Compare commits
5 Commits
bc6f5eca9c
...
cf1b4778a1
| Author | SHA1 | Date |
|---|---|---|
|
|
cf1b4778a1 | |
|
|
77928dc93d | |
|
|
659fcf633c | |
|
|
9a1cd1124d | |
|
|
3782e12ef6 |
|
|
@ -242,6 +242,7 @@ set(SRC_FILES
|
|||
communication/message/ethphymessage.cpp
|
||||
communication/message/linmessage.cpp
|
||||
communication/message/livedatamessage.cpp
|
||||
communication/message/tc10statusmessage.cpp
|
||||
communication/packet/flexraypacket.cpp
|
||||
communication/packet/canpacket.cpp
|
||||
communication/packet/a2bpacket.cpp
|
||||
|
|
@ -259,6 +260,7 @@ set(SRC_FILES
|
|||
communication/packet/componentversionpacket.cpp
|
||||
communication/packet/supportedfeaturespacket.cpp
|
||||
communication/packet/genericbinarystatuspacket.cpp
|
||||
communication/packet/hardwareinfopacket.cpp
|
||||
communication/decoder.cpp
|
||||
communication/encoder.cpp
|
||||
communication/ethernetpacketizer.cpp
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
- RADComet3
|
||||
- CAN works
|
||||
- Ethernet works
|
||||
- neoVI Connect
|
||||
- CAN works
|
||||
- CAN FD works
|
||||
- Ethernet works
|
||||
|
||||
- Connecting over USB
|
||||
- ValueCAN 4 series
|
||||
|
|
@ -53,4 +57,4 @@
|
|||
- RADMoon3
|
||||
- RADComet3
|
||||
- CAN works
|
||||
- Ethernet works
|
||||
- Ethernet works
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ static constexpr const char* VALUE_NOT_YET_PRESENT = "The value is not yet prese
|
|||
static constexpr const char* TIMEOUT = "The timeout was reached.";
|
||||
static constexpr const char* WIVI_NOT_SUPPORTED = "Wireless neoVI functions are not supported on this device.";
|
||||
static constexpr const char* RESTRICTED_ENTRY_FLAG = "Attempted to set a restricted flag in a Root Directory entry.";
|
||||
static constexpr const char* NOT_SUPPORTED = "The requested feature is not supported.";
|
||||
|
||||
// Device Errors
|
||||
static constexpr const char* POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
||||
|
|
@ -221,6 +222,8 @@ const char* APIEvent::DescriptionForType(Type type) {
|
|||
return WIVI_NOT_SUPPORTED;
|
||||
case Type::RestrictedEntryFlag:
|
||||
return RESTRICTED_ENTRY_FLAG;
|
||||
case Type::NotSupported:
|
||||
return NOT_SUPPORTED;
|
||||
|
||||
// Device Errors
|
||||
case Type::PollingMessageOverflow:
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ using namespace icsneo;
|
|||
int Communication::messageCallbackIDCounter = 1;
|
||||
|
||||
Communication::~Communication() {
|
||||
if(redirectingRead)
|
||||
clearRedirectRead();
|
||||
if(isOpen())
|
||||
close();
|
||||
}
|
||||
|
|
@ -44,6 +42,11 @@ void Communication::spawnThreads() {
|
|||
|
||||
void Communication::joinThreads() {
|
||||
closing = true;
|
||||
|
||||
if(pauseReadTask) {
|
||||
resumeReads();
|
||||
}
|
||||
|
||||
if(readTaskThread.joinable())
|
||||
readTaskThread.join();
|
||||
closing = false;
|
||||
|
|
@ -96,23 +99,6 @@ bool Communication::sendCommand(ExtendedCommand cmd, std::vector<uint8_t> argume
|
|||
return sendCommand(Command::Extended, arguments);
|
||||
}
|
||||
|
||||
bool Communication::redirectRead(std::function<void(std::vector<uint8_t>&&)> redirectTo) {
|
||||
if(redirectingRead)
|
||||
return false;
|
||||
redirectionFn = redirectTo;
|
||||
redirectingRead = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Communication::clearRedirectRead() {
|
||||
if(!redirectingRead)
|
||||
return;
|
||||
// The mutex is required to clear the redirection, but not to set it
|
||||
std::lock_guard<std::mutex> lk(redirectingReadMutex);
|
||||
redirectingRead = false;
|
||||
redirectionFn = std::function<void(std::vector<uint8_t>&&)>();
|
||||
}
|
||||
|
||||
bool Communication::getSettingsSync(std::vector<uint8_t>& data, std::chrono::milliseconds timeout) {
|
||||
static const std::shared_ptr<MessageFilter> filter = std::make_shared<MessageFilter>(Network::NetID::ReadSettings);
|
||||
std::shared_ptr<Message> msg = waitForMessageSync([this]() {
|
||||
|
|
@ -261,44 +247,55 @@ void Communication::dispatchMessage(const std::shared_ptr<Message>& msg) {
|
|||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||
}
|
||||
|
||||
void Communication::readTask() {
|
||||
std::vector<uint8_t> readBytes;
|
||||
void Communication::pauseReads() {
|
||||
std::unique_lock<std::mutex> lk(pauseReadTaskMutex);
|
||||
pauseReadTask = true;
|
||||
}
|
||||
|
||||
void Communication::resumeReads() {
|
||||
std::unique_lock<std::mutex> lk(pauseReadTaskMutex);
|
||||
if(!pauseReadTask) {
|
||||
return;
|
||||
}
|
||||
pauseReadTask = false;
|
||||
lk.unlock();
|
||||
|
||||
pauseReadTaskCv.notify_one();
|
||||
}
|
||||
|
||||
bool Communication::readsArePaused() {
|
||||
std::unique_lock<std::mutex> lk(pauseReadTaskMutex);
|
||||
return pauseReadTask;
|
||||
}
|
||||
|
||||
void Communication::readTask() {
|
||||
EventManager::GetInstance().downgradeErrorsOnCurrentThread();
|
||||
|
||||
while(!closing) {
|
||||
readBytes.clear();
|
||||
if(pauseReadTask) {
|
||||
std::unique_lock<std::mutex> lk(pauseReadTaskMutex);
|
||||
pauseReadTaskCv.wait(lk, [this]() { return !pauseReadTask; });
|
||||
}
|
||||
if(driver->readAvailable()) {
|
||||
handleInput(*packetizer, readBytes);
|
||||
if(pauseReadTask) {
|
||||
/**
|
||||
* Reads could have paused while the driver was not available
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
handleInput(*packetizer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Communication::handleInput(Packetizer& p, std::vector<uint8_t>& readBytes) {
|
||||
if(redirectingRead) {
|
||||
// redirectingRead is an atomic so it can be set without acquiring a mutex
|
||||
// However, we do not clear it without the mutex. The idea is that if another
|
||||
// thread calls clearRedirectRead(), it will block until the redirectionFn
|
||||
// finishes, and after that the redirectionFn will not be called again.
|
||||
std::unique_lock<std::mutex> lk(redirectingReadMutex);
|
||||
// So after we acquire the mutex, we need to check the atomic again, and
|
||||
// if it has become cleared, we *can not* run the redirectionFn.
|
||||
if(redirectingRead) {
|
||||
redirectionFn(std::move(readBytes));
|
||||
} else {
|
||||
// The redirectionFn got cleared while we were acquiring the lock
|
||||
lk.unlock(); // We don't need the lock anymore
|
||||
handleInput(p, readBytes); // and we might as well process this input ourselves
|
||||
}
|
||||
} else {
|
||||
if(p.input(driver->getReadBuffer())) {
|
||||
for(const auto& packet : p.output()) {
|
||||
std::shared_ptr<Message> msg;
|
||||
if(!decoder->decode(msg, packet))
|
||||
continue;
|
||||
void Communication::handleInput(Packetizer& p) {
|
||||
if(p.input(driver->getReadBuffer())) {
|
||||
for(const auto& packet : p.output()) {
|
||||
std::shared_ptr<Message> msg;
|
||||
if(!decoder->decode(msg, packet))
|
||||
continue;
|
||||
|
||||
dispatchMessage(msg);
|
||||
}
|
||||
dispatchMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
#include "icsneo/communication/message/extendeddatamessage.h"
|
||||
#include "icsneo/communication/message/livedatamessage.h"
|
||||
#include "icsneo/communication/message/diskdatamessage.h"
|
||||
#include "icsneo/communication/message/hardwareinfo.h"
|
||||
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||
#include "icsneo/communication/command.h"
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/communication/packet/canpacket.h"
|
||||
|
|
@ -35,6 +37,8 @@
|
|||
#include "icsneo/communication/packet/mdiopacket.h"
|
||||
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
||||
#include "icsneo/communication/packet/livedatapacket.h"
|
||||
#include "icsneo/communication/packet/hardwareinfopacket.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace icsneo;
|
||||
|
|
@ -286,6 +290,9 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||
case ExtendedCommand::LiveData:
|
||||
result = HardwareLiveDataPacket::DecodeToMessage(packet->data, report);
|
||||
return true;
|
||||
case ExtendedCommand::GetTC10Status:
|
||||
result = TC10StatusMessage::DecodeToMessage(packet->data);
|
||||
return true;
|
||||
default:
|
||||
// No defined handler, treat this as a RawMessage
|
||||
break;
|
||||
|
|
@ -358,6 +365,16 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
|||
|
||||
return true;
|
||||
}
|
||||
case Command::GetHardwareInfo: {
|
||||
result = HardwareInfoPacket::DecodeToMessage(packet->data);
|
||||
|
||||
if(!result) {
|
||||
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
auto msg = std::make_shared<Main51Message>();
|
||||
msg->command = Command(packet->data[0]);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,33 @@
|
|||
|
||||
using namespace icsneo;
|
||||
|
||||
bool Driver::pushRx(const uint8_t* buf, size_t numReceived) {
|
||||
bool ret = readBuffer.write(buf, numReceived);
|
||||
|
||||
if(hasRxWaitRequest) {
|
||||
rxWaitRequestCv.notify_one();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Driver::waitForRx(size_t limit, std::chrono::milliseconds timeout) {
|
||||
return waitForRx([limit, this]() {
|
||||
return readBuffer.size() >= limit;
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
bool Driver::waitForRx(std::function<bool()> predicate, std::chrono::milliseconds timeout) {
|
||||
std::unique_lock<std::mutex> lk(rxWaitMutex);
|
||||
hasRxWaitRequest = true;
|
||||
|
||||
auto ret = rxWaitRequestCv.wait_for(lk, timeout, predicate);
|
||||
|
||||
hasRxWaitRequest = false;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Driver::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout, size_t limit) {
|
||||
// A limit of zero indicates no limit
|
||||
if(limit == 0)
|
||||
|
|
@ -16,14 +43,13 @@ bool Driver::readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds tim
|
|||
if(limit > (readBuffer.size() + 4))
|
||||
limit = (readBuffer.size() + 4);
|
||||
|
||||
bytes.resize(limit);
|
||||
|
||||
// wait until we have enough data, or the timout occurs
|
||||
const auto timeoutTime = std::chrono::steady_clock::now() + timeout;
|
||||
while (readBuffer.size() < limit && std::chrono::steady_clock::now() < timeoutTime) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
waitForRx(limit, timeout);
|
||||
|
||||
size_t actuallyRead = std::min(readBuffer.size(), limit);
|
||||
bytes.resize(actuallyRead);
|
||||
|
||||
readBuffer.read(bytes.data(), 0, actuallyRead);
|
||||
readBuffer.pop(actuallyRead);
|
||||
bytes.resize(actuallyRead);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||
#include "icsneo/communication/command.h"
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
#pragma pack(push, 2)
|
||||
struct Header {
|
||||
ExtendedCommand command;
|
||||
uint16_t length;
|
||||
};
|
||||
|
||||
struct Packet {
|
||||
Header header;
|
||||
TC10WakeStatus wakeStatus;
|
||||
TC10SleepStatus sleepStatus;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
std::shared_ptr<TC10StatusMessage> TC10StatusMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||
if(bytestream.size() < sizeof(Packet)) {
|
||||
return nullptr;
|
||||
}
|
||||
const Packet* packet = (Packet*)bytestream.data();
|
||||
if (packet->header.command != ExtendedCommand::GetTC10Status) {
|
||||
return nullptr;
|
||||
}
|
||||
if (packet->header.length < sizeof(Packet) - sizeof(Header)) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<TC10StatusMessage>(packet->wakeStatus, packet->sleepStatus);
|
||||
}
|
||||
|
|
@ -177,8 +177,11 @@ void MultiChannelCommunication::vnetReadTask(size_t vnetIndex) {
|
|||
if(queue.wait_dequeue_timed(payloadBytes, std::chrono::milliseconds(250))) {
|
||||
if(closing)
|
||||
break;
|
||||
|
||||
handleInput(*vnetPacketizer, payloadBytes);
|
||||
|
||||
auto& ringBuffer = driver->getReadBuffer();
|
||||
ringBuffer.write(payloadBytes);
|
||||
|
||||
handleInput(*vnetPacketizer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include "icsneo/communication/packet/hardwareinfopacket.h"
|
||||
#include "icsneo/communication/message/hardwareinfo.h"
|
||||
#include <iostream>
|
||||
using namespace icsneo;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct
|
||||
{
|
||||
uint8_t valid;
|
||||
struct
|
||||
{
|
||||
uint8_t day;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
} manufactureDate;
|
||||
struct
|
||||
{
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
} hwRev;
|
||||
uint8_t deviceId;
|
||||
struct
|
||||
{
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
} blVersion;
|
||||
} HardwareInfoFrame;
|
||||
#pragma pack(pop)
|
||||
|
||||
std::shared_ptr<HardwareInfo> HardwareInfoPacket::DecodeToMessage(const std::vector<uint8_t>& bytes) {
|
||||
if(bytes.size() < (sizeof(HardwareInfoFrame) + 1)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto* frame = reinterpret_cast<const HardwareInfoFrame*>(&bytes[1]);
|
||||
|
||||
auto msg = std::make_shared<HardwareInfo>();
|
||||
|
||||
msg->manufactureDate.day = frame->manufactureDate.day;
|
||||
msg->manufactureDate.year = frame->manufactureDate.year;
|
||||
msg->manufactureDate.month = frame->manufactureDate.month;
|
||||
|
||||
msg->hardwareRevision.major = frame->hwRev.major;
|
||||
msg->hardwareRevision.minor = frame->hwRev.minor;
|
||||
|
||||
msg->bootloaderVersion.major = frame->blVersion.major;
|
||||
msg->bootloaderVersion.minor = frame->blVersion.minor;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
|
@ -722,6 +722,37 @@ Network Device::getNetworkByNumber(Network::Type type, size_t index) const {
|
|||
return Network::NetID::Invalid;
|
||||
}
|
||||
|
||||
std::shared_ptr<HardwareInfo> Device::getHardwareInfo(std::chrono::milliseconds timeout) {
|
||||
if(!isOpen()) {
|
||||
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!isOnline()) {
|
||||
report(APIEvent::Type::DeviceCurrentlyOffline, APIEvent::Severity::Error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto filter = std::make_shared<MessageFilter>(Message::Type::HardwareInfo);
|
||||
|
||||
auto response = com->waitForMessageSync([this]() {
|
||||
return com->sendCommand(Command::GetHardwareInfo);
|
||||
}, filter, timeout);
|
||||
|
||||
if(!response) {
|
||||
report(APIEvent::Type::Timeout, APIEvent::Severity::Error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto hardwareInfo = std::dynamic_pointer_cast<HardwareInfo>(response);
|
||||
if(!hardwareInfo) {
|
||||
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return hardwareInfo;
|
||||
}
|
||||
|
||||
|
||||
std::optional<uint64_t> Device::readLogicalDisk(uint64_t pos, uint8_t* into, uint64_t amount, std::chrono::milliseconds timeout, Disk::MemoryType memType) {
|
||||
if(!into || timeout <= std::chrono::milliseconds(0)) {
|
||||
|
|
@ -3148,4 +3179,80 @@ std::optional<uint64_t> Device::getVSADiskSize() {
|
|||
return std::nullopt;
|
||||
}
|
||||
return diskSize;
|
||||
}
|
||||
}
|
||||
|
||||
bool Device::requestTC10Wake(Network::NetID network) {
|
||||
if(!supportsTC10()) {
|
||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
std::vector<uint8_t> args(sizeof(network));
|
||||
*(Network::NetID*)args.data() = network;
|
||||
auto msg = com->waitForMessageSync([&] {
|
||||
return com->sendCommand(ExtendedCommand::RequestTC10Wake, args);
|
||||
}, std::make_shared<MessageFilter>(Message::Type::ExtendedResponse), std::chrono::milliseconds(1000));
|
||||
|
||||
if(!msg) {
|
||||
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto resp = std::static_pointer_cast<ExtendedResponseMessage>(msg);
|
||||
if(!resp) {
|
||||
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return resp->response == ExtendedResponse::OK;
|
||||
}
|
||||
|
||||
bool Device::requestTC10Sleep(Network::NetID network) {
|
||||
if(!supportsTC10()) {
|
||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
std::vector<uint8_t> args(sizeof(network));
|
||||
*(Network::NetID*)args.data() = network;
|
||||
auto msg = com->waitForMessageSync([&] {
|
||||
return com->sendCommand(ExtendedCommand::RequestTC10Sleep, args);
|
||||
}, std::make_shared<MessageFilter>(Message::Type::ExtendedResponse), std::chrono::milliseconds(1000));
|
||||
|
||||
if(!msg) {
|
||||
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto typed = std::static_pointer_cast<ExtendedResponseMessage>(msg);
|
||||
if(!typed) {
|
||||
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return typed->response == ExtendedResponse::OK;
|
||||
}
|
||||
|
||||
std::optional<TC10StatusMessage> Device::getTC10Status(Network::NetID network) {
|
||||
if(!supportsTC10()) {
|
||||
report(APIEvent::Type::NotSupported, APIEvent::Severity::Error);
|
||||
return std::nullopt;
|
||||
}
|
||||
std::vector<uint8_t> args(sizeof(network));
|
||||
*(Network::NetID*)args.data() = network;
|
||||
auto msg = com->waitForMessageSync([&] {
|
||||
return com->sendCommand(ExtendedCommand::GetTC10Status, args);
|
||||
}, std::make_shared<MessageFilter>(Message::Type::TC10Status), std::chrono::milliseconds(1000));
|
||||
|
||||
if(!msg) {
|
||||
report(APIEvent::Type::NoDeviceResponse, APIEvent::Severity::Error);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto typed = std::static_pointer_cast<TC10StatusMessage>(msg);
|
||||
|
||||
if(!typed) {
|
||||
report(APIEvent::Type::UnexpectedResponse, APIEvent::Severity::Error);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *typed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@ std::vector<std::shared_ptr<Device>> DeviceFinder::FindAll() {
|
|||
makeIfSerialMatches<NeoOBD2SIM>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVICONNECT_H_
|
||||
makeIfSerialMatches<NeoVIConnect>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIFIRE_H_
|
||||
makeIfPIDMatches<NeoVIFIRE>(dev, newFoundDevices);
|
||||
#endif
|
||||
|
|
@ -288,6 +292,10 @@ const std::vector<DeviceType>& DeviceFinder::GetSupportedDevices() {
|
|||
NeoVIRED2::DEVICE_TYPE,
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVICONNECT_H_
|
||||
NeoVIConnect::DEVICE_TYPE,
|
||||
#endif
|
||||
|
||||
#ifdef __NEOVIFIRE_H_
|
||||
NeoVIFIRE::DEVICE_TYPE,
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public:
|
|||
Timeout = 0x1014,
|
||||
WiVINotSupported = 0x1015,
|
||||
RestrictedEntryFlag = 0x1016,
|
||||
NotSupported = 0x1017,
|
||||
|
||||
// Device Events
|
||||
PollingMessageOverflow = 0x2000,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ enum class Command : uint8_t {
|
|||
UpdateLEDState = 0xA7,
|
||||
SetDefaultSettings = 0xA8, // Follow up with SaveSettings to write to EEPROM
|
||||
GetSecondaryVersions = 0xA9, // Previously known as RED_CMD_PERIPHERALS_APP_VERSION_REQ, versions other than the main chip
|
||||
GetHardwareInfo = 0xB7, // Previously known as RED_CMD_HARDWARE_VERSION_REQ
|
||||
GetLogicalDiskInfo = 0xBB, // Previously known as RED_CMD_GET_SDCARD_INFO
|
||||
RequestStatusUpdate = 0xBC,
|
||||
ReadSettings = 0xC7, // Previously known as 3G_READ_SETTINGS_EX
|
||||
|
|
@ -55,6 +56,9 @@ enum class ExtendedCommand : uint16_t {
|
|||
SetRootFSEntryFlags = 0x0027,
|
||||
GenericBinaryInfo = 0x0030,
|
||||
LiveData = 0x0035,
|
||||
RequestTC10Wake = 0x003D,
|
||||
RequestTC10Sleep = 0x003E,
|
||||
GetTC10Status = 0x003F,
|
||||
};
|
||||
|
||||
enum class ExtendedResponse : int32_t {
|
||||
|
|
|
|||
|
|
@ -48,8 +48,10 @@ public:
|
|||
void awaitModeChangeComplete() { driver->awaitModeChangeComplete(); }
|
||||
bool rawWrite(const std::vector<uint8_t>& bytes) { return driver->write(bytes); }
|
||||
virtual bool sendPacket(std::vector<uint8_t>& bytes);
|
||||
bool redirectRead(std::function<void(std::vector<uint8_t>&&)> redirectTo);
|
||||
void clearRedirectRead();
|
||||
|
||||
void pauseReads();
|
||||
void resumeReads();
|
||||
bool readsArePaused();
|
||||
|
||||
void setWriteBlocks(bool blocks) { driver->writeBlocks = blocks; }
|
||||
|
||||
|
|
@ -90,12 +92,14 @@ protected:
|
|||
std::mutex messageCallbacksLock;
|
||||
std::map<int, std::shared_ptr<MessageCallback>> messageCallbacks;
|
||||
std::atomic<bool> closing{false};
|
||||
std::atomic<bool> redirectingRead{false};
|
||||
std::function<void(std::vector<uint8_t>&&)> redirectionFn;
|
||||
std::mutex redirectingReadMutex; // Don't allow read to be disabled while in the redirectionFn
|
||||
|
||||
std::condition_variable pauseReadTaskCv;
|
||||
std::mutex pauseReadTaskMutex;
|
||||
std::atomic<bool> pauseReadTask = false;
|
||||
|
||||
std::mutex syncMessageMutex;
|
||||
|
||||
void handleInput(Packetizer& p, std::vector<uint8_t>& readBytes);
|
||||
void handleInput(Packetizer& p);
|
||||
|
||||
private:
|
||||
std::thread readTaskThread;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ public:
|
|||
virtual void awaitModeChangeComplete() {}
|
||||
virtual bool isDisconnected() { return disconnected; };
|
||||
virtual bool close() = 0;
|
||||
|
||||
bool waitForRx(size_t limit, std::chrono::milliseconds timeout);
|
||||
bool waitForRx(std::function<bool()> predicate, std::chrono::milliseconds timeout);
|
||||
bool readWait(std::vector<uint8_t>& bytes, std::chrono::milliseconds timeout = std::chrono::milliseconds(100), size_t limit = 0);
|
||||
bool write(const std::vector<uint8_t>& bytes);
|
||||
virtual bool isEthernet() const { return false; }
|
||||
|
|
@ -57,8 +60,12 @@ protected:
|
|||
virtual bool writeQueueAlmostFull() { return writeQueue.size_approx() > (writeQueueSize * 3 / 4); }
|
||||
virtual bool writeInternal(const std::vector<uint8_t>& b) { return writeQueue.enqueue(WriteOperation(b)); }
|
||||
|
||||
|
||||
bool pushRx(const uint8_t* buf, size_t numReceived);
|
||||
RingBuffer readBuffer = RingBuffer(ICSNEO_DRIVER_RINGBUFFER_SIZE);
|
||||
std::atomic<bool> hasRxWaitRequest = false;
|
||||
std::condition_variable rxWaitRequestCv;
|
||||
std::mutex rxWaitMutex;
|
||||
|
||||
moodycamel::BlockingConcurrentQueue<WriteOperation> writeQueue;
|
||||
std::thread readThread, writeThread;
|
||||
std::atomic<bool> closing{false};
|
||||
|
|
|
|||
|
|
@ -9,6 +9,20 @@ class ComponentVersion {
|
|||
public:
|
||||
ComponentVersion(uint8_t valid, uint8_t componentInfo, uint32_t identifier, uint32_t dotVersion, uint32_t commitHash) :
|
||||
valid(valid), componentInfo(componentInfo), identifier(identifier), dotVersion(dotVersion), commitHash(commitHash) {}
|
||||
|
||||
static ComponentVersion FromAppVersion(uint32_t identifier, uint8_t appMajor, uint8_t appMinor) {
|
||||
uint32_t dotVersion = (appMajor << 24) | (appMinor << 16);
|
||||
|
||||
|
||||
return ComponentVersion(
|
||||
static_cast<uint8_t>(1u),
|
||||
static_cast<uint8_t>(0u),
|
||||
identifier,
|
||||
dotVersion,
|
||||
static_cast<uint8_t>(0u)
|
||||
);
|
||||
}
|
||||
|
||||
const bool valid;
|
||||
const uint8_t componentInfo;
|
||||
const uint32_t identifier;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef _HARDWARE_INFO_MESSAGE_H_
|
||||
#define _HARDWARE_INFO_MESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "icsneo/communication/message/message.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class HardwareInfo : public Message {
|
||||
public:
|
||||
HardwareInfo() : Message(Message::Type::HardwareInfo) {}
|
||||
struct Version {
|
||||
uint8_t major;
|
||||
uint8_t minor;
|
||||
};
|
||||
|
||||
struct Date {
|
||||
uint8_t day;
|
||||
uint8_t month;
|
||||
uint16_t year;
|
||||
};
|
||||
|
||||
Date manufactureDate;
|
||||
Version hardwareRevision;
|
||||
Version bootloaderVersion;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
|
|
@ -38,6 +38,8 @@ public:
|
|||
SupportedFeatures = 0x800d,
|
||||
GenericBinaryStatus = 0x800e,
|
||||
LiveData = 0x800f,
|
||||
HardwareInfo = 0x8010,
|
||||
TC10Status = 0x8011,
|
||||
};
|
||||
|
||||
Message(Type t) : type(t) {}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef __TC10STATUSMESSAGE_H
|
||||
#define __TC10STATUSMESSAGE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo
|
||||
{
|
||||
|
||||
enum class TC10WakeStatus : uint8_t {
|
||||
NoWakeReceived,
|
||||
WakeReceived,
|
||||
};
|
||||
|
||||
enum class TC10SleepStatus : uint8_t {
|
||||
NoSleepReceived,
|
||||
SleepReceived,
|
||||
SleepFailed,
|
||||
SleepAborted,
|
||||
};
|
||||
|
||||
class TC10StatusMessage : public Message {
|
||||
public:
|
||||
static std::shared_ptr<TC10StatusMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
|
||||
TC10StatusMessage(const TC10WakeStatus& wakeStatus, const TC10SleepStatus& sleepStatus) :
|
||||
Message(Type::TC10Status), wakeStatus(wakeStatus), sleepStatus(sleepStatus) {}
|
||||
|
||||
const TC10WakeStatus wakeStatus;
|
||||
const TC10SleepStatus sleepStatus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef __HARDWAREINFOPACKET_H__
|
||||
#define __HARDWAREINFOPACKET_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class HardwareInfo;
|
||||
|
||||
struct HardwareInfoPacket {
|
||||
static std::shared_ptr<HardwareInfo> DecodeToMessage(const std::vector<uint8_t>& bytes);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __DEVICECOMPONENTVERSIONPACKET_H__
|
||||
|
|
@ -34,8 +34,10 @@
|
|||
#include "icsneo/communication/message/scriptstatusmessage.h"
|
||||
#include "icsneo/communication/message/supportedfeaturesmessage.h"
|
||||
#include "icsneo/communication/message/genericbinarystatusmessage.h"
|
||||
#include "icsneo/communication/message/hardwareinfo.h"
|
||||
#include "icsneo/communication/message/extendeddatamessage.h"
|
||||
#include "icsneo/communication/message/livedatamessage.h"
|
||||
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||
#include "icsneo/communication/packet/genericbinarystatuspacket.h"
|
||||
#include "icsneo/communication/packet/livedatapacket.h"
|
||||
#include "icsneo/device/extensions/flexray/controller.h"
|
||||
|
|
@ -45,6 +47,8 @@
|
|||
#include "icsneo/platform/nodiscard.h"
|
||||
#include "icsneo/disk/vsa/vsa.h"
|
||||
#include "icsneo/disk/vsa/vsaparser.h"
|
||||
#include "icsneo/communication/message/versionmessage.h"
|
||||
|
||||
|
||||
#define ICSNEO_FINDABLE_DEVICE_BASE(className, type) \
|
||||
static constexpr DeviceType::Enum DEVICE_TYPE = type; \
|
||||
|
|
@ -222,6 +226,7 @@ public:
|
|||
virtual size_t getNetworkCountByType(Network::Type) const;
|
||||
virtual Network getNetworkByNumber(Network::Type, size_t) const;
|
||||
|
||||
std::shared_ptr<HardwareInfo> getHardwareInfo(std::chrono::milliseconds timeout = std::chrono::milliseconds(2));
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -565,6 +570,7 @@ public:
|
|||
*/
|
||||
const std::vector<std::optional<DeviceAppVersion>>& getVersions() const { return versions; }
|
||||
const std::vector<ComponentVersion>& getComponentVersions() const { return componentVersions; }
|
||||
|
||||
/**
|
||||
* Some alternate communication protocols do not support DFU
|
||||
*/
|
||||
|
|
@ -717,6 +723,14 @@ public:
|
|||
|
||||
virtual bool supportsComponentVersions() const { return false; }
|
||||
|
||||
virtual bool supportsTC10() const { return false; }
|
||||
|
||||
bool requestTC10Wake(Network::NetID network);
|
||||
|
||||
bool requestTC10Sleep(Network::NetID network);
|
||||
|
||||
std::optional<TC10StatusMessage> getTC10Status(Network::NetID network);
|
||||
|
||||
protected:
|
||||
bool online = false;
|
||||
int messagePollingCallbackID = 0;
|
||||
|
|
@ -822,8 +836,6 @@ protected:
|
|||
|
||||
neodevice_t& getWritableNeoDevice() { return data; }
|
||||
|
||||
|
||||
|
||||
private:
|
||||
neodevice_t data;
|
||||
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public:
|
|||
RADMoon3 = (0x00000023),
|
||||
RADComet = (0x00000024),
|
||||
FIRE3_FlexRay = (0x00000025),
|
||||
Connect = (0x00000026),
|
||||
RADComet3 = (0x00000027),
|
||||
RED = (0x00000040),
|
||||
ECU = (0x00000080),
|
||||
|
|
@ -189,6 +190,8 @@ public:
|
|||
return "neoVI FIRE3 FlexRay";
|
||||
case RADComet3:
|
||||
return "RAD-Comet 3";
|
||||
case Connect:
|
||||
return "neoVI Connect";
|
||||
case DONT_REUSE0:
|
||||
case DONT_REUSE1:
|
||||
case DONT_REUSE2:
|
||||
|
|
@ -242,6 +245,7 @@ private:
|
|||
#define ICSNEO_DEVICETYPE_RADMoon3 ((devicetype_t)0x00000023)
|
||||
#define ICSNEO_DEVICETYPE_RADCOMET ((devicetype_t)0x00000024)
|
||||
#define ICSNEO_DEVICETYPE_FIRE3FLEXRAY ((devicetype_t)0x00000025)
|
||||
#define ICSNEO_DEVICETYPE_CONNECT ((devicetype_t)0x00000026)
|
||||
#define ICSNEO_DEVICETYPE_RADCOMET3 ((devicetype_t)0x00000027)
|
||||
#define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040)
|
||||
#define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef __NEOVICONNECT_H_
|
||||
#define __NEOVICONNECT_H_
|
||||
|
||||
#include "icsneo/device/device.h"
|
||||
#include "icsneo/device/devicetype.h"
|
||||
#include "icsneo/disk/extextractordiskreaddriver.h"
|
||||
#include "icsneo/disk/neomemorydiskdriver.h"
|
||||
#include "icsneo/device/tree/neoviconnect/neoviconnectsettings.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class NeoVIConnect : public Device {
|
||||
public:
|
||||
// Serial numbers start with DM
|
||||
// Ethernet MAC allocation is 0x1F, standard driver is Raw
|
||||
ICSNEO_FINDABLE_DEVICE(NeoVIConnect, DeviceType::Connect, "DM");
|
||||
|
||||
static const std::vector<Network>& GetSupportedNetworks() {
|
||||
static std::vector<Network> supportedNetworks = {
|
||||
Network::NetID::HSCAN,
|
||||
Network::NetID::MSCAN,
|
||||
Network::NetID::HSCAN2,
|
||||
Network::NetID::HSCAN3,
|
||||
Network::NetID::HSCAN4,
|
||||
Network::NetID::HSCAN5,
|
||||
Network::NetID::HSCAN6,
|
||||
Network::NetID::HSCAN7,
|
||||
|
||||
Network::NetID::Ethernet,
|
||||
|
||||
Network::NetID::LIN,
|
||||
Network::NetID::LIN2
|
||||
};
|
||||
return supportedNetworks;
|
||||
}
|
||||
|
||||
protected:
|
||||
NeoVIConnect(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
|
||||
initialize<NeoVIConnectSettings, Disk::ExtExtractorDiskReadDriver, Disk::NeoMemoryDiskDriver>(makeDriver);
|
||||
}
|
||||
|
||||
virtual void setupEncoder(Encoder& encoder) override {
|
||||
Device::setupEncoder(encoder);
|
||||
encoder.supportCANFD = true;
|
||||
}
|
||||
|
||||
void setupPacketizer(Packetizer& packetizer) override {
|
||||
Device::setupPacketizer(packetizer);
|
||||
packetizer.align16bit = true;
|
||||
}
|
||||
|
||||
void setupSupportedRXNetworks(std::vector<Network>& rxNetworks) override {
|
||||
for(auto& netid : GetSupportedNetworks())
|
||||
rxNetworks.emplace_back(netid);
|
||||
}
|
||||
|
||||
// The supported TX networks are the same as the supported RX networks for this device
|
||||
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
|
||||
|
||||
bool supportsWiVI() const override { return true; }
|
||||
|
||||
bool supportsLiveData() const override { return true; }
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressFlash() const override {
|
||||
return 33*1024*1024;
|
||||
}
|
||||
|
||||
std::optional<MemoryAddress> getCoreminiStartAddressSD() const override {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
#ifndef __NEOVICONNECTSETTINGS_H_
|
||||
#define __NEOVICONNECTSETTINGS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "icsneo/device/idevicesettings.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4201) // nameless struct/union
|
||||
#endif
|
||||
|
||||
#pragma pack(push, 2)
|
||||
typedef struct {
|
||||
uint16_t perf_en;
|
||||
uint16_t network_enabled_on_boot;
|
||||
uint16_t misc_io_on_report_events;
|
||||
uint16_t pwr_man_enable;
|
||||
int16_t iso15765_separation_time_offset;
|
||||
uint16_t reservedA;
|
||||
uint32_t pwr_man_timeout;
|
||||
uint64_t network_enables;
|
||||
CAN_SETTINGS can1;
|
||||
CANFD_SETTINGS canfd1;
|
||||
CAN_SETTINGS can2;
|
||||
CANFD_SETTINGS canfd2;
|
||||
CAN_SETTINGS can3;
|
||||
CANFD_SETTINGS canfd3;
|
||||
CAN_SETTINGS can4;
|
||||
CANFD_SETTINGS canfd4;
|
||||
CAN_SETTINGS can5;
|
||||
CANFD_SETTINGS canfd5;
|
||||
CAN_SETTINGS can6;
|
||||
CANFD_SETTINGS canfd6;
|
||||
CAN_SETTINGS can7;
|
||||
CANFD_SETTINGS canfd7;
|
||||
CAN_SETTINGS can8;
|
||||
CANFD_SETTINGS canfd8;
|
||||
LIN_SETTINGS lin1;
|
||||
LIN_SETTINGS lin2;
|
||||
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;
|
||||
uint16_t iso_parity;
|
||||
uint16_t iso_msg_termination;
|
||||
ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
|
||||
uint16_t iso_parity_2;
|
||||
uint16_t iso_msg_termination_2;
|
||||
ETHERNET_SETTINGS ethernet_1;
|
||||
ETHERNET_SETTINGS2 ethernet2_1;
|
||||
ETHERNET_SETTINGS ethernet_2;
|
||||
ETHERNET_SETTINGS2 ethernet2_2;
|
||||
STextAPISettings text_api;
|
||||
DISK_SETTINGS disk;
|
||||
uint16_t misc_io_report_period;
|
||||
uint16_t ain_threshold;
|
||||
uint16_t misc_io_analog_enable;
|
||||
uint16_t digitalIoThresholdTicks;
|
||||
uint16_t digitalIoThresholdEnable;
|
||||
uint16_t misc_io_initial_ddr;
|
||||
uint16_t misc_io_initial_latch;
|
||||
Fire3LinuxSettings os_settings;
|
||||
RAD_GPTP_SETTINGS gPTP;
|
||||
struct
|
||||
{
|
||||
uint32_t disableUsbCheckOnBoot : 1;
|
||||
uint32_t enableLatencyTest : 1;
|
||||
uint32_t enableDefaultLogger : 1;
|
||||
uint32_t enableDefaultUpload : 1;
|
||||
uint32_t reserved3 : 28;
|
||||
} flags;
|
||||
} neoviconnect_settings_t;
|
||||
|
||||
typedef struct {
|
||||
} neoviconnect_status_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class NeoVIConnectSettings : public IDeviceSettings {
|
||||
public:
|
||||
NeoVIConnectSettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neoviconnect_settings_t)) {}
|
||||
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||
auto cfg = getStructurePointer<neoviconnect_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
switch(net.getNetID()) {
|
||||
case Network::NetID::HSCAN:
|
||||
return &(cfg->can1);
|
||||
case Network::NetID::HSCAN2:
|
||||
return &(cfg->can2);
|
||||
case Network::NetID::HSCAN3:
|
||||
return &(cfg->can3);
|
||||
case Network::NetID::HSCAN4:
|
||||
return &(cfg->can4);
|
||||
case Network::NetID::HSCAN5:
|
||||
return &(cfg->can5);
|
||||
case Network::NetID::HSCAN6:
|
||||
return &(cfg->can6);
|
||||
case Network::NetID::HSCAN7:
|
||||
return &(cfg->can7);
|
||||
case Network::NetID::MSCAN:
|
||||
return &(cfg->can8);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||
auto cfg = getStructurePointer<neoviconnect_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
switch(net.getNetID()) {
|
||||
case Network::NetID::HSCAN:
|
||||
return &(cfg->canfd1);
|
||||
case Network::NetID::HSCAN2:
|
||||
return &(cfg->canfd2);
|
||||
case Network::NetID::HSCAN3:
|
||||
return &(cfg->canfd3);
|
||||
case Network::NetID::HSCAN4:
|
||||
return &(cfg->canfd4);
|
||||
case Network::NetID::HSCAN5:
|
||||
return &(cfg->canfd5);
|
||||
case Network::NetID::HSCAN6:
|
||||
return &(cfg->canfd6);
|
||||
case Network::NetID::HSCAN7:
|
||||
return &(cfg->canfd7);
|
||||
case Network::NetID::MSCAN:
|
||||
return &(cfg->canfd8);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
const LIN_SETTINGS* getLINSettingsFor(Network net) const override {
|
||||
auto cfg = getStructurePointer<neoviconnect_settings_t>();
|
||||
if(cfg == nullptr)
|
||||
return nullptr;
|
||||
switch(net.getNetID()) {
|
||||
case Network::NetID::LIN:
|
||||
return &(cfg->lin1);
|
||||
case Network::NetID::LIN2:
|
||||
return &(cfg->lin2);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
|
|
@ -18,6 +18,8 @@ public:
|
|||
|
||||
bool supportsComponentVersions() const override { return true; }
|
||||
|
||||
bool supportsTC10() const override { return true; }
|
||||
|
||||
protected:
|
||||
RADMoon2ZL(neodevice_t neodevice, const driver_factory_t& makeDriver) : RADMoon2Base(neodevice) {
|
||||
initialize<RADMoon2Settings>(makeDriver);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "icsneo/device/tree/etherbadge/etherbadge.h"
|
||||
#include "icsneo/device/tree/neoobd2pro/neoobd2pro.h"
|
||||
#include "icsneo/device/tree/neoobd2sim/neoobd2sim.h"
|
||||
#include "icsneo/device/tree/neoviconnect/neoviconnect.h"
|
||||
#include "icsneo/device/tree/neovifire/neovifire.h"
|
||||
#include "icsneo/device/tree/neovifire2/neovifire2.h"
|
||||
#include "icsneo/device/tree/neovifire3/neovifire3.h"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "icsneo/device/tree/etherbadge/etherbadge.h"
|
||||
#include "icsneo/device/tree/neoobd2pro/neoobd2pro.h"
|
||||
#include "icsneo/device/tree/neoobd2sim/neoobd2sim.h"
|
||||
#include "icsneo/device/tree/neoviconnect/neoviconnect.h"
|
||||
#include "icsneo/device/tree/neovifire/neovifire.h"
|
||||
#include "icsneo/device/tree/neovifire2/neovifire2.h"
|
||||
#include "icsneo/device/tree/neovifire3/neovifire3.h"
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ void FTD3XX::readTask() {
|
|||
}
|
||||
FT_ReleaseOverlapped(*handle, &overlap);
|
||||
if(received > 0) {
|
||||
readBuffer.write(buffer, received);
|
||||
pushRx(buffer, received);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ void CDCACM::readTask() {
|
|||
}
|
||||
std::cout << std::dec << std::endl;
|
||||
#endif
|
||||
readBuffer.write(readbuf, bytesRead);
|
||||
pushRx(readbuf, bytesRead);
|
||||
} else {
|
||||
if(modeChanging) {
|
||||
// We were expecting a disconnect for reenumeration
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ void FirmIO::readTask() {
|
|||
|
||||
// Translate the physical address back to our virtual address space
|
||||
uint8_t* addr = reinterpret_cast<uint8_t*>(msg.payload.data.addr - PHY_ADDR_BASE + vbase);
|
||||
while (!readBuffer.write(addr, msg.payload.data.len)) {
|
||||
while (!pushRx(addr, msg.payload.data.len)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // back-off so reading thread can empty the buffer
|
||||
if (closing || isDisconnected()) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ void FTDI::readTask() {
|
|||
} else
|
||||
report(APIEvent::Type::FailedToRead, APIEvent::Severity::EventWarning);
|
||||
} else
|
||||
readBuffer.write(readbuf, readBytes);
|
||||
pushRx(readbuf, readBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ void PCAP::readTask() {
|
|||
PCAP* driver = reinterpret_cast<PCAP*>(obj);
|
||||
if(driver->ethPacketizer.inputUp({data, data + header->caplen})) {
|
||||
const auto bytes = driver->ethPacketizer.outputUp();
|
||||
driver->readBuffer.write(bytes.data(), bytes.size());
|
||||
driver->pushRx(bytes.data(), bytes.size());
|
||||
}
|
||||
}, (uint8_t*)this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ void TCP::readTask() {
|
|||
uint8_t readbuf[READ_BUFFER_SIZE];
|
||||
while(!closing) {
|
||||
if(const auto received = ::recv(*socket, (char*)readbuf, READ_BUFFER_SIZE, 0); received > 0) {
|
||||
readBuffer.write(readbuf, received);
|
||||
pushRx(readbuf, received);
|
||||
} else {
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 50'000;
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ void PCAP::readTask() {
|
|||
|
||||
if(ethPacketizer.inputUp({data, data + header->caplen})) {
|
||||
const auto bytes = ethPacketizer.outputUp();
|
||||
readBuffer.write(bytes.data(), bytes.size());
|
||||
pushRx(bytes.data(), bytes.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ void VCP::readTask() {
|
|||
if(ReadFile(detail->handle, readbuf, READ_BUFFER_SIZE, nullptr, &detail->overlappedRead)) {
|
||||
if(GetOverlappedResult(detail->handle, &detail->overlappedRead, &bytesRead, FALSE)) {
|
||||
if(bytesRead)
|
||||
readBuffer.write(readbuf, bytesRead);
|
||||
pushRx(readbuf, bytesRead);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
@ -413,7 +413,7 @@ void VCP::readTask() {
|
|||
auto ret = WaitForSingleObject(detail->overlappedRead.hEvent, 100);
|
||||
if(ret == WAIT_OBJECT_0) {
|
||||
if(GetOverlappedResult(detail->handle, &detail->overlappedRead, &bytesRead, FALSE)) {
|
||||
readBuffer.write(readbuf, bytesRead);
|
||||
pushRx(readbuf, bytesRead);
|
||||
state = LAUNCH;
|
||||
} else
|
||||
report(APIEvent::Type::FailedToRead, APIEvent::Severity::Error);
|
||||
|
|
|
|||
Loading…
Reference in New Issue