From 4e901676d289decc4fa7a5f294356fcc78620dc9 Mon Sep 17 00:00:00 2001 From: David Rebbe Date: Mon, 7 Jun 2021 17:03:56 -0400 Subject: [PATCH 01/17] Added icsneoOpenDevice. --- api/icsneolegacy/dllhelper/icsneo40DLLAPI.cpp | 4 +++- api/icsneolegacy/dllhelper/icsneo40DLLAPI.h | 2 ++ api/icsneolegacy/icsneolegacy.cpp | 19 +++++++++++++++++++ include/icsneo/icsneolegacy.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/api/icsneolegacy/dllhelper/icsneo40DLLAPI.cpp b/api/icsneolegacy/dllhelper/icsneo40DLLAPI.cpp index e7cf697..dafea23 100644 --- a/api/icsneolegacy/dllhelper/icsneo40DLLAPI.cpp +++ b/api/icsneolegacy/dllhelper/icsneo40DLLAPI.cpp @@ -5,6 +5,7 @@ //Basic Functions FINDNEODEVICES icsneoFindNeoDevices; OPENNEODEVICE icsneoOpenNeoDevice; +OPENDEVICE icsneoOpenDevice; CLOSEPORT icsneoClosePort; FREEOBJECT icsneoFreeObject; ////OPENPORTEX icsneoOpenPortEx; @@ -137,6 +138,7 @@ bool LoadDLLAPI(HINSTANCE &hAPIDLL) icsneoFindNeoDevices = (FINDNEODEVICES) GetProcAddress(hAPIDLL, "icsneoFindNeoDevices"); icsneoOpenNeoDevice = (OPENNEODEVICE) GetProcAddress(hAPIDLL, "icsneoOpenNeoDevice"); + icsneoOpenDevice = (OPENDEVICE) GetProcAddress(hAPIDLL, "icsneoOpenDevice"); icsneoClosePort = (CLOSEPORT) GetProcAddress(hAPIDLL, "icsneoClosePort"); icsneoFreeObject = (FREEOBJECT) GetProcAddress(hAPIDLL, "icsneoFreeObject"); //// icsneoOpenPortEx = (OPENPORTEX) GetProcAddress(hAPIDLL, "icsneoOpenPortEx"); @@ -204,7 +206,7 @@ bool LoadDLLAPI(HINSTANCE &hAPIDLL) icsneoEnableDOIPLine = (ENABLEDOIPACTIVATIONLINE)GetProcAddress(hAPIDLL, "icsneoEnableDOIPLine"); - if(!icsneoFindNeoDevices || !icsneoOpenNeoDevice || !icsneoClosePort || !icsneoFreeObject || + if(!icsneoFindNeoDevices || !icsneoOpenNeoDevice || !icsneoOpenDevice || !icsneoClosePort || !icsneoFreeObject || !icsneoTxMessages || !icsneoGetMessages || !icsneoWaitForRxMessagesWithTimeOut || !icsneoGetTimeStampForMsg || !icsneoEnableNetworkRXQueue || !icsneoGetISO15765Status || !icsneoTxMessagesEx || !icsneoSetISO15765RxParameters || !icsneoGetConfiguration || !icsneoSendConfiguration || diff --git a/api/icsneolegacy/dllhelper/icsneo40DLLAPI.h b/api/icsneolegacy/dllhelper/icsneo40DLLAPI.h index aa2b80c..4bed6e0 100644 --- a/api/icsneolegacy/dllhelper/icsneo40DLLAPI.h +++ b/api/icsneolegacy/dllhelper/icsneo40DLLAPI.h @@ -11,6 +11,7 @@ void UnloadDLLAPI(HINSTANCE &hAPIDLL); //Basic Functions typedef int (__stdcall *FINDNEODEVICES)(unsigned long DeviceTypes, NeoDevice *pNeoDevice, int *pNumDevices); typedef int (__stdcall *OPENNEODEVICE)(NeoDevice *pNeoDevice, void * hObject, unsigned char *bNetworkIDs, int bConfigRead, int bSyncToPC); +typedef int (__stdcall *OPENDEVICE)(NeoDeviceEx* pNeoDeviceEx, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int iOptions, OptionsOpenNeoEx* stOptionsOpenNeoEx, unsigned long reserved); typedef int (__stdcall *CLOSEPORT)(void * hObject, int *pNumberOfErrors); typedef void (__stdcall *FREEOBJECT)(void * hObject); typedef int (__stdcall *OPENPORTEX)(void * lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, @@ -115,6 +116,7 @@ typedef int (__stdcall *SCRIPTWRITEISO15765TXMESSAGE)(void * hObject, unsigned //Basic Functions extern FINDNEODEVICES icsneoFindNeoDevices; extern OPENNEODEVICE icsneoOpenNeoDevice; +extern OPENDEVICE icsneoOpenDevice; extern CLOSEPORT icsneoClosePort; extern FREEOBJECT icsneoFreeObject; extern SERIALNUMBERTOSTRING icsneoSerialNumberToString; diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index 9097060..ffecc41 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -169,6 +169,25 @@ int icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, unsigned char* bN return icsneo_setPollingMessageLimit(device, 20000) && icsneo_enableMessagePolling(device) && icsneo_goOnline(device); } +int icsneoOpenDevice(NeoDeviceEx* pNeoDeviceEx, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int iOptions, OptionsOpenNeoEx* stOptionsOpenNeoEx, unsigned long reserved) { + if(pNeoDeviceEx == nullptr || hObject == nullptr) + return false; + + neodevice_t* device; + try { + device = &neodevices.at(uint64_t(pNeoDeviceEx->neoDevice.Handle) << 32 | pNeoDeviceEx->neoDevice.SerialNumber); + } catch(std::out_of_range& e) { + (void)e; // Unused + return false; + } + + *hObject = device; + if(!icsneo_openDevice(device)) + return false; + + return icsneo_setPollingMessageLimit(device, 20000) && icsneo_enableMessagePolling(device) && icsneo_goOnline(device); +} + int icsneoClosePort(void* hObject, int* pNumberOfErrors) { if(!icsneoValidateHObject(hObject)) return false; diff --git a/include/icsneo/icsneolegacy.h b/include/icsneo/icsneolegacy.h index 7503059..8dea1cc 100644 --- a/include/icsneo/icsneolegacy.h +++ b/include/icsneo/icsneolegacy.h @@ -16,6 +16,7 @@ extern "C" { extern int DLLExport icsneoFindDevices(NeoDeviceEx* pNeoDeviceEx, int* pNumDevices, unsigned int* DeviceTypes, unsigned int numDeviceTypes,POptionsFindNeoEx* pOptionsNeoEx, unsigned int* reserved); extern int DLLExport icsneoFindNeoDevices(unsigned long DeviceTypes, NeoDevice* pNeoDevice, int* pNumDevices); extern int DLLExport icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int bSyncToPC); +extern int DLLExport icsneoOpenDevice(NeoDeviceEx* pNeoDeviceEx, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int iOptions, OptionsOpenNeoEx* stOptionsOpenNeoEx, unsigned long reserved); extern int DLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors); extern void DLLExport icsneoFreeObject(void* hObject); extern int DLLExport icsneoSerialNumberToString(unsigned long serial, char* data, unsigned long data_size); From d4f6c1239407731a5f6eef7eb7fc968f10c5d570 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 25 May 2021 17:23:41 -0400 Subject: [PATCH 02/17] CANPacket: Fix invalid length check This case is already checked above, and further was invalid since the length had already been translated to the numeric (0-64) value. --- communication/packet/canpacket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/communication/packet/canpacket.cpp b/communication/packet/canpacket.cpp index 4268a69..c20a3d9 100644 --- a/communication/packet/canpacket.cpp +++ b/communication/packet/canpacket.cpp @@ -109,7 +109,7 @@ bool HardwareCANPacket::EncodeFromMessage(const CANMessage& message, std::vector const optional lenFromDLC = CANFD_DLCToLength(message.dlcOnWire); if (lenFromDLC.has_value() && *lenFromDLC != 0) { - if (*lenFromDLC < lengthNibble || *lenFromDLC > 0xF) { + if (*lenFromDLC < lengthNibble) { report(APIEvent::Type::MessageMaxLengthExceeded, APIEvent::Severity::Error); return false; } From b340d167dc9e2c6f8ae214b8b64de72a5bb14af6 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Thu, 27 May 2021 22:47:36 -0400 Subject: [PATCH 03/17] Support the neoVI RED 2 --- device/devicefinder.cpp | 8 + include/icsneo/device/devicetype.h | 4 + .../icsneo/device/tree/neovired2/neovired2.h | 91 +++++++++ .../device/tree/neovired2/neovired2settings.h | 178 ++++++++++++++++++ include/icsneo/platform/posix/devices.h | 1 + include/icsneo/platform/windows/devices.h | 1 + 6 files changed, 283 insertions(+) create mode 100644 include/icsneo/device/tree/neovired2/neovired2.h create mode 100644 include/icsneo/device/tree/neovired2/neovired2settings.h diff --git a/device/devicefinder.cpp b/device/devicefinder.cpp index ba6ffa5..e636cc0 100644 --- a/device/devicefinder.cpp +++ b/device/devicefinder.cpp @@ -19,6 +19,10 @@ static std::vector supportedDevices = { NeoOBD2SIM::DEVICE_TYPE, #endif + #ifdef __NEOVIRED2_H_ + NeoVIRED2::DEVICE_TYPE, + #endif + #ifdef __NEOVIFIRE_H_ NeoVIFIRE::DEVICE_TYPE, #endif @@ -153,6 +157,10 @@ std::vector> DeviceFinder::FindAll() { findResults.push_back(NeoVIFIRE2USB::Find()); #endif + #ifdef __NEOVIRED2_H_ + findResults.push_back(NeoVIRED2::Find(pcapDevices)); + #endif + #ifdef __NEOVIION_H_ findResults.push_back(NeoVIION::Find()); #endif diff --git a/include/icsneo/device/devicetype.h b/include/icsneo/device/devicetype.h index b6011ff..a46391b 100644 --- a/include/icsneo/device/devicetype.h +++ b/include/icsneo/device/devicetype.h @@ -42,6 +42,7 @@ public: RADJupiter = (0x00000011), VCAN4_IND = (0x00000012), RADGigastar = (0x00000013), + RED2 = (0x00000014), EtherBADGE = (0x00000016), RED = (0x00000040), ECU = (0x00000080), @@ -119,6 +120,8 @@ public: return "ValueCAN 4 Industrial"; case RADGigastar: return "RAD-Gigastar"; + case RED2: + return "neoVI RED 2"; case EtherBADGE: return "EtherBADGE"; case RED: @@ -210,6 +213,7 @@ private: #define ICSNEO_DEVICETYPE_RADJUPITER ((devicetype_t)0x00000011) #define ICSNEO_DEVICETYPE_VCAN4_IND ((devicetype_t)0x00000012) #define ICSNEO_DEVICETYPE_RADGIGASTAR ((devicetype_t)0x00000013) +#define ICSNEO_DEVICETYPE_RED2 ((devicetype_t)0x00000014) #define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) #define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040) #define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080) diff --git a/include/icsneo/device/tree/neovired2/neovired2.h b/include/icsneo/device/tree/neovired2/neovired2.h new file mode 100644 index 0000000..93cc464 --- /dev/null +++ b/include/icsneo/device/tree/neovired2/neovired2.h @@ -0,0 +1,91 @@ +#ifndef __NEOVIRED2_H_ +#define __NEOVIRED2_H_ + +#include "icsneo/device/device.h" +#include "icsneo/device/devicetype.h" +#include "icsneo/platform/pcap.h" +#include "icsneo/device/tree/neovired2/neovired2settings.h" + +namespace icsneo { + +class NeoVIRED2 : public Device { +public: + static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RED2; + static constexpr const char* SERIAL_START = "D2"; + static constexpr const uint16_t PRODUCT_ID = 0x000E; + static std::vector> Find(const std::vector& pcapDevices) { + std::vector> found; + + for(auto& foundDev : pcapDevices) { + auto fakedev = std::shared_ptr(new NeoVIRED2({})); + for (auto& payload : foundDev.discoveryPackets) + fakedev->com->packetizer->input(payload); + for (auto& packet : fakedev->com->packetizer->output()) { + std::shared_ptr msg; + if (!fakedev->com->decoder->decode(msg, packet)) + continue; // We failed to decode this packet + + if(!msg || msg->type != Message::Type::Main51) + continue; // Not a message we care about + auto sn = std::dynamic_pointer_cast(msg); + if(!sn) + continue; // Not a serial number message + + if(sn->deviceSerial.length() < 2) + continue; + if(sn->deviceSerial.substr(0, 2) != SERIAL_START) + continue; // Not a RED 2 + + auto device = foundDev.device; + device.serial[sn->deviceSerial.copy(device.serial, sizeof(device.serial))] = '\0'; + found.emplace_back(new NeoVIRED2(std::move(device))); + break; + } + } + + return found; + } + + static const std::vector& GetSupportedNetworks() { + static std::vector 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: + NeoVIRED2(neodevice_t neodevice) : Device(neodevice) { + initialize(); + getWritableNeoDevice().type = DEVICE_TYPE; + productId = PRODUCT_ID; + } + + virtual void setupEncoder(Encoder& encoder) override { + Device::setupEncoder(encoder); + encoder.supportCANFD = true; + } + + virtual void setupSupportedRXNetworks(std::vector& 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 + virtual void setupSupportedTXNetworks(std::vector& txNetworks) override { setupSupportedRXNetworks(txNetworks); } +}; + +} + +#endif \ No newline at end of file diff --git a/include/icsneo/device/tree/neovired2/neovired2settings.h b/include/icsneo/device/tree/neovired2/neovired2settings.h new file mode 100644 index 0000000..416d54d --- /dev/null +++ b/include/icsneo/device/tree/neovired2/neovired2settings.h @@ -0,0 +1,178 @@ +#ifndef __NEOVIRED2SETTINGS_H_ +#define __NEOVIRED2SETTINGS_H_ + +#include +#include "icsneo/device/idevicesettings.h" + +#ifdef __cplusplus + +namespace icsneo { + +#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 slaveVnetA; + uint32_t reserved; + uint64_t termination_enables; + union { + uint64_t word; + struct + { + uint16_t network_enables; + uint16_t network_enables_2; + uint16_t network_enables_3; + }; + } network_enables; + uint32_t pwr_man_timeout; + 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_1; + uint16_t iso_parity_1; + uint16_t iso_msg_termination_1; + ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2; + uint16_t iso_parity_2; + uint16_t iso_msg_termination_2; + ETHERNET_SETTINGS ethernet; + TIMESYNC_ICSHARDWARE_SETTINGS timeSync; + STextAPISettings text_api; + struct + { + uint32_t disableUsbCheckOnBoot : 1; + uint32_t enableLatencyTest : 1; + uint32_t busMessagesToAndroid : 1; + uint32_t enablePcEthernetComm : 1; + uint32_t enableDefaultLogger : 1; + uint32_t enableDefaultUpload : 1; + uint32_t reserved : 26; + } flags; + 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; + ETHERNET_SETTINGS2 ethernet2; +} neovired2_settings_t; + +typedef struct { + uint8_t backupPowerGood; + uint8_t backupPowerEnabled; + uint8_t usbHostPowerEnabled; + uint8_t ethernetActivationLineEnabled; + EthernetNetworkStatus ethernetStatus; +} neovired2_status_t; +#pragma pack(pop) + +#ifdef __cplusplus + +#include + +class NeoVIRED2Settings : public IDeviceSettings { +public: + NeoVIRED2Settings(std::shared_ptr com) : IDeviceSettings(com, sizeof(neovired2_settings_t)) {} + const CAN_SETTINGS* getCANSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::HSCAN: + return &(cfg->can1); + case Network::NetID::MSCAN: + return &(cfg->can2); + case Network::NetID::HSCAN2: + return &(cfg->can3); + case Network::NetID::HSCAN3: + return &(cfg->can4); + case Network::NetID::HSCAN4: + return &(cfg->can5); + case Network::NetID::HSCAN5: + return &(cfg->can6); + case Network::NetID::HSCAN6: + return &(cfg->can7); + case Network::NetID::HSCAN7: + return &(cfg->can8); + default: + return nullptr; + } + } + const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + switch(net.getNetID()) { + case Network::NetID::HSCAN: + return &(cfg->canfd1); + case Network::NetID::MSCAN: + return &(cfg->canfd2); + case Network::NetID::HSCAN2: + return &(cfg->canfd3); + case Network::NetID::HSCAN3: + return &(cfg->canfd4); + case Network::NetID::HSCAN4: + return &(cfg->canfd5); + case Network::NetID::HSCAN5: + return &(cfg->canfd6); + case Network::NetID::HSCAN6: + return &(cfg->canfd7); + case Network::NetID::HSCAN7: + return &(cfg->canfd8); + default: + return nullptr; + } + } + + virtual std::vector getTerminationGroups() const override { + return { + { + Network(Network::NetID::HSCAN), + Network(Network::NetID::HSCAN3), + Network(Network::NetID::HSCAN5), + Network(Network::NetID::HSCAN7) + }, + { + Network(Network::NetID::MSCAN), + Network(Network::NetID::HSCAN2), + Network(Network::NetID::HSCAN4), + Network(Network::NetID::HSCAN6) + } + }; + } + +protected: + ICSNEO_UNALIGNED(const uint64_t*) getTerminationEnables() const override { + auto cfg = getStructurePointer(); + if(cfg == nullptr) + return nullptr; + return &cfg->termination_enables; + } +}; + +} + +#endif // __cplusplus + +#endif \ No newline at end of file diff --git a/include/icsneo/platform/posix/devices.h b/include/icsneo/platform/posix/devices.h index 90149d4..49b9cf0 100644 --- a/include/icsneo/platform/posix/devices.h +++ b/include/icsneo/platform/posix/devices.h @@ -7,6 +7,7 @@ #include "icsneo/device/tree/neovifire/neovifire.h" #include "icsneo/device/tree/neovifire2/neovifire2eth.h" #include "icsneo/device/tree/neovifire2/neovifire2usb.h" +#include "icsneo/device/tree/neovired2/neovired2.h" #include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviplasma.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" diff --git a/include/icsneo/platform/windows/devices.h b/include/icsneo/platform/windows/devices.h index 2c7b882..f9008dd 100644 --- a/include/icsneo/platform/windows/devices.h +++ b/include/icsneo/platform/windows/devices.h @@ -7,6 +7,7 @@ #include "icsneo/device/tree/neovifire/neovifire.h" #include "icsneo/device/tree/neovifire2/neovifire2eth.h" #include "icsneo/device/tree/neovifire2/neovifire2usb.h" +#include "icsneo/device/tree/neovired2/neovired2.h" #include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviplasma.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" From 19aabdfacfa3c41bd3dad7280b19ff43fc2da770 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Thu, 27 May 2021 22:47:44 -0400 Subject: [PATCH 04/17] POSIX: PCAP: Cancel after pcap_breakloop() to EINTR out of poll() This is necessary as pcap_breakloop() does not actually wake the thread from blocking operations, such as poll. --- platform/posix/pcap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/posix/pcap.cpp b/platform/posix/pcap.cpp index 85a5eed..67ffc27 100644 --- a/platform/posix/pcap.cpp +++ b/platform/posix/pcap.cpp @@ -234,6 +234,7 @@ bool PCAP::close() { closing = true; // Signal the threads that we are closing pcap_breakloop(interface.fp); + pthread_cancel(readThread.native_handle()); readThread.join(); writeThread.join(); closing = false; From 7b7320bc27ba5d1be733090f070a685979ba72d2 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 28 May 2021 18:10:16 -0400 Subject: [PATCH 05/17] Support the RAD-Epsilon --- device/devicefinder.cpp | 10 +++- include/icsneo/device/devicetype.h | 4 ++ .../device/tree/radepsilon/radepsilon.h | 59 +++++++++++++++++++ include/icsneo/platform/posix/devices.h | 1 + include/icsneo/platform/windows/devices.h | 1 + 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 include/icsneo/device/tree/radepsilon/radepsilon.h diff --git a/device/devicefinder.cpp b/device/devicefinder.cpp index e636cc0..53c27df 100644 --- a/device/devicefinder.cpp +++ b/device/devicefinder.cpp @@ -43,6 +43,10 @@ static std::vector supportedDevices = { NeoVIPLASMA::DEVICE_TYPE, #endif + #ifdef __RADEPSILON_H_ + RADEpsilon::DEVICE_TYPE, + #endif + #ifdef __RADGALAXY_H_ RADGalaxy::DEVICE_TYPE, #endif @@ -169,6 +173,10 @@ std::vector> DeviceFinder::FindAll() { findResults.push_back(NeoVIPLASMA::Find()); #endif + #ifdef __RADEPSILON_H_ + findResults.push_back(RADEpsilon::Find()); + #endif + #ifdef __RADGALAXY_H_ findResults.push_back(RADGalaxy::Find(pcapDevices)); #endif @@ -267,4 +275,4 @@ const std::vector& DeviceFinder::GetSupportedDevices() { supportedDevicesCached = true; } return supportedDevices; -} \ No newline at end of file +} diff --git a/include/icsneo/device/devicetype.h b/include/icsneo/device/devicetype.h index a46391b..dc083b9 100644 --- a/include/icsneo/device/devicetype.h +++ b/include/icsneo/device/devicetype.h @@ -44,6 +44,7 @@ public: RADGigastar = (0x00000013), RED2 = (0x00000014), EtherBADGE = (0x00000016), + RADEpsilon = (0x00000018), RED = (0x00000040), ECU = (0x00000080), IEVB = (0x00000100), @@ -124,6 +125,8 @@ public: return "neoVI RED 2"; case EtherBADGE: return "EtherBADGE"; + case RADEpsilon: + return "RAD-Epsilon"; case RED: return "neoVI RED"; case ECU: @@ -215,6 +218,7 @@ private: #define ICSNEO_DEVICETYPE_RADGIGASTAR ((devicetype_t)0x00000013) #define ICSNEO_DEVICETYPE_RED2 ((devicetype_t)0x00000014) #define ICSNEO_DEVICETYPE_ETHERBADGE ((devicetype_t)0x00000016) +#define ICSNEO_DEVICETYPE_RADEPSILON ((devicetype_t)0x00000018) #define ICSNEO_DEVICETYPE_RED ((devicetype_t)0x00000040) #define ICSNEO_DEVICETYPE_ECU ((devicetype_t)0x00000080) #define ICSNEO_DEVICETYPE_IEVB ((devicetype_t)0x00000100) diff --git a/include/icsneo/device/tree/radepsilon/radepsilon.h b/include/icsneo/device/tree/radepsilon/radepsilon.h new file mode 100644 index 0000000..9858bd9 --- /dev/null +++ b/include/icsneo/device/tree/radepsilon/radepsilon.h @@ -0,0 +1,59 @@ +#ifndef __RADEPSILON_H_ +#define __RADEPSILON_H_ + +#include "icsneo/device/device.h" +#include "icsneo/device/devicetype.h" +#include "icsneo/platform/cdcacm.h" + +namespace icsneo { + +class RADEpsilon : public Device { +public: + static constexpr DeviceType::Enum DEVICE_TYPE = DeviceType::RADEpsilon; + static constexpr const char* SERIAL_START = "RE"; + static constexpr const uint16_t PRODUCT_ID = 0x1109; + static std::vector> Find() { + std::vector> found; + + for(auto neodevice : CDCACM::FindByProduct(PRODUCT_ID)) + found.emplace_back(new RADEpsilon(neodevice)); + + return found; + } + + static const std::vector& GetSupportedNetworks() { + static std::vector supportedNetworks = { + Network::NetID::HSCAN, + Network::NetID::HSCAN2, + + Network::NetID::Ethernet, // Connected to port 6 on the switch + + Network::NetID::LIN + }; + return supportedNetworks; + } + +protected: + RADEpsilon(neodevice_t neodevice) : Device(neodevice) { + initialize(); + getWritableNeoDevice().type = DEVICE_TYPE; + productId = PRODUCT_ID; + } + + virtual void setupEncoder(Encoder& encoder) override { + Device::setupEncoder(encoder); + encoder.supportCANFD = true; + } + + virtual void setupSupportedRXNetworks(std::vector& 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 + virtual void setupSupportedTXNetworks(std::vector& txNetworks) override { setupSupportedRXNetworks(txNetworks); } +}; + +} + +#endif diff --git a/include/icsneo/platform/posix/devices.h b/include/icsneo/platform/posix/devices.h index 49b9cf0..d9931c0 100644 --- a/include/icsneo/platform/posix/devices.h +++ b/include/icsneo/platform/posix/devices.h @@ -10,6 +10,7 @@ #include "icsneo/device/tree/neovired2/neovired2.h" #include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviplasma.h" +#include "icsneo/device/tree/radepsilon/radepsilon.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgigalog/radgigalogeth.h" #include "icsneo/device/tree/radgigalog/radgigalogusb.h" diff --git a/include/icsneo/platform/windows/devices.h b/include/icsneo/platform/windows/devices.h index f9008dd..a56a678 100644 --- a/include/icsneo/platform/windows/devices.h +++ b/include/icsneo/platform/windows/devices.h @@ -10,6 +10,7 @@ #include "icsneo/device/tree/neovired2/neovired2.h" #include "icsneo/device/tree/plasion/neoviion.h" #include "icsneo/device/tree/plasion/neoviplasma.h" +#include "icsneo/device/tree/radepsilon/radepsilon.h" #include "icsneo/device/tree/radgalaxy/radgalaxy.h" #include "icsneo/device/tree/radgigalog/radgigalogeth.h" #include "icsneo/device/tree/radgigalog/radgigalogusb.h" From ed94012046fb3252205b5188bda8920e539ca25d Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Sun, 30 May 2021 02:55:00 -0700 Subject: [PATCH 06/17] Examples: Interactive C: Fix initializers --- examples/c/interactive/src/main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/c/interactive/src/main.c b/examples/c/interactive/src/main.c index 509d36a..e1f458c 100644 --- a/examples/c/interactive/src/main.c +++ b/examples/c/interactive/src/main.c @@ -31,7 +31,7 @@ void printAllDevices() { printf("No devices found! Please scan for new devices.\n"); } for(int i = 0; i < numDevices; i++) { - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; // Updates productDescription and descriptionLength for each device @@ -272,7 +272,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -333,7 +333,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -381,7 +381,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -440,7 +440,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -505,7 +505,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -560,7 +560,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -586,7 +586,7 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); @@ -712,13 +712,13 @@ int main() { selectedDevice = selectDevice(); // Get the product description for the device - char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = {}; + char productDescription[ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION] = { 0 }; size_t descriptionLength = ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION; icsneo_describeDevice(selectedDevice, productDescription, &descriptionLength); printf("Termination is "); const bool val = icsneo_isTerminationEnabledFor(selectedDevice, ICSNEO_NETID_HSCAN); - neoevent_t err = {}; + neoevent_t err = { 0 }; if(icsneo_getLastError(&err)) { printf("not available at this time: %s\n\n", err.description); break; From 165eb0f8a242076356de0f082ef858cbfa6de62c Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Sun, 30 May 2021 02:57:18 -0700 Subject: [PATCH 07/17] Windows: Correct dynamic load helper when _UNICODE is defined --- include/icsneo/platform/windows/dynamiclib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/icsneo/platform/windows/dynamiclib.h b/include/icsneo/platform/windows/dynamiclib.h index 5fe3378..d40b1f3 100644 --- a/include/icsneo/platform/windows/dynamiclib.h +++ b/include/icsneo/platform/windows/dynamiclib.h @@ -12,7 +12,7 @@ // MSVC does not have the ability to specify a destructor #define ICSNEO_DESTRUCTOR -#define icsneo_dynamicLibraryLoad() LoadLibrary("icsneoc.dll") +#define icsneo_dynamicLibraryLoad() LoadLibrary(TEXT("icsneoc.dll")) #define icsneo_dynamicLibraryGetFunction(handle, func) GetProcAddress((HMODULE) handle, func) #define icsneo_dynamicLibraryClose(handle) FreeLibrary((HMODULE) handle) From 1b7db51a45381d2c53709ea7fcbd9588d6737868 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Sun, 30 May 2021 03:02:41 -0700 Subject: [PATCH 08/17] Windows: PCAP: Fix Npcap loading for _UNICODE --- platform/windows/internal/pcapdll.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/platform/windows/internal/pcapdll.cpp b/platform/windows/internal/pcapdll.cpp index 7bce8d5..80a6223 100644 --- a/platform/windows/internal/pcapdll.cpp +++ b/platform/windows/internal/pcapdll.cpp @@ -1,4 +1,5 @@ #include "icsneo/platform/windows/internal/pcapdll.h" +#include using namespace icsneo; @@ -27,22 +28,19 @@ bool PCAPDLL::ok() const PCAPDLL::PCAPDLL() { + DLL_DIRECTORY_COOKIE cookie = 0; #ifdef NPCAP - BOOL(WINAPI * SetDllDirectory)(LPCTSTR); - char sysdir_name[512]; - int len; - SetDllDirectory = (BOOL(WINAPI*)(LPCTSTR)) GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA"); - if (SetDllDirectory != NULL) - { - len = GetSystemDirectory(sysdir_name, 480); // be safe - if (len) - { - strcat(sysdir_name, "\\Npcap"); - SetDllDirectory(sysdir_name); - } + TCHAR dllPath[512] = { 0 }; + int len = GetSystemDirectory(dllPath, 480); // be safe + if (len) { + _tcscat_s(dllPath, 512, TEXT("\\Npcap")); + cookie = AddDllDirectory(dllPath); } #endif - dll = LoadLibrary(TEXT("wpcap.dll")); + dll = LoadLibraryEx(TEXT("wpcap.dll"), nullptr, LOAD_LIBRARY_SEARCH_USER_DIRS); + + if (cookie) + RemoveDllDirectory(cookie); if(dll == NULL) { closeDLL(); From 4095f23ded5a6221b98de9560957d943dc930291 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Tue, 1 Jun 2021 22:40:26 -0400 Subject: [PATCH 09/17] Settings: Make getBaudrateFor work for SWCAN and LSFTCAN --- device/idevicesettings.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/device/idevicesettings.cpp b/device/idevicesettings.cpp index 8f27ce6..2605421 100644 --- a/device/idevicesettings.cpp +++ b/device/idevicesettings.cpp @@ -375,7 +375,35 @@ int64_t IDeviceSettings::getBaudrateFor(Network net) const { case Network::Type::CAN: { const CAN_SETTINGS* cfg = getCANSettingsFor(net); if(cfg == nullptr) { - report(APIEvent::Type::CANFDSettingsNotAvailable, APIEvent::Severity::Error); + report(APIEvent::Type::CANSettingsNotAvailable, APIEvent::Severity::Error); + return -1; + } + + int64_t baudrate = GetBaudrateValueForEnum((CANBaudrate)cfg->Baudrate); + if(baudrate == -1) { + report(APIEvent::Type::BaudrateNotFound, APIEvent::Severity::Error); + return -1; + } + return baudrate; + } + case Network::Type::SWCAN: { + const SWCAN_SETTINGS* cfg = getSWCANSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::SWCANSettingsNotAvailable, APIEvent::Severity::Error); + return -1; + } + + int64_t baudrate = GetBaudrateValueForEnum((CANBaudrate)cfg->Baudrate); + if(baudrate == -1) { + report(APIEvent::Type::BaudrateNotFound, APIEvent::Severity::Error); + return -1; + } + return baudrate; + } + case Network::Type::LSFTCAN: { + const CAN_SETTINGS* cfg = getLSFTCANSettingsFor(net); + if(cfg == nullptr) { + report(APIEvent::Type::LSFTCANSettingsNotAvailable, APIEvent::Severity::Error); return -1; } From 9e70a9d51fc06dbebda7a6170ddf0a2742d92670 Mon Sep 17 00:00:00 2001 From: Sangeetha Hariharasudhan Date: Tue, 23 Apr 2019 20:35:49 -0400 Subject: [PATCH 10/17] API: Legacy: Implement functions necessary for J2534 icsneoEnableNetworkComEx icsneoGetDeviceSettingsType icsneoGetDeviceSettings icsneoSetDeviceSettings icsneoGetMiniportAdapterInfo icsneoEnableDOIPLine icsneoGetVnetSimpleNetid icsneoGetNetidforSlaveVNETs icsneoSetBitRateEx icsneoSetFDBitRate icsneoSerialNumberFromString icsneoJ2534Cmd _stdcall convention added with .def file (octal support) use NumberBytesHeader instead of NodeID in txmessagesEx --- CMakeLists.txt | 1 + api/icsneolegacy/icsneolegacy.cpp | 1380 +++++++++++++++--- api/icsneolegacy/icsneolegacyextra.cpp | 6 +- include/icsneo/J2534.h | 33 + include/icsneo/communication/command.h | 3 + include/icsneo/icsnVC40.h | 12 + include/icsneo/icsneolegacy.h | 185 ++- include/icsneo/platform/posix/dynamiclib.h | 1 + include/icsneo/platform/windows/dynamiclib.h | 1 + platform/windows/icsneolegacy.def | 99 ++ 10 files changed, 1468 insertions(+), 253 deletions(-) create mode 100644 include/icsneo/J2534.h create mode 100644 platform/windows/icsneolegacy.def diff --git a/CMakeLists.txt b/CMakeLists.txt index 23ff690..7cc3dcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,6 +269,7 @@ if(LIBICSNEO_BUILD_ICSNEOLEGACY) api/icsneolegacy/icsneolegacy.cpp api/icsneolegacy/icsneolegacyextra.cpp api/icsneoc/icsneoc.cpp + platform/windows/icsneolegacy.def ) target_include_directories(icsneolegacy PUBLIC diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index 9097060..526f26c 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -6,6 +6,7 @@ #define ICSNEOC_MAKEDLL #include "icsneo/icsneolegacy.h" +#include "icsneo/J2534.h" #undef ICSNEOC_MAKEDLL #include "icsneo/icsneoc.h" @@ -26,8 +27,13 @@ using namespace icsneo; typedef uint64_t legacymaphandle_t; static std::map neodevices; -static NeoDevice OldNeoDeviceFromNew(const neodevice_t* newnd) { - NeoDevice oldnd = { 0 }; +std::map mp_netIDToVnetOffSet = {{NETID_HSCAN, 1}, {NETID_MSCAN, 2}, {NETID_HSCAN2, 18}, {NETID_HSCAN3, 19}, {NETID_HSCAN4, 32}, {NETID_HSCAN5, 33}, {NETID_HSCAN6, 47}, {NETID_HSCAN7, 48}}; +std::map mp_HWnetIDToCMnetID = {{NETID_HSCAN, 0}, {NETID_MSCAN, 1}, {NETID_HSCAN2, 5}, {NETID_HSCAN3, 8}, {NETID_HSCAN4, 14}, {NETID_HSCAN5, 15}, {NETID_HSCAN6, 32}, {NETID_HSCAN7, 33}}; +unsigned long vnet_table[] = {0, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE2_OFFSET}; + +static NeoDevice OldNeoDeviceFromNew(const neodevice_t *newnd) +{ + NeoDevice oldnd = {0}; oldnd.DeviceType = newnd->type; oldnd.SerialNumber = icsneo_serialStringToNum(newnd->serial); oldnd.NumberOfClients = 0; @@ -37,216 +43,675 @@ static NeoDevice OldNeoDeviceFromNew(const neodevice_t* newnd) { return oldnd; } -static void NeoMessageToSpyMessage(const neodevice_t* device, const neomessage_t& newmsg, icsSpyMessage& oldmsg) { +static void NeoMessageToSpyMessage(const neodevice_t *device, const neomessage_t &newmsg, icsSpyMessage &oldmsg) +{ memset(&oldmsg, 0, sizeof(icsSpyMessage)); oldmsg.NumberBytesData = (uint8_t)std::min(newmsg.length, (size_t)255); oldmsg.NumberBytesHeader = 4; oldmsg.ExtraDataPtr = (void*)newmsg.data; - oldmsg.ExtraDataPtrEnabled = newmsg.length > 8 ? 1 :0; + oldmsg.ExtraDataPtrEnabled = newmsg.length > 8 ? 1 : 0; memcpy(oldmsg.Data, newmsg.data, std::min(newmsg.length, (size_t)8)); - oldmsg.ArbIDOrHeader = *(uint32_t*)newmsg.header; + oldmsg.ArbIDOrHeader = *(uint32_t *)newmsg.header; oldmsg.NetworkID = (uint8_t)newmsg.netid; // Note: NetID remapping from the original API is not supported oldmsg.DescriptionID = newmsg.description; oldmsg.StatusBitField = newmsg.status.statusBitfield[0]; oldmsg.StatusBitField2 = newmsg.status.statusBitfield[1]; oldmsg.StatusBitField3 = newmsg.status.statusBitfield[2]; oldmsg.StatusBitField4 = newmsg.status.statusBitfield[3]; - switch(Network::Type(newmsg.type)) { - case Network::Type::CAN: - case Network::Type::SWCAN: - case Network::Type::LSFTCAN: - oldmsg.Protocol = newmsg.status.canfdFDF ? SPY_PROTOCOL_CANFD : SPY_PROTOCOL_CAN; - break; - case Network::Type::Ethernet: - oldmsg.Protocol = SPY_PROTOCOL_ETHERNET; - break; + switch (Network::Type(newmsg.type)) + { + case Network::Type::CAN: + case Network::Type::SWCAN: + case Network::Type::LSFTCAN: + oldmsg.Protocol = newmsg.status.canfdFDF ? SPY_PROTOCOL_CANFD : SPY_PROTOCOL_CAN; + break; + case Network::Type::Ethernet: + oldmsg.Protocol = SPY_PROTOCOL_ETHERNET; + break; } - + // Timestamp - epoch = 1/1/2007 - 25ns per tick most of the time uint64_t t = newmsg.timestamp; uint16_t res = 0; - if (icsneo_getTimestampResolution(device, &res)) { + if (icsneo_getTimestampResolution(device, &res)) + { t /= res; oldmsg.TimeHardware2 = (unsigned long)(t >> 32); oldmsg.TimeHardware = (unsigned long)(t & 0xFFFFFFFF); - switch (res) { - case 25: - oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NEORED_25NS; - break; - case 10: - oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NEORED_10NS; - break; - default: - oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NONE; + switch (res) + { + case 25: + oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NEORED_25NS; + break; + case 10: + oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NEORED_10NS; + break; + default: + oldmsg.TimeStampHardwareID = HARDWARE_TIMESTAMP_ID_NONE; } } } -//Basic Functions -int icsneoFindDevices(NeoDeviceEx* devs, int* devCount, unsigned int* devTypes, unsigned int devTypeCount, POptionsFindNeoEx*, unsigned int*) { - constexpr size_t MAX_DEVICES = 255; - if(devCount == nullptr) - return 0; - - unsigned int devTypesDefault[] = { std::numeric_limits::max() }; - if(devTypes == nullptr || devTypeCount == 0) { - devTypes = devTypesDefault; - devTypeCount = 1; - } - - size_t count = MAX_DEVICES; - if(devs == nullptr) { // Size query - icsneo_findAllDevices(nullptr, &count); - *devCount = (int)count; - return 1; - } - - size_t bufferSize = (size_t)*devCount; - if(*devCount < 0 || bufferSize > MAX_DEVICES) - return 0; - - neodevice_t devices[MAX_DEVICES]; - icsneo_findAllDevices(devices, &count); - if(bufferSize < count) - count = bufferSize; - *devCount = (int)count; - - for(size_t i = 0; i < count; i++) { - devs[i] = { OldNeoDeviceFromNew(&devices[i]) }; // Write out into user memory - neodevices[uint64_t(devices[i].handle) << 32 | icsneo_serialStringToNum(devices[i].serial)] = devices[i]; // Fill the look up table - } - - return 1; +inline bool Within(size_t value, size_t min, size_t max) +{ + return ((min <= value) && (value < max)); +} +inline bool IdIsSlaveARange1(size_t fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE1_OFFSET + PLASMA_SLAVE_NUM); +} +inline bool IdIsSlaveARange2(size_t fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE1_OFFSET_RANGE2, PLASMA_SLAVE2_OFFSET_RANGE2); +} +inline bool IdIsSlaveBRange1(size_t fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE2_OFFSET, PLASMA_SLAVE2_OFFSET + PLASMA_SLAVE_NUM); +} +inline bool IdIsSlaveBRange2(unsigned int fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE2_OFFSET_RANGE2, PLASMA_SLAVE3_OFFSET_RANGE2); } -int icsneoFindNeoDevices(unsigned long DeviceTypes, NeoDevice* pNeoDevice, int* pNumDevices) { +/** @return 0 for main vnet, 1 for slave1, 2 for slave2 */ +inline EPlasmaIonVnetChannel_t GetVnetPos(size_t fullNetid) +{ + if (IdIsSlaveARange1(fullNetid) || IdIsSlaveARange2(fullNetid)) + { + return PlasmaIonVnetChannelA; + } + + if (IdIsSlaveBRange1(fullNetid) || IdIsSlaveBRange2(fullNetid)) + { + return PlasmaIonVnetChannelB; + } + return PlasmaIonVnetChannelMain; +} + +inline unsigned int GetVnetNetid(size_t simpleNetId, EPlasmaIonVnetChannel_t vnetSlot) +{ + if (vnetSlot == 0 || vnetSlot > 3) + return simpleNetId; + + return mp_netIDToVnetOffSet[simpleNetId] + vnet_table[vnetSlot]; +} +/** + * So if you are passing in the offset from PLASMA_SLAVE1_OFFSET or + * the offset from PLASMA_SLAVE1_OFFSET2, return the vnet agnostic + * netid so caller can commonize handlers without caring about WHICH slave. + */ +inline unsigned int OffsetToSimpleNetworkId(size_t offset) +{ + for (auto &it : mp_netIDToVnetOffSet) + { + if (it.second == offset) + return it.first; + } + return 0; //NETID_DEVICE +} + +inline unsigned int GetVnetAgnosticNetid(size_t fullNetid) +{ + if (IdIsSlaveARange1(fullNetid)) + { + unsigned int off = fullNetid - PLASMA_SLAVE1_OFFSET; + return OffsetToSimpleNetworkId(off); + } + else if (IdIsSlaveARange2(fullNetid)) + { + return fullNetid - PLASMA_SLAVE1_OFFSET_RANGE2; + } + else if (IdIsSlaveBRange1(fullNetid)) + { + unsigned int off = fullNetid - PLASMA_SLAVE2_OFFSET; + return OffsetToSimpleNetworkId(off); + } + else if (IdIsSlaveBRange2(fullNetid)) + { + return fullNetid - PLASMA_SLAVE2_OFFSET_RANGE2; + } + return fullNetid; +} + +/** + * So if you are passing in a simple net id such as NETID_LIN4, + * return the offset that we can add to PLASMA_SLAVE1_OFFSET or + * PLASMA_SLAVE2_OFFSET to compute the corresponding slave netids. + */ +inline bool NetworkIdToVnetOffset_Range1(size_t simpleNetId, size_t& offset) +{ + switch (simpleNetId) + { + case NETID_DEVICE: + offset = 0; + break; + case NETID_HSCAN: + offset = 1; + break; + case NETID_MSCAN: + offset = 2; + break; + case NETID_SWCAN: + offset = 3; + break; + case NETID_LSFTCAN: + offset = 4; + break; + case NETID_FORDSCP: + offset = 5; + break; + case NETID_J1708: + offset = 6; + break; + case NETID_AUX: + offset = 7; + break; + case NETID_JVPW: + offset = 8; + break; + case NETID_ISO: + offset = 9; + break; + case NETID_ISOPIC: + offset = 10; + break; + case NETID_MAIN51: + offset = 11; + break; + case NETID_RED: + offset = 12; + break; + case NETID_SCI: + offset = 13; + break; + case NETID_ISO2: + offset = 14; + break; + case NETID_ISO14230: + offset = 15; + break; + case NETID_LIN: + offset = 16; + break; + case NETID_ISO3: + offset = 17; + break; + case NETID_HSCAN2: + offset = 18; + break; + case NETID_HSCAN3: + offset = 19; + break; + case NETID_ISO4: + offset = 20; + break; + case NETID_LIN2: + offset = 21; + break; + case NETID_LIN3: + offset = 22; + break; + case NETID_LIN4: + offset = 23; + break; + case NETID_MOST: + offset = 24; + break; + case NETID_CGI: + offset = 25; + break; + case NETID_I2C1: + offset = 26; + break; + case NETID_SPI1: + offset = 27; + break; + case NETID_FLEXRAY1A: + offset = 28; + break; + case NETID_MOST25: + offset = 29; + break; + case NETID_MOST50: + offset = 30; + break; + case NETID_MOST150: + offset = 31; + break; + case NETID_HSCAN4: + offset = 32; + break; + case NETID_HSCAN5: + offset = 33; + break; + case NETID_RS232: + offset = 34; + break; + case NETID_UART: + offset = 35; + break; + case NETID_UART2: + offset = 36; + break; + case NETID_UART3: + offset = 37; + break; + case NETID_UART4: + offset = 38; + break; + case NETID_SWCAN2: + offset = 39; + break; + case NETID_FLEXRAY1B: + offset = 40; + break; + case NETID_FLEXRAY2A: + offset = 41; + break; + case NETID_FLEXRAY2B: + offset = 42; + break; + case NETID_LIN5: + offset = 43; + break; + case NETID_ETHERNET: + offset = 44; + break; + case NETID_ETHERNET_DAQ: + offset = 45; + break; + case NETID_RED_APP_ERROR: + offset = 46; + break; + case NETID_HSCAN6: + offset = 47; + break; + case NETID_HSCAN7: + offset = 48; + break; + case NETID_LIN6: + offset = 49; + break; + case NETID_LSFTCAN2: + offset = 50; + break; + default: + /* there is no decoding for the provided id */ + offset = 0; + return false; + } + return true; +} + +inline bool Within(size_t value, size_t min, size_t max) +{ + return ((min <= value) && (value < max)); +} +inline bool IdIsSlaveARange1(size_t fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE1_OFFSET + PLASMA_SLAVE_NUM); +} +inline bool IdIsSlaveARange2(size_t fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE1_OFFSET_RANGE2, PLASMA_SLAVE2_OFFSET_RANGE2); +} +inline bool IdIsSlaveBRange1(size_t fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE2_OFFSET, PLASMA_SLAVE2_OFFSET + PLASMA_SLAVE_NUM); +} +inline bool IdIsSlaveBRange2(unsigned int fullNetid) +{ + return Within(fullNetid, PLASMA_SLAVE2_OFFSET_RANGE2, PLASMA_SLAVE3_OFFSET_RANGE2); +} + +/** @return 0 for main vnet, 1 for slave1, 2 for slave2 */ +inline EPlasmaIonVnetChannel_t GetVnetPos(size_t fullNetid) +{ + if (IdIsSlaveARange1(fullNetid) || IdIsSlaveARange2(fullNetid)) + { + return PlasmaIonVnetChannelA; + } + + if (IdIsSlaveBRange1(fullNetid) || IdIsSlaveBRange2(fullNetid)) + { + return PlasmaIonVnetChannelB; + } + return PlasmaIonVnetChannelMain; +} + +inline unsigned int GetVnetNetid(size_t simpleNetId, EPlasmaIonVnetChannel_t vnetSlot) +{ + if (vnetSlot > 3) + return simpleNetId; + + if (vnetSlot == 0) + return simpleNetId; + + unsigned int offset = 0; + if (NetworkIdToVnetOffset_Range1(simpleNetId, offset)) + { + /* simpleNetId was one of the original networks mapped to slaves */ + unsigned long table[] = { 0, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE2_OFFSET }; + return offset + table[vnetSlot]; + } + else + { + /* simpleNetid has the simpler offset scheme */ + unsigned long table[] = { 0, PLASMA_SLAVE1_OFFSET_RANGE2, PLASMA_SLAVE2_OFFSET_RANGE2 }; + return simpleNetId + table[vnetSlot]; + } +} +/** + * So if you are passing in the offset from PLASMA_SLAVE1_OFFSET or + * the offset from PLASMA_SLAVE1_OFFSET2, return the vnet agnostic + * netid so caller can commonize handlers without caring about WHICH slave. + */ +inline unsigned int OffsetToSimpleNetworkId(size_t offset) +{ + switch (offset) + { + default: + case 0: + return NETID_DEVICE; + case 1: + return NETID_HSCAN; + case 2: + return NETID_MSCAN; + case 3: + return NETID_SWCAN; + case 4: + return NETID_LSFTCAN; + case 5: + return NETID_FORDSCP; + case 6: + return NETID_J1708; + case 7: + return NETID_AUX; + case 8: + return NETID_JVPW; + case 9: + return NETID_ISO; + case 10: + return NETID_ISOPIC; + case 11: + return NETID_MAIN51; + case 12: + return NETID_RED; + case 13: + return NETID_SCI; + case 14: + return NETID_ISO2; + case 15: + return NETID_ISO14230; + case 16: + return NETID_LIN; + case 17: + return NETID_ISO3; + case 18: + return NETID_HSCAN2; + case 19: + return NETID_HSCAN3; + case 20: + return NETID_ISO4; + case 21: + return NETID_LIN2; + case 22: + return NETID_LIN3; + case 23: + return NETID_LIN4; + case 24: + return NETID_MOST; + case 25: + return NETID_CGI; + case 26: + return NETID_I2C1; + case 27: + return NETID_SPI1; + case 28: + return NETID_FLEXRAY1A; + case 29: + return NETID_MOST25; + case 30: + return NETID_MOST50; + case 31: + return NETID_MOST150; + case 32: + return NETID_HSCAN4; + case 33: + return NETID_HSCAN5; + case 34: + return NETID_RS232; + case 35: + return NETID_UART; + case 36: + return NETID_UART2; + case 37: + return NETID_UART3; + case 38: + return NETID_UART4; + case 39: + return NETID_SWCAN2; + case 40: + return NETID_FLEXRAY1B; + case 41: + return NETID_FLEXRAY2A; + case 42: + return NETID_FLEXRAY2B; + case 43: + return NETID_LIN5; + case 44: + return NETID_ETHERNET; + case 45: + return NETID_ETHERNET_DAQ; + case 46: + return NETID_RED_APP_ERROR; + case 47: + return NETID_HSCAN6; + case 48: + return NETID_HSCAN7; + case 49: + return NETID_LIN6; + case 50: + return NETID_LSFTCAN2; + } +} + +inline unsigned int GetVnetAgnosticNetid(size_t fullNetid) +{ + if (IdIsSlaveARange1(fullNetid)) + { + unsigned int off = fullNetid - PLASMA_SLAVE1_OFFSET; + return OffsetToSimpleNetworkId(off); + } + else if (IdIsSlaveARange2(fullNetid)) + { + return fullNetid - PLASMA_SLAVE1_OFFSET_RANGE2; + } + else if (IdIsSlaveBRange1(fullNetid)) + { + unsigned int off = fullNetid - PLASMA_SLAVE2_OFFSET; + return OffsetToSimpleNetworkId(off); + } + else if (IdIsSlaveBRange2(fullNetid)) + { + return fullNetid - PLASMA_SLAVE2_OFFSET_RANGE2; + } + return fullNetid; +} + +//Basic Functions +int LegacyDLLExport icsneoFindDevices(NeoDeviceEx *devs, int *devCount, unsigned int *devTypes, unsigned int devTypeCount, POptionsFindNeoEx *POptionsFindNeoEx, unsigned int *zero) +{ + constexpr size_t MAX_DEVICES = 255; + NeoDevice Nd[MAX_DEVICES]; + int NumDevices = MAX_DEVICES; + + size_t Count = 0; + + icsneoFindNeoDevices(NULL, Nd, &NumDevices); + + if (NumDevices > 0) + { + for (const auto &element : Nd) + for (auto j = 0; j < devTypeCount; j++) + if (element.DeviceType == devTypes[j]) + devs[Count++].neoDevice = element; + + return 1; + } + else + return 0; +} + +int LegacyDLLExport icsneoFindNeoDevices(unsigned long DeviceTypes, NeoDevice *pNeoDevice, int *pNumDevices) +{ constexpr size_t MAX_DEVICES = 255; size_t count = MAX_DEVICES; - if(pNumDevices == nullptr) + if (pNumDevices == nullptr) return 0; - if(pNeoDevice == nullptr) { + if (pNeoDevice == nullptr) + { icsneo_findAllDevices(nullptr, &count); *pNumDevices = (int)count; return 1; } size_t bufferSize = (size_t)*pNumDevices; - if(*pNumDevices < 0 || bufferSize > MAX_DEVICES) + if (*pNumDevices < 0 || bufferSize > MAX_DEVICES) return 0; neodevice_t devices[MAX_DEVICES]; icsneo_findAllDevices(devices, &count); - if(bufferSize < count) + if (bufferSize < count) count = bufferSize; *pNumDevices = (int)count; - for(size_t i = 0; i < count; i++) { - pNeoDevice[i] = OldNeoDeviceFromNew(&devices[i]); // Write out into user memory + for (size_t i = 0; i < count; i++) + { + pNeoDevice[i] = OldNeoDeviceFromNew(&devices[i]); // Write out into user memory neodevices[uint64_t(devices[i].handle) << 32 | icsneo_serialStringToNum(devices[i].serial)] = devices[i]; // Fill the look up table } - + return 1; } -int icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int bSyncToPC) { - if(pNeoDevice == nullptr || hObject == nullptr) +int LegacyDLLExport icsneoOpenNeoDevice(NeoDevice *pNeoDevice, void **hObject, unsigned char *bNetworkIDs, int bConfigRead, int bSyncToPC) +{ + if (pNeoDevice == nullptr || hObject == nullptr) return false; - neodevice_t* device; - try { + neodevice_t *device; + try + { device = &neodevices.at(uint64_t(pNeoDevice->Handle) << 32 | pNeoDevice->SerialNumber); - } catch(std::out_of_range& e) { + } + catch (std::out_of_range &e) + { (void)e; // Unused return false; } *hObject = device; - if(!icsneo_openDevice(device)) + if (!icsneo_openDevice(device)) return false; return icsneo_setPollingMessageLimit(device, 20000) && icsneo_enableMessagePolling(device) && icsneo_goOnline(device); } -int icsneoClosePort(void* hObject, int* pNumberOfErrors) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoClosePort(void *hObject, int *pNumberOfErrors) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; + neodevice_t *device = (neodevice_t *)hObject; return icsneo_closeDevice(device); } // Memory is now managed automatically, this function is unneeded -void icsneoFreeObject(void* hObject) { (void)hObject; return; } +void LegacyDLLExport icsneoFreeObject(void *hObject) +{ + (void)hObject; + return; +} -int icsneoSerialNumberToString(unsigned long serial, char* data, unsigned long data_size) { +int LegacyDLLExport icsneoSerialNumberToString(unsigned long serial, char *data, unsigned long data_size) +{ size_t length = (size_t)data_size; return icsneo_serialNumToString((uint32_t)serial, data, &length); } //Message Functions -int icsneoGetMessages(void* hObject, icsSpyMessage* pMsg, int* pNumberOfMessages, int* pNumberOfErrors) { +int LegacyDLLExport icsneoGetMessages(void *hObject, icsSpyMessage *pMsg, int *pNumberOfMessages, int *pNumberOfErrors) +{ static neomessage_t messages[20000]; - if(!icsneoValidateHObject(hObject)) + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; + neodevice_t *device = (neodevice_t *)hObject; size_t messageCount = 20000; - if(!icsneo_getMessages(device, messages, &messageCount, 0)) + if (!icsneo_getMessages(device, messages, &messageCount, 0)) return false; - + *pNumberOfMessages = (int)messageCount; *pNumberOfErrors = 0; - for(size_t i = 0; i < messageCount; i++) + for (size_t i = 0; i < messageCount; i++) NeoMessageToSpyMessage(device, messages[i], pMsg[i]); return true; } -int icsneoTxMessages(void* hObject, icsSpyMessage* pMsg, int lNetworkID, int lNumMessages) { +int LegacyDLLExport icsneoTxMessages(void *hObject, icsSpyMessage *pMsg, int lNetworkID, int lNumMessages) +{ return icsneoTxMessagesEx(hObject, pMsg, lNetworkID, lNumMessages, nullptr, 0); } -int icsneoTxMessagesEx(void* hObject, icsSpyMessage* pMsg, unsigned int lNetworkID, unsigned int lNumMessages, unsigned int* NumTxed, unsigned int zero2) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoTxMessagesEx(void *hObject, icsSpyMessage *pMsg, unsigned int lNetworkID, unsigned int lNumMessages, unsigned int *NumTxed, unsigned int zero2) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; + neodevice_t *device = (neodevice_t *)hObject; neomessage_t newmsg; unsigned int temp = 0; - if(NumTxed == nullptr) + if (NumTxed == nullptr) NumTxed = &temp; *NumTxed = 0; - for(unsigned int i = 0; i < lNumMessages; i++) { - const icsSpyMessage& oldmsg = pMsg[i]; + for (unsigned int i = 0; i < lNumMessages; i++) + { + const icsSpyMessage &oldmsg = pMsg[i]; newmsg = {}; newmsg.netid = (uint16_t)lNetworkID; newmsg.description = oldmsg.DescriptionID; memcpy(newmsg.header, &oldmsg.ArbIDOrHeader, sizeof(newmsg.header)); - newmsg.length = oldmsg.NumberBytesData | (oldmsg.NodeID << 8); - if (oldmsg.ExtraDataPtr != nullptr) - newmsg.data = reinterpret_cast(oldmsg.ExtraDataPtr); + if (oldmsg.Protocol != SPY_PROTOCOL_ETHERNET) + newmsg.length = oldmsg.NumberBytesData; + else + newmsg.length = ((oldmsg.NumberBytesHeader & 255) << 8) | (oldmsg.NumberBytesData & 255); + if (oldmsg.ExtraDataPtr != nullptr && oldmsg.ExtraDataPtrEnabled == 1) + newmsg.data = reinterpret_cast(oldmsg.ExtraDataPtr); else newmsg.data = oldmsg.Data; newmsg.status.statusBitfield[0] = oldmsg.StatusBitField; newmsg.status.statusBitfield[1] = oldmsg.StatusBitField2; newmsg.status.statusBitfield[2] = oldmsg.StatusBitField3; newmsg.status.statusBitfield[3] = oldmsg.StatusBitField4; - if(oldmsg.Protocol == SPY_PROTOCOL_CANFD) + if (oldmsg.Protocol == SPY_PROTOCOL_CANFD) newmsg.status.canfdFDF = true; - if(icsneo_transmit(device, &newmsg)) + if (icsneo_transmit(device, &newmsg)) (*NumTxed)++; } return lNumMessages == *NumTxed; } -int icsneoEnableNetworkRXQueue(void* hObject, int iEnable) { +int LegacyDLLExport icsneoEnableNetworkRXQueue(void *hObject, int iEnable) +{ // TODO Implement return false; } -int icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeStamp) { +int LegacyDLLExport icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeStamp) { if(!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; @@ -269,150 +734,169 @@ int icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeSt return true; } -void icsneoGetISO15765Status(void* hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus, int*lTxStatus, int*lRxStatus) { +void LegacyDLLExport icsneoGetISO15765Status(void *hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus, int *lTxStatus, int *lRxStatus) +{ // TODO Implement return; } -void icsneoSetISO15765RxParameters(void* hObject, int lNetwork, int lEnable, spyFilterLong* pFF_CFMsgFilter, icsSpyMessage* pTxMsg, - int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent) { +void LegacyDLLExport icsneoSetISO15765RxParameters(void *hObject, int lNetwork, int lEnable, spyFilterLong *pFF_CFMsgFilter, icsSpyMessage *pTxMsg, + int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent) +{ // TODO Implement return; } //Device Functions -int icsneoGetConfiguration(void* hObject, unsigned char* pData, int* lNumBytes) { +int LegacyDLLExport icsneoGetConfiguration(void *hObject, unsigned char *pData, int *lNumBytes) +{ // 2G devices are not supported in the new API return false; } -int icsneoSendConfiguration(void* hObject, unsigned char* pData, int lNumBytes) { +int LegacyDLLExport icsneoSendConfiguration(void *hObject, unsigned char *pData, int lNumBytes) +{ // 2G devices are not supported in the new API return false; } -int icsneoGetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetFireSettings(void *hObject, SFireSettings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetFireSettings(void *hObject, SFireSettings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoGetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetVCAN3Settings(void *hObject, SVCAN3Settings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetVCAN3Settings(void *hObject, SVCAN3Settings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoGetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetFire2Settings(void *hObject, SFire2Settings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetFire2Settings(void *hObject, SFire2Settings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoGetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetVCANRFSettings(void *hObject, SVCANRFSettings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetVCANRFSettings(void *hObject, SVCANRFSettings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoGetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetVCAN412Settings(void *hObject, SVCAN412Settings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetVCAN412Settings(void *hObject, SVCAN412Settings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoGetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetRADGalaxySettings(void *hObject, SRADGalaxySettings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetRADGalaxySettings(void *hObject, SRADGalaxySettings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoGetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetRADStar2Settings(void *hObject, SRADStar2Settings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1); } -int icsneoSetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes, int bSaveToEEPROM) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetRADStar2Settings(void *hObject, SRADStar2Settings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(bSaveToEEPROM) + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); } -int icsneoSetBitRate(void* hObject, int BitRate, int NetworkID) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoSetBitRate(void *hObject, int BitRate, int NetworkID) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; - if(!icsneo_setBaudrate(device, (uint16_t)NetworkID, BitRate)) + neodevice_t *device = (neodevice_t *)hObject; + if (!icsneo_setBaudrate(device, (uint16_t)NetworkID, BitRate)) return false; return icsneo_settingsApply(device); } -int icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID) { +int LegacyDLLExport icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID) { if(!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; @@ -421,169 +905,685 @@ int icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID) { return icsneo_settingsApply(device); } -int icsneoGetDeviceParameters(void* hObject, char* pParameter, char* pValues, short ValuesLength) { +int LegacyDLLExport icsneoGetDeviceParameters(void* hObject, char* pParameter, char* pValues, short ValuesLength) { // TODO Implement return false; } -int icsneoSetDeviceParameters(void* hObject, char* pParmValue, int* pErrorIndex, int bSaveToEEPROM) { +int LegacyDLLExport icsneoSetDeviceParameters(void *hObject, char *pParmValue, int *pErrorIndex, int bSaveToEEPROM) +{ // TODO Implement return false; } //Error Functions -int icsneoGetLastAPIError(void* hObject, unsigned long* pErrorNumber) { +int LegacyDLLExport icsneoGetLastAPIError(void *hObject, unsigned long *pErrorNumber) +{ // TODO Implement return false; } -int icsneoGetErrorMessages(void* hObject, int* pErrorMsgs, int* pNumberOfErrors) { +int LegacyDLLExport icsneoGetErrorMessages(void *hObject, int *pErrorMsgs, int *pNumberOfErrors) +{ // TODO Implement return false; } -int icsneoGetErrorInfo(int lErrorNumber, TCHAR* szErrorDescriptionShort, TCHAR* szErrorDescriptionLong, int* lMaxLengthShort, int* lMaxLengthLong, int* lErrorSeverity, int* lRestartNeeded) { +int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR *szErrorDescriptionShort, TCHAR *szErrorDescriptionLong, int *lMaxLengthShort, int *lMaxLengthLong, int *lErrorSeverity, int *lRestartNeeded) +{ // TODO Implement return false; } //ISO15765-2 Functions -int icsneoISO15765_EnableNetworks(void* hObject, unsigned long ulNetworks) { +int LegacyDLLExport icsneoISO15765_EnableNetworks(void *hObject, unsigned long ulNetworks) +{ // TODO Implement return false; } -int icsneoISO15765_DisableNetworks(void* hObject) { +int LegacyDLLExport icsneoISO15765_DisableNetworks(void *hObject) +{ // TODO Implement return false; } -int icsneoISO15765_TransmitMessage(void* hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage* pMsg, unsigned long ulBlockingTimeout) { +int LegacyDLLExport icsneoISO15765_TransmitMessage(void *hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage *pMsg, unsigned long ulBlockingTimeout) +{ // TODO Implement return false; } -int icsneoISO15765_ReceiveMessage(void* hObject, int ulNetworkID, stCM_ISO157652_RxMessage* pMsg) { +int LegacyDLLExport icsneoISO15765_ReceiveMessage(void *hObject, int ulNetworkID, stCM_ISO157652_RxMessage *pMsg) +{ // TODO Implement return false; } //General Utility Functions -int icsneoValidateHObject(void* hObject) { - for(auto it = neodevices.begin(); it != neodevices.end(); it++) { - if(&it->second == hObject) { - neodevice_t* device = (neodevice_t*)hObject; - if(icsneo_isValidNeoDevice(device)) +int LegacyDLLExport icsneoValidateHObject(void *hObject) +{ + for (auto it = neodevices.begin(); it != neodevices.end(); it++) + { + if (&it->second == hObject) + { + neodevice_t *device = (neodevice_t *)hObject; + if (icsneo_isValidNeoDevice(device)) return true; } } - + return false; } -int icsneoGetDLLVersion(void) { +int LegacyDLLExport icsneoGetDLLVersion(void) +{ return 804; } -int icsneoGetSerialNumber(void* hObject, unsigned int*iSerialNumber) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoGetSerialNumber(void *hObject, unsigned int *iSerialNumber) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; + neodevice_t *device = (neodevice_t *)hObject; *iSerialNumber = icsneo_serialStringToNum(device->serial); return true; } -int icsneoEnableDOIPLine(void* hObject, bool enable) { +int LegacyDLLExport icsneoEnableDOIPLine(void* hObject, bool enable) { if(!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return icsneo_setDigitalIO(device, ICSNEO_IO_ETH_ACTIVATION, 1, enable); } -int icsneoStartSockServer(void* hObject, int iPort) { +int LegacyDLLExport icsneoStartSockServer(void* hObject, int iPort) { // TODO Implement return false; } -int icsneoStopSockServer(void* hObject) { +int LegacyDLLExport icsneoStopSockServer(void *hObject) +{ // TODO Implement return false; } //CoreMini Script functions -int icsneoScriptStart(void* hObject, int iLocation) { +int LegacyDLLExport icsneoScriptStart(void *hObject, int iLocation) +{ // TODO Implement return false; } -int icsneoScriptStop(void* hObject) { +int LegacyDLLExport icsneoScriptStop(void *hObject) +{ // TODO Implement return false; } -int icsneoScriptLoad(void* hObject, const unsigned char* bin, unsigned long len_bytes, int iLocation) { +int LegacyDLLExport icsneoScriptLoad(void *hObject, const unsigned char *bin, unsigned long len_bytes, int iLocation) +{ // TODO Implement return false; } -int icsneoScriptClear(void* hObject, int iLocation) { +int LegacyDLLExport icsneoScriptClear(void *hObject, int iLocation) +{ // TODO Implement return false; } -int icsneoScriptStartFBlock(void* hObject,unsigned int fb_index) { +int LegacyDLLExport icsneoScriptStartFBlock(void *hObject, unsigned int fb_index) +{ // TODO Implement return false; } -int icsneoScriptGetFBlockStatus(void* hObject, unsigned int fb_index, int* piRunStatus) { +int LegacyDLLExport icsneoScriptGetFBlockStatus(void *hObject, unsigned int fb_index, int *piRunStatus) +{ // TODO Implement return false; } -int icsneoScriptStopFBlock(void* hObject,unsigned int fb_index) { +int LegacyDLLExport icsneoScriptStopFBlock(void *hObject, unsigned int fb_index) +{ // TODO Implement return false; } -int icsneoScriptGetScriptStatus(void* hObject, int* piStatus) { +int LegacyDLLExport icsneoScriptGetScriptStatus(void *hObject, int *piStatus) +{ // TODO Implement return false; } -int icsneoScriptReadAppSignal(void* hObject, unsigned int iIndex, double*dValue) { +int LegacyDLLExport icsneoScriptReadAppSignal(void *hObject, unsigned int iIndex, double *dValue) +{ // TODO Implement return false; } -int icsneoScriptWriteAppSignal(void* hObject, unsigned int iIndex, double dValue) { +int LegacyDLLExport icsneoScriptWriteAppSignal(void *hObject, unsigned int iIndex, double dValue) +{ // TODO Implement return false; } //Deprecated (but still suppored in the DLL) -int icsneoOpenPortEx(void* lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char* bNetworkID, int* hObject) { +int LegacyDLLExport icsneoOpenPortEx(void *lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char *bNetworkID, int *hObject) +{ // TODO Implement return false; } -int icsneoOpenPort(int lPortNumber, int lPortType, int lDriverType, unsigned char* bNetworkID, unsigned char* bSCPIDs, int* hObject) { +int LegacyDLLExport icsneoOpenPort(int lPortNumber, int lPortType, int lDriverType, unsigned char *bNetworkID, unsigned char *bSCPIDs, int *hObject) +{ // TODO Implement return false; } -int icsneoEnableNetworkCom(void* hObject, int Enable) { - if(!icsneoValidateHObject(hObject)) +int LegacyDLLExport icsneoEnableNetworkCom(void *hObject, int Enable) +{ + if (!icsneoValidateHObject(hObject)) return false; - neodevice_t* device = (neodevice_t*)hObject; + neodevice_t *device = (neodevice_t *)hObject; - if(Enable) + if (Enable) return icsneo_goOnline(device); else return icsneo_goOffline(device); } -int icsneoFindAllCOMDevices(int lDriverType, int lGetSerialNumbers, int lStopAtFirst, int lUSBCommOnly, int* p_lDeviceTypes, int* p_lComPorts, int* p_lSerialNumbers, int*lNumDevices) { +int LegacyDLLExport icsneoFindAllCOMDevices(int lDriverType, int lGetSerialNumbers, int lStopAtFirst, int lUSBCommOnly, int *p_lDeviceTypes, int *p_lComPorts, int *p_lSerialNumbers, int *lNumDevices) +{ // TODO Implement return false; } + +int LegacyDLLExport icsneoOpenNeoDeviceByChannels(NeoDevice *pNeoDevice, void **hObject, unsigned char *uChannels, int iSize, int bConfigRead, int iOptions) +{ + // TODO Implement + return false; +} + +int LegacyDLLExport icsneoOpenDevice(NeoDeviceEx *pNeoDeviceEx, + void **hObject, + unsigned char *bNetworkIDs, + int bConfigRead, + int iOptions, + OptionsOpenNeoEx *stOptionsOpenNeoEx, + unsigned long reserved) +{ + if (pNeoDeviceEx == nullptr || hObject == nullptr) + return false; + + neodevice_t *device; + try + { + device = &neodevices.at(uint64_t(pNeoDeviceEx->neoDevice.Handle) << 32 | pNeoDeviceEx->neoDevice.SerialNumber); + } + catch (std::out_of_range &e) + { + (void)e; // Unused + return false; + } + + *hObject = device; + if (!icsneo_openDevice(device)) + return false; + + icsneo_setPollingMessageLimit(device, 20000); + icsneo_enableMessagePolling(device); + return icsneo_goOnline(device); +} + +int LegacyDLLExport icsneoGetVCAN4Settings(void *hObject, SVCAN4Settings *pSettings, int iNumBytes) +{ + if (!icsneoValidateHObject(hObject)) + return false; + neodevice_t *device = (neodevice_t *)hObject; + return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes); +} + +int LegacyDLLExport icsneoSetVCAN4Settings(void *hObject, SVCAN4Settings *pSettings, int iNumBytes, int bSaveToEEPROM) +{ + if (!icsneoValidateHObject(hObject)) + return false; + neodevice_t *device = (neodevice_t *)hObject; + if (bSaveToEEPROM) + return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); + return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); +} + +int LegacyDLLExport icsneoGetDeviceSettingsType(void *hObject, EPlasmaIonVnetChannel_t vnetSlot, EDeviceSettingsType *pDeviceSettingsType) +{ + if (!icsneoValidateHObject(hObject)) + return false; + + neodevice_t *device = (neodevice_t *)hObject; + + unsigned long ulDeviceType = device->type; + + if (pDeviceSettingsType == nullptr) + return 0; + + if ((PlasmaIonVnetChannelMain != vnetSlot) && (ulDeviceType != NEODEVICE_PLASMA) && (ulDeviceType != NEODEVICE_ION)) + { + return 0; + } + + switch (ulDeviceType) + { + case NEODEVICE_PLASMA: + case NEODEVICE_ION: + *pDeviceSettingsType = DeviceFire2SettingsType; //defaults to FIRE2 vnets with libicsneo - no firevnets! + break; + case NEODEVICE_VCAN3: + *pDeviceSettingsType = DeviceVCAN3SettingsType; + break; + case NEODEVICE_FIRE: + *pDeviceSettingsType = DeviceFireSettingsType; + break; + case NEODEVICE_FIRE2: + *pDeviceSettingsType = DeviceFire2SettingsType; + break; + case NEODEVICE_RADGALAXY: + *pDeviceSettingsType = DeviceRADGalaxySettingsType; + break; + case NEODEVICE_RADSTAR2: + *pDeviceSettingsType = DeviceRADStar2SettingsType; + break; + case NEODEVICE_VCAN44: + case NEODEVICE_VCAN42_EL: + *pDeviceSettingsType = DeviceVCAN4SettingsType; + break; + case NEODEVICE_VCAN41: + case NEODEVICE_VCAN42: + *pDeviceSettingsType = DeviceVCAN412SettingsType; + break; + case NEODEVICE_VIVIDCAN: + *pDeviceSettingsType = DeviceVividCANSettingsType; + break; + case NEODEVICE_ECU_AVB: + *pDeviceSettingsType = DeviceECU_AVBSettingsType; + break; + case NEODEVICE_RADSUPERMOON: + *pDeviceSettingsType = DeviceRADSuperMoonSettingsType; + break; + case NEODEVICE_RADMOON2: + *pDeviceSettingsType = DeviceRADMoon2SettingsType; + break; + case NEODEVICE_RADGIGALOG: + *pDeviceSettingsType = DeviceRADGigalogSettingsType; + break; + default: + return 0; + } + + return 1; +} + +int LegacyDLLExport icsneoSetDeviceSettings(void *hObject, SDeviceSettings *pSettings, int iNumBytes, int bSaveToEEPROM, EPlasmaIonVnetChannel_t vnetSlot) +{ + if (!icsneoValidateHObject(hObject)) + return false; + + neodevice_t *device = (neodevice_t *)hObject; + + if (bSaveToEEPROM) + return icsneo_settingsApplyStructure(device, pSettings, iNumBytes); + + return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes); +} + +int LegacyDLLExport icsneoGetDeviceSettings(void *hObject, SDeviceSettings *pSettings, int iNumBytes, EPlasmaIonVnetChannel_t vnetSlot) +{ + if (!icsneoValidateHObject(hObject)) + return false; + + neodevice_t *device = (neodevice_t *)hObject; + + return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes); +} + +int LegacyDLLExport icsneoSetBitRateEx(void *hObject, unsigned long BitRate, int NetworkID, int iOptions) +{ + if (!icsneoValidateHObject(hObject)) + return false; + neodevice_t *device = (neodevice_t *)hObject; + if (!icsneo_setBaudrate(device, (uint16_t)NetworkID, BitRate)) + return false; + + bool bSaveToEEPROM = iOptions & 0x1; + + if (bSaveToEEPROM) + return icsneo_settingsApply(device); + else + return icsneo_settingsApplyTemporary(device); +} + +int LegacyDLLExport icsneoEnableNetworkComEx(void *hObject, int iEnable, int iNetId) +{ + return icsneoEnableNetworkCom(hObject, iEnable); +} + +int LegacyDLLExport icsneoForceFirmwareUpdate(void *hObject) +{ + return false; +} + +int LegacyDLLExport icsneoGetHWFirmwareInfo(void *hObject, stAPIFirmwareInfo *pInfo) +{ + return false; +} + +int LegacyDLLExport icsneoSetUSBLatency(NeoDevice *pNeoDevice, unsigned long LatencyVal) +{ + return false; +} + +/** + * @fn unsigned int _stdcall icsneoGetCANControllerClockFrequency(int hObject, + * int lNetworkID) + * + * @brief Gets the CAN Controller clock frequency of a specified CAN + * network. For most cases this is 20Mhz (40 MIPS/2). The clock frequency + * is dependent on the network and product. This function is necessary when + * computing the time quanta parameters of a CAN network, specifically the + * Bit Rate Prescaler (BRP). As a general rule if you are using + * icsneoSetCANParameters then you should also be calling this function. + * + * @param hObject Handle to Hardware, see OpenNeoDevice. + * @param lNetworkID The CAN network to retrieve Clock period from. + * + * @return Clock Period of specified CAN Controller, or 0 if input + * parameters are invalid. + */ +unsigned int LegacyDLLExport icsneoGetCANControllerClockFrequency(void* hObject, int lNetworkID) +{ + return false; +} + +/** +* @fn int _stdcall icsneoSetCANParameters(int hObject, +* unsigned int baudRatePrescaler, unsigned int propagationTqs, +* unsigned int phase1Tqs, unsigned int phase2Tqs, +* unsigned int syncJumpWidthTqs, unsigned int optionBits, int lNetworkID) +* +* @brief Sets the timing parameters of a specific CAN network. +* +* @param hObject Handle to Hardware, see OpenNeoDevice. +* @param baudRatePrescaler The baud rate prescaler[1-63]. Zero is +* invalid. +* @param propagationTqs The propagation delay in time quantas. +* @param phase1Tqs The phase 1 segment in time quantas. +* @param phase2Tqs The phase 2 segment in time quantas. +* @param syncJumpWidthTqs The synchronisation jump width in time +* quantas. +* @param optionBits Reserved, set to zero. +* @param lNetworkID The CAN network to retrieve Clock period +* from. +* +* @return 1 iff successful, 0 otherwise. +*/ +int LegacyDLLExport icsneoSetCANParameters(void* hObject, + unsigned int baudRatePrescaler, + unsigned int propagationTqs, + unsigned int phase1Tqs, + unsigned int phase2Tqs, + unsigned int syncJumpWidthTqs, + unsigned int optionBits, + int lNetworkID) +{ + return false; +} + +int LegacyDLLExport icsneoSetCANParametersPhilipsSJA1000(void* hObject, + unsigned int btr0, + unsigned int btr1, + unsigned int optionBits, + int lNetworkID) +{ + return false; +} + +int LegacyDLLExport icsneoEnableBitSmash(void *hObject, + int netId, + unsigned int numWaitBits, + unsigned int numSmashBits, + unsigned int numFrames, + unsigned int timeout_ms, + unsigned int optionBits, + unsigned int numArbIds, + unsigned int arbIds[MAX_BIT_SMASH_ARBIDS]) +{ + return false; +} + +int LegacyDLLExport icsneoDisableBitSmash(void *hObject, unsigned int reservedZero) +{ + return false; +} + +int LegacyDLLExport icsneoSendHWTimeRequest(void *hObject) +{ + return false; +} + +int LegacyDLLExport icsneoReceiveHWTimeResponse(void *hObject, double *TimeHardware, unsigned long TimeOut) +{ + return false; +} + +int LegacyDLLExport icsneoGetDLLFirmwareInfo(void *hObject, stAPIFirmwareInfo *pInfo) +{ + return false; +} + +int LegacyDLLExport icsneoGetDLLFirmwareInfoEx(void *hObject, stAPIFirmwareInfo *pInfo, EPlasmaIonVnetChannel_t vnetSlot) +{ + return false; +} + +int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short Len, void *pVoid) +{ + bool bCurrentSetting, bHSSWCANRate, bRetVal, bTermination, bFormat; + unsigned long *pTmp, Baud; + int iRetVal = 0, NetworkID; + ISO9141NetworkParms* pISOParms; + EPlasmaIonVnetChannel_t pos; + + unsigned long *pTmp, Baud; + + int iRetVal = 0, NetworkID; + + ISO9141NetworkParms* pISOParms; + + if (!icsneoValidateHObject(hObject)) + return false; + + neodevice_t *device = (neodevice_t *)hObject; + + switch (*CmdBuf) + { + case J2534NVCMD_SetNetworkBaudRate: + + pTmp = (uint64_t *)&CmdBuf[1]; + NetworkID = (uint16_t)*pTmp; + pTmp = (uint64_t *)&CmdBuf[5]; + + if (!icsneo_setBaudrate(device, NetworkID, *pTmp) && !icsneo_settingsApply(device)) + iRetVal = 0; + break; + + case J2534NVCMD_GetNetworkBaudRate: + + double dBaud; + pTmp = (uint64_t *)&CmdBuf[1]; + NetworkID = (uint16_t)*pTmp; + pTmp = (uint64_t *)&CmdBuf[5]; + + //Ignoring 2G hardwares here - CmdBuf[9] + *pTmp = icsneo_getBaudrate(device, NetworkID); + break; + + case J2534NVCMD_SetCANFDRate: + + pTmp = (uint64_t *)&CmdBuf[1]; + NetworkID = (uint16_t)*pTmp; + pTmp = (uint64_t *)&CmdBuf[5]; + + //Ignoring 2G hardwares here - CmdBuf[9] + if (!icsneo_setFDBaudrate(device, NetworkID, *pTmp) && !icsneo_settingsApply(device)) + iRetVal = 0; + break; + + case J2534NVCMD_GetCANFDRate: + + pTmp = (uint64_t *)&CmdBuf[1]; + NetworkID = (uint16_t)*pTmp; + pTmp = (uint64_t *)&CmdBuf[5]; + + //Ignoring 2G hardwares here - CmdBuf[9] + *pTmp = icsneo_getFDBaudrate(device, NetworkID); + break; + + case J2534NVCMD_GetCANFDTermination: + + pTmp = (uint64_t *)&CmdBuf[1]; + NetworkID = (uint16_t)*pTmp; + pTmp = (uint64_t *)&CmdBuf[5]; + + pos = GetVnetPos(NetworkID); + switch (device->type) + { + case NEODEVICE_FIRE2: + case NEODEVICE_PLASMA: //FIRE2 VNETS + case NEODEVICE_ION: //FIRE2 VNETS + SFire2Settings Cs; + iNumBytes = sizeof(Cs); + if (!!icsneoGetFire2Settings(hObject, &Cs, iNumBytes)) + (Cs.termination_enables & (1ull << mp_HWnetIDToCMnetID[GetVnetAgnosticNetid(NetworkID)])) ? *pTmp = 3 /*Termination ON*/ : *pTmp = 0 /*Termination OFF*/; + else + iRetVal = 0; + break; + } + break; + + case J2534NVCMD_SetCANFDTermination: + + pTmp = (uint64_t *)&CmdBuf[1]; + NetworkID = (uint16_t)*pTmp; + pTmp = (uint64_t *)&CmdBuf[5]; + + pos = GetVnetPos(NetworkID); + switch (device->type) + { + case NEODEVICE_FIRE2: + case NEODEVICE_PLASMA: + case NEODEVICE_ION: + SFire2Settings Cs; + iNumBytes = sizeof(Cs); + if (icsneoGetFire2Settings(hObject, &Cs, iNumBytes)) + { + unsigned long long CoremininetID = mp_HWnetIDToCMnetID[GetVnetAgnosticNetid(NetworkID)]; + + if (*pTmp == 3) /*Termination ON*/ + Cs.termination_enables |= (1ull << CoremininetID); + else /*Termination OFF*/ + Cs.termination_enables &= ~(1ull << CoremininetID); + + iRetVal = icsneoSetFire2Settings(hObject, &Cs, iNumBytes, ConfigurationOptionDoNotSaveToEEPROM); + } + break; + } + break; + + default: + break; + } + return iRetVal; +} + +int LegacyDLLExport icsneoSendRawCmds(void *hObject, icsneoVICommand *pCmdMsgs, int lNumOfCmds) +{ + return false; +} + +int LegacyDLLExport icsneoEnableBusVoltageMonitor(void *hObject, unsigned int enable, unsigned int reserved) +{ + return false; +} + +int LegacyDLLExport icsneoISO15765_TransmitMessageEx(void *hObject, + unsigned long ulNetworkID, + ISO15765_2015_TxMessage *pMsg, + unsigned long ulBlockingTimeout) +{ + return false; +} + +int LegacyDLLExport icsneoGetBusVoltage(void *hObject, unsigned long *pVBusVoltage, unsigned int reserved) +{ + return false; +} + +int LegacyDLLExport icsneoOpenRemoteNeoDevice(const char *pIPAddress, + NeoDevice *pNeoDevice, + void **hObject, + unsigned char *bNetworkIDs, + int iOptions) +{ + return false; +} + +int LegacyDLLExport icsneoFindRemoteNeoDevices(const char *pIPAddress, NeoDevice *pNeoDevice, int *pNumDevices) +{ + return false; +} + +int LegacyDLLExport icsneoFirmwareUpdateRequired(void *hObject) +{ + return false; +} + +int LegacyDLLExport icsneoSetFDBitRate(void *hObject, int BitRate, int NetworkID) +{ + neodevice_t *device = (neodevice_t *)hObject; + if (!icsneo_setFDBaudrate(device, (uint16_t)NetworkID, BitRate)) + return false; + return icsneo_settingsApply(device); +} + +void LegacyDLLExport icsneoGetDLLVersionEx(unsigned long *dwMSVersion, unsigned long *dwLSVersion) +{ + return; +} + +int LegacyDLLExport icsneoGetNetidforSlaveVNETs(size_t *NetworkIndex, EPlasmaIonVnetChannel_t vnetSlot) +{ + return GetVnetNetid(*NetworkIndex, vnetSlot); +} + +int LegacyDLLExport icsneoGetVnetSimpleNetid(size_t *FullNetID) +{ + return GetVnetAgnosticNetid(*FullNetID); +} + +int LegacyDLLExport icsneoSerialNumberFromString(unsigned long *serial, char *data) +{ + if (serial == nullptr) + return false; + + *serial = icsneo_serialStringToNum(data); + return false; +} + +int LegacyDLLExport icsneoEnableDOIPLine(void *hObject, bool bActivate) +{ + return false; +} +int LegacyDLLExport icsneoGetMiniportAdapterInfo(void *hObject, NETWORK_ADAPTER_INFO *aInfo) +{ + return false; +} diff --git a/api/icsneolegacy/icsneolegacyextra.cpp b/api/icsneolegacy/icsneolegacyextra.cpp index ffff4d2..0c33b29 100644 --- a/api/icsneolegacy/icsneolegacyextra.cpp +++ b/api/icsneolegacy/icsneolegacyextra.cpp @@ -14,11 +14,11 @@ using namespace icsneo; extern "C" { -extern int DLLExport icsneoValidateHObject(void* hObject); -extern int DLLExport icsneoWaitForRxMessagesWithTimeOut(void* hObject, unsigned int iTimeOut); +extern int LegacyDLLExport icsneoValidateHObject(void* hObject); +extern int LegacyDLLExport icsneoWaitForRxMessagesWithTimeOut(void* hObject, unsigned int iTimeOut); } -int icsneoWaitForRxMessagesWithTimeOut(void* hObject, unsigned int iTimeOut) { +int LegacyDLLExport icsneoWaitForRxMessagesWithTimeOut(void* hObject, unsigned int iTimeOut) { if(!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; diff --git a/include/icsneo/J2534.h b/include/icsneo/J2534.h new file mode 100644 index 0000000..e225dfe --- /dev/null +++ b/include/icsneo/J2534.h @@ -0,0 +1,33 @@ +#ifndef _J2534_H +#define _J2534_H + +//J2534 Commands +#define J1534_NUM_PERIOD_TX_MSGS 128 +#define J1534_NUM_PERIOD_RX_MSGS 128 +#define J2534NVCMD_SetISJ2534 0 +#define J2534NVCMD_SetISO5Baud 1 +#define J2534NVCMD_SetISOFastInit 2 +#define J2534NVCMD_SetISOCheckSum 3 +#define J2534NVCMD_SetISO9141Parms 4 +#define J2534NVCMD_GetISO9141Parms 5 +#define J2534NVCMD_ISO9141APIChkSum 6 +#define J2534NVCMD_SetNetworkBaudRate 7 +#define J2534NVCMD_GetNetworkBaudRate 8 +#define J2534NVCMD_EnableTransmitEvent 9 +#define J2534NVCMD_SetTransmitEvent 10 +#define J2534NVCMD_BlueEnableStopFilters 11 +#define J2534NVCMD_Blue15765HWSupport 12 +#define J2534NVCMD_GetTXBufferInfo 13 +#define J2534NVCMD_GetEncryptionKey 14 +#define J2534NVCMD_SetMiscIOForVBATT 15 +#define J2534NVCMD_EnableISO_KW_Network 16 +#define J2534NVCMD_SetJ1708CheckSum 17 +#define J2534NVCMD_GetTimestamp 18 +#define J2534NVCMD_GetCANFDRate 19 +#define J2534NVCMD_SetCANFDRate 20 +#define J2534NVCMD_GetCANFDTermination 21 +#define J2534NVCMD_SetCANFDTermination 22 +#define J2534NVCMD_GetCANFDFormat 23 +#define J2534NVCMD_SetCANFDFormat 24 + +#endif diff --git a/include/icsneo/communication/command.h b/include/icsneo/communication/command.h index 62599b2..e053062 100644 --- a/include/icsneo/communication/command.h +++ b/include/icsneo/communication/command.h @@ -18,6 +18,9 @@ enum class Command : uint8_t { GetSecondaryVersions = 0xA9, // Previously known as RED_CMD_PERIPHERALS_APP_VERSION_REQ, versions other than the main chip RequestStatusUpdate = 0xBC, ReadSettings = 0xC7, // Previously known as 3G_READ_SETTINGS_EX + SetVBattMonitor = 0xDB, // Previously known as RED_CMD_CM_VBATT_MONITOR + RequestBitSmash = 0xDC, // Previously known as RED_CMD_CM_BITSMASH + GetVBattReq = 0xDF, // Previously known as RED_CMD_VBATT_REQUEST MiscControl = 0xE7, FlexRayControl = 0xF3 }; diff --git a/include/icsneo/icsnVC40.h b/include/icsneo/icsnVC40.h index 49de417..97416d6 100644 --- a/include/icsneo/icsnVC40.h +++ b/include/icsneo/icsnVC40.h @@ -1965,6 +1965,7 @@ typedef enum _EDeviceSettingsType DeviceECU_AVBSettingsType, DeviceRADSuperMoonSettingsType, DeviceRADMoon2SettingsType, + DeviceRADGigalogSettingsType, // // add new settings type here // ... @@ -2421,6 +2422,17 @@ typedef union { icsFire2DeviceStatus fire2Status; icsVcan4DeviceStatus vcan4Status; } icsDeviceStatus; + +typedef struct +{ + int8_t szName[128]; //Adaptor name - ASCII Null terminated + int8_t szDeviceName[64]; //Device name - ASCII Null terminated + uint32_t Status; //Adaptor Status, 0 for disabled, 1 for enabled + uint8_t bMAC_Address[6]; // The Media Access Control (MAC) Address of the Network interface in the PC that is to be connected to the vehicle. + uint8_t bIPV6_Address[16]; //The Ipv6 address assigned to the Network interface. No compressed or short form notation// If not available, all bytes are set to zero to imply the absence of an address. + uint8_t bIPV4_Address[4]; // The Ipv4 address assigned to the Network interface. If not available, all bytes are set to zero. +} NETWORK_ADAPTER_INFO; + #ifndef INTREPID_NO_CHECK_STRUCT_SIZE #if defined(__cplusplus) && (__cplusplus > 199711L) diff --git a/include/icsneo/icsneolegacy.h b/include/icsneo/icsneolegacy.h index 7503059..78af46b 100644 --- a/include/icsneo/icsneolegacy.h +++ b/include/icsneo/icsneolegacy.h @@ -8,93 +8,158 @@ typedef uint8_t byte; // Typedef helper for the following include #include "icsneo/icsnVC40.h" // Definitions for structs +// From coremini.h +#define MAX_BIT_SMASH_ARBIDS (4) +#define BIT_SMASH_OPTION_EXTENDED (1) +#define BIT_SMASH_OPTION_REMOTE (2) +#define BIT_SMASH_OPTION_BUSTEST (4) +#define BIT_SMASH_OPTION_WHITELIST (8) + #ifdef __cplusplus extern "C" { #endif //Basic Functions -extern int DLLExport icsneoFindDevices(NeoDeviceEx* pNeoDeviceEx, int* pNumDevices, unsigned int* DeviceTypes, unsigned int numDeviceTypes,POptionsFindNeoEx* pOptionsNeoEx, unsigned int* reserved); -extern int DLLExport icsneoFindNeoDevices(unsigned long DeviceTypes, NeoDevice* pNeoDevice, int* pNumDevices); -extern int DLLExport icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int bSyncToPC); -extern int DLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors); -extern void DLLExport icsneoFreeObject(void* hObject); -extern int DLLExport icsneoSerialNumberToString(unsigned long serial, char* data, unsigned long data_size); +extern int LegacyDLLExport icsneoFindDevices(NeoDeviceEx* pNeoDeviceEx, int* pNumDevices, unsigned int* DeviceTypes, unsigned int numDeviceTypes,POptionsFindNeoEx* pOptionsNeoEx, unsigned int* reserved); +extern int LegacyDLLExport icsneoFindNeoDevices(unsigned long DeviceTypes, NeoDevice* pNeoDevice, int* pNumDevices); +extern int LegacyDLLExport icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int bSyncToPC); +extern int LegacyDLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors); +extern void LegacyDLLExport icsneoFreeObject(void* hObject); +extern int LegacyDLLExport icsneoOpenDevice(NeoDeviceEx* pNeoDeviceEx, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int iOptions, OptionsOpenNeoEx* stOptionsOpenNeoEx, unsigned long reserved); //Message Functions -extern int DLLExport icsneoGetMessages(void* hObject, icsSpyMessage* pMsg, int* pNumberOfMessages, int* pNumberOfErrors); -extern int DLLExport icsneoTxMessages(void* hObject, icsSpyMessage* pMsg, int lNetworkID, int lNumMessages); -extern int DLLExport icsneoTxMessagesEx(void* hObject,icsSpyMessage* pMsg, unsigned int lNetworkID, unsigned int lNumMessages, unsigned int* NumTxed, unsigned int zero2); -extern int DLLExport icsneoWaitForRxMessagesWithTimeOut(void* hObject, unsigned int iTimeOut); -extern int DLLExport icsneoEnableNetworkRXQueue(void* hObject, int iEnable); -extern int DLLExport icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeStamp); -extern void DLLExport icsneoGetISO15765Status(void* hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus, int*lTxStatus, int*lRxStatus); -extern void DLLExport icsneoSetISO15765RxParameters(void* hObject, int lNetwork, int lEnable, spyFilterLong* pFF_CFMsgFilter, icsSpyMessage* pTxMsg, +extern int LegacyDLLExport icsneoGetMessages(void* hObject, icsSpyMessage* pMsg, int* pNumberOfMessages, int* pNumberOfErrors); +extern int LegacyDLLExport icsneoTxMessages(void* hObject, icsSpyMessage* pMsg, int lNetworkID, int lNumMessages); +extern int LegacyDLLExport icsneoTxMessagesEx(void* hObject,icsSpyMessage* pMsg, unsigned int lNetworkID, unsigned int lNumMessages, unsigned int* NumTxed, unsigned int zero2); +extern int LegacyDLLExport icsneoWaitForRxMessagesWithTimeOut(void* hObject, unsigned int iTimeOut); +extern int LegacyDLLExport icsneoEnableNetworkRXQueue(void* hObject, int iEnable); +extern int LegacyDLLExport icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeStamp); +extern void LegacyDLLExport icsneoGetISO15765Status(void* hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus, int*lTxStatus, int*lRxStatus); +extern void LegacyDLLExport icsneoSetISO15765RxParameters(void* hObject, int lNetwork, int lEnable, spyFilterLong* pFF_CFMsgFilter, icsSpyMessage* pTxMsg, int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent); //Device Functions -extern int DLLExport icsneoGetConfiguration(void* hObject, unsigned char* pData, int* lNumBytes); -extern int DLLExport icsneoSendConfiguration(void* hObject, unsigned char* pData, int lNumBytes); -extern int DLLExport icsneoGetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetConfiguration(void* hObject, unsigned char* pData, int* lNumBytes); +extern int LegacyDLLExport icsneoSendConfiguration(void* hObject, unsigned char* pData, int lNumBytes); +extern int LegacyDLLExport icsneoGetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoGetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoGetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoGetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoGetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoGetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoGetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes); -extern int DLLExport icsneoSetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoGetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes, int bSaveToEEPROM); -extern int DLLExport icsneoSetBitRate(void* hObject, int BitRate, int NetworkID); -extern int DLLExport icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID); -extern int DLLExport icsneoGetDeviceParameters(void* hObject, char* pParameter, char* pValues, short ValuesLength); -extern int DLLExport icsneoSetDeviceParameters(void* hObject, char* pParmValue, int* pErrorIndex, int bSaveToEEPROM); +extern int LegacyDLLExport icsneoSetBitRate(void* hObject, int BitRate, int NetworkID); +extern int LegacyDLLExport icsneoSetBitRateEx(void* hObject, unsigned long BitRate, int NetworkID, int iOptions); +extern int LegacyDLLExport icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID); + +extern int LegacyDLLExport icsneoGetDeviceParameters(void* hObject, char* pParameter, char* pValues, short ValuesLength); +extern int LegacyDLLExport icsneoSetDeviceParameters(void* hObject, char* pParmValue, int* pErrorIndex, int bSaveToEEPROM); + +extern int LegacyDLLExport icsneoGetVCAN4Settings(void* hObject, SVCAN4Settings* pSettings, int iNumBytes); +extern int LegacyDLLExport icsneoSetVCAN4Settings(void* hObject, SVCAN4Settings* pSettings, int iNumBytes, int bSaveToEEPROM); + +extern int LegacyDLLExport icsneoGetDeviceSettingsType(void* hObject, EPlasmaIonVnetChannel_t vnetSlot, EDeviceSettingsType* pDeviceSettingsType); +extern int LegacyDLLExport icsneoSetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, int bSaveToEEPROM, EPlasmaIonVnetChannel_t vnetSlot); +extern int LegacyDLLExport icsneoGetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, EPlasmaIonVnetChannel_t vnetSlot); + +extern int LegacyDLLExport icsneoSetUSBLatency(NeoDevice* pNeoDevice, unsigned long LatencyVal); + +extern unsigned int LegacyDLLExport icsneoGetCANControllerClockFrequency(void* hObject, int lNetworkID); +extern int LegacyDLLExport icsneoSetCANParameters(void* hObject,unsigned int baudRatePrescaler,unsigned int propagationTqs,unsigned int phase1Tqs,unsigned int phase2Tqs,unsigned int syncJumpWidthTqs,unsigned int optionBits,int lNetworkID); +extern int LegacyDLLExport icsneoSetCANParametersPhilipsSJA1000(void* hObject,unsigned int btr0,unsigned int btr1,unsigned int optionBits,int lNetworkID); + +//Remote Device Functions +extern int LegacyDLLExport icsneoOpenRemoteNeoDevice(const char* pIPAddress,NeoDevice* pNeoDevice,void** hObject,unsigned char* bNetworkIDs,int iOptions); +extern int LegacyDLLExport icsneoFindRemoteNeoDevices(const char* pIPAddress, NeoDevice* pNeoDevice, int* pNumDevices); //Error Functions -extern int DLLExport icsneoGetLastAPIError(void* hObject, unsigned long* pErrorNumber); -extern int DLLExport icsneoGetErrorMessages(void* hObject, int* pErrorMsgs, int* pNumberOfErrors); -extern int DLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR*szErrorDescriptionShort, TCHAR*szErrorDescriptionLong, int* lMaxLengthShort, int* lMaxLengthLong,int* lErrorSeverity,int* lRestartNeeded); +extern int LegacyDLLExport icsneoGetLastAPIError(void* hObject, unsigned long* pErrorNumber); +extern int LegacyDLLExport icsneoGetErrorMessages(void* hObject, int* pErrorMsgs, int* pNumberOfErrors); +extern int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR*szErrorDescriptionShort, TCHAR*szErrorDescriptionLong, int* lMaxLengthShort, int* lMaxLengthLong,int* lErrorSeverity,int* lRestartNeeded); //ISO15765-2 Functions -extern int DLLExport icsneoISO15765_EnableNetworks(void* hObject, unsigned long ulNetworks); -extern int DLLExport icsneoISO15765_DisableNetworks(void* hObject); -extern int DLLExport icsneoISO15765_TransmitMessage(void* hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage* pMsg, unsigned long ulBlockingTimeout); -extern int DLLExport icsneoISO15765_ReceiveMessage(void* hObject,int ulNetworkID, stCM_ISO157652_RxMessage* pMsg); +extern int LegacyDLLExport icsneoISO15765_EnableNetworks(void* hObject, unsigned long ulNetworks); +extern int LegacyDLLExport icsneoISO15765_DisableNetworks(void* hObject); +extern int LegacyDLLExport icsneoISO15765_TransmitMessage(void* hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage* pMsg, unsigned long ulBlockingTimeout); +extern int LegacyDLLExport icsneoISO15765_TransmitMessageEx(void* hObject,unsigned long ulNetworkID,ISO15765_2015_TxMessage* pMsg,unsigned long ulBlockingTimeout); +extern int LegacyDLLExport icsneoISO15765_ReceiveMessage(void* hObject, int ulNetworkID, stCM_ISO157652_RxMessage* pMsg); //General Utility Functions -extern int DLLExport icsneoValidateHObject(void* hObject); -extern int DLLExport icsneoGetDLLVersion(void); -extern int DLLExport icsneoGetSerialNumber(void* hObject, unsigned int*iSerialNumber); -extern int DLLExport icsneoStartSockServer(void* hObject, int iPort); -extern int DLLExport icsneoStopSockServer(void* hObject); +extern int LegacyDLLExport icsneoValidateHObject(void* hObject); + +extern int LegacyDLLExport icsneoGetDLLVersion(void); +extern void LegacyDLLExport icsneoGetDLLVersionEx(unsigned long* dwMSVersion, unsigned long* dwLSVersion); + +extern int LegacyDLLExport icsneoGetSerialNumber(void* hObject, unsigned int*iSerialNumber); +extern int LegacyDLLExport icsneoSerialNumberFromString(unsigned long* serial, char* data); +extern int LegacyDLLExport icsneoSerialNumberToString(unsigned long serial, char* data, unsigned long data_size); + +extern int LegacyDLLExport icsneoStartSockServer(void* hObject, int iPort); +extern int LegacyDLLExport icsneoStopSockServer(void* hObject); //CoreMini Script functions -extern int DLLExport icsneoScriptStart(void* hObject, int iLocation); -extern int DLLExport icsneoScriptStop(void* hObject); -extern int DLLExport icsneoScriptLoad(void* hObject, const unsigned char* bin, unsigned long len_bytes, int iLocation); -extern int DLLExport icsneoScriptClear(void* hObject, int iLocation); -extern int DLLExport icsneoScriptStartFBlock(void* hObject,unsigned int fb_index); -extern int DLLExport icsneoScriptGetFBlockStatus(void* hObject, unsigned int fb_index, int* piRunStatus); -extern int DLLExport icsneoScriptStopFBlock(void* hObject,unsigned int fb_index); -extern int DLLExport icsneoScriptGetScriptStatus(void* hObject, int* piStatus); -extern int DLLExport icsneoScriptReadAppSignal(void* hObject, unsigned int iIndex, double*dValue); -extern int DLLExport icsneoScriptWriteAppSignal(void* hObject, unsigned int iIndex, double dValue); +extern int LegacyDLLExport icsneoScriptStart(void* hObject, int iLocation); +extern int LegacyDLLExport icsneoScriptStop(void* hObject); +extern int LegacyDLLExport icsneoScriptLoad(void* hObject, const unsigned char* bin, unsigned long len_bytes, int iLocation); +extern int LegacyDLLExport icsneoScriptClear(void* hObject, int iLocation); +extern int LegacyDLLExport icsneoScriptStartFBlock(void* hObject,unsigned int fb_index); +extern int LegacyDLLExport icsneoScriptGetFBlockStatus(void* hObject, unsigned int fb_index, int* piRunStatus); +extern int LegacyDLLExport icsneoScriptStopFBlock(void* hObject,unsigned int fb_index); +extern int LegacyDLLExport icsneoScriptGetScriptStatus(void* hObject, int* piStatus); +extern int LegacyDLLExport icsneoScriptReadAppSignal(void* hObject, unsigned int iIndex, double*dValue); +extern int LegacyDLLExport icsneoScriptWriteAppSignal(void* hObject, unsigned int iIndex, double dValue); //Deprecated (but still suppored in the DLL) -extern int DLLExport icsneoOpenPortEx(void* lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char* bNetworkID, int* hObject); -extern int DLLExport icsneoOpenPort(int lPortNumber, int lPortType, int lDriverType, unsigned char* bNetworkID, unsigned char* bSCPIDs, int* hObject); -extern int DLLExport icsneoEnableNetworkCom(void* hObject, int Enable); -extern int DLLExport icsneoFindAllCOMDevices(int lDriverType, int lGetSerialNumbers, int lStopAtFirst, int lUSBCommOnly, int* p_lDeviceTypes, int* p_lComPorts, int* p_lSerialNumbers, int*lNumDevices); +extern int LegacyDLLExport icsneoOpenPortEx(void* lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char* bNetworkID, int* hObject); +extern int LegacyDLLExport icsneoOpenPort(int lPortNumber, int lPortType, int lDriverType, unsigned char* bNetworkID, unsigned char* bSCPIDs, int* hObject); +extern int LegacyDLLExport icsneoFindAllCOMDevices(int lDriverType, int lGetSerialNumbers, int lStopAtFirst, int lUSBCommOnly, int* p_lDeviceTypes, int* p_lComPorts, int* p_lSerialNumbers, int*lNumDevices); +extern int LegacyDLLExport icsneoOpenNeoDeviceByChannels(NeoDevice* pNeoDevice,void** hObject,unsigned char* uChannels,int iSize,int bConfigRead,int iOptions); +extern int LegacyDLLExport icsneoLockChannels(void* hObject, unsigned char* uChannels, int iSize); +extern int LegacyDLLExport icsneoUnlockChannels(void* hObject, unsigned char* uChannels, int iSize); +extern int LegacyDLLExport icsneoGetChannelLockStatus(void* hObject, unsigned char* uChannels, int iSize); + +//Enable Network Com Functions +extern int LegacyDLLExport icsneoEnableNetworkComEx(void* hObject, int iEnable, int iNetId); +extern int LegacyDLLExport icsneoEnableNetworkCom(void* hObject, int Enable); + +//Firmware Info/Update calls +extern int LegacyDLLExport icsneoForceFirmwareUpdate(void* hObject); +extern int LegacyDLLExport icsneoGetHWFirmwareInfo(void* hObject, stAPIFirmwareInfo* pInfo); +extern int LegacyDLLExport icsneoGetDLLFirmwareInfo(void* hObject, stAPIFirmwareInfo* pInfo); +extern int LegacyDLLExport icsneoGetDLLFirmwareInfoEx(void* hObject, stAPIFirmwareInfo* pInfo, EPlasmaIonVnetChannel_t vnetSlot); +extern int LegacyDLLExport icsneoFirmwareUpdateRequired(void* hObject); + +//J2534 API functions +extern int LegacyDLLExport icsneoJ2534Cmd(void* hObject, unsigned char* CmdBuf, short Len, void* pVoid); +extern int LegacyDLLExport icsneoSendRawCmds(void* hObject, icsneoVICommand* pCmdMsgs, int lNumOfCmds); +extern int LegacyDLLExport icsneoEnableBusVoltageMonitor(void* hObject, unsigned int enable, unsigned int reserved); +extern int LegacyDLLExport icsneoGetBusVoltage(void* hObject, unsigned long* pVBusVoltage, unsigned int reserved); +extern int LegacyDLLExport icsneoGetNetidforSlaveVNETs(size_t* NetworkIndex, EPlasmaIonVnetChannel_t vnetSlot); +extern int LegacyDLLExport icsneoGetVnetSimpleNetid(size_t* FullNetID); +extern int LegacyDLLExport icsneoEnableDOIPLine(void* hObject, bool bActivate); +extern int LegacyDLLExport icsneoGetMiniportAdapterInfo(void* hObject, NETWORK_ADAPTER_INFO* aInfo); + +// Hardware Time API functions +extern int LegacyDLLExport icsneoSendHWTimeRequest(void* hObject); +extern int LegacyDLLExport icsneoReceiveHWTimeResponse(void* hObject, double* TimeHardware, unsigned long TimeOut); + +//Bitsmash functions +extern int LegacyDLLExport icsneoEnableBitSmash(void* hObject,int netId,unsigned int numWaitBits,unsigned int numSmashBits,unsigned int numFrames,unsigned int timeout_ms,unsigned int optionBits,unsigned int numArbIds,unsigned int arbIds[MAX_BIT_SMASH_ARBIDS]); +extern int LegacyDLLExport icsneoDisableBitSmash(void* hObject, unsigned int reservedZero); #ifdef __cplusplus } // extern "C" diff --git a/include/icsneo/platform/posix/dynamiclib.h b/include/icsneo/platform/posix/dynamiclib.h index 8b4fc4d..2510c1d 100644 --- a/include/icsneo/platform/posix/dynamiclib.h +++ b/include/icsneo/platform/posix/dynamiclib.h @@ -11,6 +11,7 @@ // Nothing special is needed to export #define DLLExport +#define LegacyDLLExport // #ifndef ICSNEO_NO_AUTO_DESTRUCT // #define ICSNEO_DESTRUCTOR __attribute__((destructor)); diff --git a/include/icsneo/platform/windows/dynamiclib.h b/include/icsneo/platform/windows/dynamiclib.h index d40b1f3..6c63758 100644 --- a/include/icsneo/platform/windows/dynamiclib.h +++ b/include/icsneo/platform/windows/dynamiclib.h @@ -5,6 +5,7 @@ #ifdef ICSNEOC_MAKEDLL #define DLLExport __declspec(dllexport) +#define LegacyDLLExport _stdcall #else #define DLLExport __declspec(dllimport) #endif diff --git a/platform/windows/icsneolegacy.def b/platform/windows/icsneolegacy.def new file mode 100644 index 0000000..b19edee --- /dev/null +++ b/platform/windows/icsneolegacy.def @@ -0,0 +1,99 @@ + +LIBRARY icsneolegacy + +EXPORTS + icsneoFindDevices @1 + icsneoFindNeoDevices @2 + icsneoOpenNeoDevice @3 + icsneoClosePort @4 + icsneoFreeObject @5 + icsneoOpenDevice @6 + icsneoGetMessages @7 + icsneoTxMessages @8 + icsneoTxMessagesEx @9 + icsneoWaitForRxMessagesWithTimeOut @10 + icsneoEnableNetworkRXQueue @11 + icsneoGetTimeStampForMsg @12 + icsneoGetISO15765Status @13 + icsneoSetISO15765RxParameters @14 + icsneoGetConfiguration @15 + icsneoSendConfiguration @16 + icsneoGetFireSettings @17 + icsneoSetFireSettings @18 + icsneoGetVCAN3Settings @19 + icsneoSetVCAN3Settings @20 + icsneoGetFire2Settings @21 + icsneoSetFire2Settings @22 + icsneoGetVCANRFSettings @23 + icsneoGetVCAN412Settings @24 + icsneoSetVCAN412Settings @25 + icsneoGetRADGalaxySettings @26 + icsneoSetRADGalaxySettings @27 + icsneoGetRADStar2Settings @28 + icsneoSetRADStar2Settings @29 + icsneoSetBitRate @30 + icsneoSetBitRateEx @31 + icsneoSetFDBitRate @32 + icsneoGetDeviceParameters @33 + icsneoSetDeviceParameters @34 + icsneoGetVCAN4Settings @35 + icsneoSetVCAN4Settings @36 + icsneoGetDeviceSettingsType @37 + icsneoSetDeviceSettings @38 + icsneoGetDeviceSettings @39 + icsneoSetUSBLatency @40 + icsneoGetCANControllerClockFrequency @41 + icsneoSetCANParameters @42 + icsneoSetCANParametersPhilipsSJA1000 @43 + icsneoOpenRemoteNeoDevice @44 + icsneoFindRemoteNeoDevices @45 + icsneoGetLastAPIError @46 + icsneoGetErrorMessages @47 + icsneoGetErrorInfo @48 + icsneoISO15765_EnableNetworks @49 + icsneoISO15765_DisableNetworks @50 + icsneoISO15765_TransmitMessage @51 + icsneoISO15765_ReceiveMessage @52 + icsneoValidateHObject @53 + icsneoGetDLLVersion @54 + icsneoGetDLLVersionEx @55 + icsneoGetSerialNumber @56 + icsneoSerialNumberFromString @57 + icsneoSerialNumberToString @58 + icsneoStartSockServer @59 + icsneoStopSockServer @60 + icsneoScriptStart @61 + icsneoScriptStop @62 + icsneoScriptLoad @63 + icsneoScriptClear @64 + icsneoScriptStartFBlock @65 + icsneoScriptGetFBlockStatus @66 + icsneoScriptStopFBlock @67 + icsneoScriptGetScriptStatus @68 + icsneoScriptReadAppSignal @69 + icsneoScriptWriteAppSignal @70 + icsneoOpenPortEx @71 + icsneoOpenPort @72 + icsneoFindAllCOMDevices @73 + icsneoEnableNetworkComEx @74 + icsneoEnableNetworkCom @75 + icsneoForceFirmwareUpdate @76 + icsneoGetHWFirmwareInfo @77 + icsneoGetDLLFirmwareInfo @78 + icsneoGetDLLFirmwareInfoEx @79 + icsneoFirmwareUpdateRequired @80 + icsneoJ2534Cmd @81 + icsneoSendRawCmds @82 + icsneoEnableBusVoltageMonitor @83 + icsneoGetBusVoltage @84 + icsneoGetNetidforSlaveVNETs @85 + icsneoGetVnetSimpleNetid @86 + icsneoEnableDOIPLine @87 + icsneoGetMiniportAdapterInfo @88 + icsneoSendHWTimeRequest @89 + icsneoReceiveHWTimeResponse @90 + icsneoEnableBitSmash @91 + icsneoDisableBitSmash @92 + icsneoOpenNeoDeviceByChannels @93 + icsneoISO15765_TransmitMessageEx @94 + icsneoSetVCANRFSettings @95 \ No newline at end of file From 34f7bfabd26bf6646c5b012f47647cc2b3fcb735 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 12:36:37 -0400 Subject: [PATCH 11/17] API: Legacy: Remove unused variable --- api/icsneolegacy/icsneolegacy.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index d1ebbef..893e3ce 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -607,9 +607,8 @@ int LegacyDLLExport icsneoOpenNeoDevice(NeoDevice *pNeoDevice, void **hObject, u { device = &neodevices.at(uint64_t(pNeoDevice->Handle) << 32 | pNeoDevice->SerialNumber); } - catch (std::out_of_range &e) + catch (const std::out_of_range&) { - (void)e; // Unused return false; } From 843fa925649a228cd07da4f0937ed5d5c9154482 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 12:39:20 -0400 Subject: [PATCH 12/17] API: Legacy: Add standard DLLExport to LegacyDLLExport --- include/icsneo/platform/posix/dynamiclib.h | 2 +- include/icsneo/platform/windows/dynamiclib.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/icsneo/platform/posix/dynamiclib.h b/include/icsneo/platform/posix/dynamiclib.h index 2510c1d..cdfb896 100644 --- a/include/icsneo/platform/posix/dynamiclib.h +++ b/include/icsneo/platform/posix/dynamiclib.h @@ -11,7 +11,7 @@ // Nothing special is needed to export #define DLLExport -#define LegacyDLLExport +#define LegacyDLLExport DLLExport // #ifndef ICSNEO_NO_AUTO_DESTRUCT // #define ICSNEO_DESTRUCTOR __attribute__((destructor)); diff --git a/include/icsneo/platform/windows/dynamiclib.h b/include/icsneo/platform/windows/dynamiclib.h index 6c63758..12db241 100644 --- a/include/icsneo/platform/windows/dynamiclib.h +++ b/include/icsneo/platform/windows/dynamiclib.h @@ -5,10 +5,10 @@ #ifdef ICSNEOC_MAKEDLL #define DLLExport __declspec(dllexport) -#define LegacyDLLExport _stdcall #else #define DLLExport __declspec(dllimport) #endif +#define LegacyDLLExport _stdcall DLLExport // MSVC does not have the ability to specify a destructor #define ICSNEO_DESTRUCTOR From f3e456e7ea023ba38d6125a1834449708128d078 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 13:05:39 -0400 Subject: [PATCH 13/17] API: Legacy: Fix build issues caused by the merge --- api/icsneolegacy/icsneolegacy.cpp | 483 +----------------- .../icsneo/device/tree/neovired2/neovired2.h | 2 +- 2 files changed, 27 insertions(+), 458 deletions(-) diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index 893e3ce..c44450d 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -27,9 +27,9 @@ using namespace icsneo; typedef uint64_t legacymaphandle_t; static std::map neodevices; -std::map mp_netIDToVnetOffSet = {{NETID_HSCAN, 1}, {NETID_MSCAN, 2}, {NETID_HSCAN2, 18}, {NETID_HSCAN3, 19}, {NETID_HSCAN4, 32}, {NETID_HSCAN5, 33}, {NETID_HSCAN6, 47}, {NETID_HSCAN7, 48}}; -std::map mp_HWnetIDToCMnetID = {{NETID_HSCAN, 0}, {NETID_MSCAN, 1}, {NETID_HSCAN2, 5}, {NETID_HSCAN3, 8}, {NETID_HSCAN4, 14}, {NETID_HSCAN5, 15}, {NETID_HSCAN6, 32}, {NETID_HSCAN7, 33}}; -unsigned long vnet_table[] = {0, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE2_OFFSET}; +static std::map mp_netIDToVnetOffSet = {{NETID_HSCAN, 1}, {NETID_MSCAN, 2}, {NETID_HSCAN2, 18}, {NETID_HSCAN3, 19}, {NETID_HSCAN4, 32}, {NETID_HSCAN5, 33}, {NETID_HSCAN6, 47}, {NETID_HSCAN7, 48}}; +static std::map mp_HWnetIDToCMnetID = {{NETID_HSCAN, 0}, {NETID_MSCAN, 1}, {NETID_HSCAN2, 5}, {NETID_HSCAN3, 8}, {NETID_HSCAN4, 14}, {NETID_HSCAN5, 15}, {NETID_HSCAN6, 32}, {NETID_HSCAN7, 33}}; +static unsigned long vnet_table[] = {0, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE2_OFFSET}; static NeoDevice OldNeoDeviceFromNew(const neodevice_t *newnd) { @@ -92,431 +92,55 @@ static void NeoMessageToSpyMessage(const neodevice_t *device, const neomessage_t } } -inline bool Within(size_t value, size_t min, size_t max) +static inline bool Within(size_t value, size_t min, size_t max) { return ((min <= value) && (value < max)); } -inline bool IdIsSlaveARange1(size_t fullNetid) + +static inline bool IdIsSlaveARange1(size_t fullNetid) { return Within(fullNetid, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE1_OFFSET + PLASMA_SLAVE_NUM); } -inline bool IdIsSlaveARange2(size_t fullNetid) + +static inline bool IdIsSlaveARange2(size_t fullNetid) { return Within(fullNetid, PLASMA_SLAVE1_OFFSET_RANGE2, PLASMA_SLAVE2_OFFSET_RANGE2); } -inline bool IdIsSlaveBRange1(size_t fullNetid) + +static inline bool IdIsSlaveBRange1(size_t fullNetid) { return Within(fullNetid, PLASMA_SLAVE2_OFFSET, PLASMA_SLAVE2_OFFSET + PLASMA_SLAVE_NUM); } -inline bool IdIsSlaveBRange2(unsigned int fullNetid) + +static inline bool IdIsSlaveBRange2(unsigned int fullNetid) { return Within(fullNetid, PLASMA_SLAVE2_OFFSET_RANGE2, PLASMA_SLAVE3_OFFSET_RANGE2); } -/** @return 0 for main vnet, 1 for slave1, 2 for slave2 */ -inline EPlasmaIonVnetChannel_t GetVnetPos(size_t fullNetid) -{ - if (IdIsSlaveARange1(fullNetid) || IdIsSlaveARange2(fullNetid)) - { - return PlasmaIonVnetChannelA; - } - - if (IdIsSlaveBRange1(fullNetid) || IdIsSlaveBRange2(fullNetid)) - { - return PlasmaIonVnetChannelB; - } - return PlasmaIonVnetChannelMain; -} - -inline unsigned int GetVnetNetid(size_t simpleNetId, EPlasmaIonVnetChannel_t vnetSlot) +static inline unsigned int GetVnetNetid(size_t simpleNetId, EPlasmaIonVnetChannel_t vnetSlot) { if (vnetSlot == 0 || vnetSlot > 3) return simpleNetId; return mp_netIDToVnetOffSet[simpleNetId] + vnet_table[vnetSlot]; } + /** * So if you are passing in the offset from PLASMA_SLAVE1_OFFSET or * the offset from PLASMA_SLAVE1_OFFSET2, return the vnet agnostic * netid so caller can commonize handlers without caring about WHICH slave. */ -inline unsigned int OffsetToSimpleNetworkId(size_t offset) +static inline unsigned int OffsetToSimpleNetworkId(size_t offset) { - for (auto &it : mp_netIDToVnetOffSet) + for (const auto& it : mp_netIDToVnetOffSet) { if (it.second == offset) return it.first; } - return 0; //NETID_DEVICE + return NETID_DEVICE; } -inline unsigned int GetVnetAgnosticNetid(size_t fullNetid) -{ - if (IdIsSlaveARange1(fullNetid)) - { - unsigned int off = fullNetid - PLASMA_SLAVE1_OFFSET; - return OffsetToSimpleNetworkId(off); - } - else if (IdIsSlaveARange2(fullNetid)) - { - return fullNetid - PLASMA_SLAVE1_OFFSET_RANGE2; - } - else if (IdIsSlaveBRange1(fullNetid)) - { - unsigned int off = fullNetid - PLASMA_SLAVE2_OFFSET; - return OffsetToSimpleNetworkId(off); - } - else if (IdIsSlaveBRange2(fullNetid)) - { - return fullNetid - PLASMA_SLAVE2_OFFSET_RANGE2; - } - return fullNetid; -} - -/** - * So if you are passing in a simple net id such as NETID_LIN4, - * return the offset that we can add to PLASMA_SLAVE1_OFFSET or - * PLASMA_SLAVE2_OFFSET to compute the corresponding slave netids. - */ -inline bool NetworkIdToVnetOffset_Range1(size_t simpleNetId, size_t& offset) -{ - switch (simpleNetId) - { - case NETID_DEVICE: - offset = 0; - break; - case NETID_HSCAN: - offset = 1; - break; - case NETID_MSCAN: - offset = 2; - break; - case NETID_SWCAN: - offset = 3; - break; - case NETID_LSFTCAN: - offset = 4; - break; - case NETID_FORDSCP: - offset = 5; - break; - case NETID_J1708: - offset = 6; - break; - case NETID_AUX: - offset = 7; - break; - case NETID_JVPW: - offset = 8; - break; - case NETID_ISO: - offset = 9; - break; - case NETID_ISOPIC: - offset = 10; - break; - case NETID_MAIN51: - offset = 11; - break; - case NETID_RED: - offset = 12; - break; - case NETID_SCI: - offset = 13; - break; - case NETID_ISO2: - offset = 14; - break; - case NETID_ISO14230: - offset = 15; - break; - case NETID_LIN: - offset = 16; - break; - case NETID_ISO3: - offset = 17; - break; - case NETID_HSCAN2: - offset = 18; - break; - case NETID_HSCAN3: - offset = 19; - break; - case NETID_ISO4: - offset = 20; - break; - case NETID_LIN2: - offset = 21; - break; - case NETID_LIN3: - offset = 22; - break; - case NETID_LIN4: - offset = 23; - break; - case NETID_MOST: - offset = 24; - break; - case NETID_CGI: - offset = 25; - break; - case NETID_I2C1: - offset = 26; - break; - case NETID_SPI1: - offset = 27; - break; - case NETID_FLEXRAY1A: - offset = 28; - break; - case NETID_MOST25: - offset = 29; - break; - case NETID_MOST50: - offset = 30; - break; - case NETID_MOST150: - offset = 31; - break; - case NETID_HSCAN4: - offset = 32; - break; - case NETID_HSCAN5: - offset = 33; - break; - case NETID_RS232: - offset = 34; - break; - case NETID_UART: - offset = 35; - break; - case NETID_UART2: - offset = 36; - break; - case NETID_UART3: - offset = 37; - break; - case NETID_UART4: - offset = 38; - break; - case NETID_SWCAN2: - offset = 39; - break; - case NETID_FLEXRAY1B: - offset = 40; - break; - case NETID_FLEXRAY2A: - offset = 41; - break; - case NETID_FLEXRAY2B: - offset = 42; - break; - case NETID_LIN5: - offset = 43; - break; - case NETID_ETHERNET: - offset = 44; - break; - case NETID_ETHERNET_DAQ: - offset = 45; - break; - case NETID_RED_APP_ERROR: - offset = 46; - break; - case NETID_HSCAN6: - offset = 47; - break; - case NETID_HSCAN7: - offset = 48; - break; - case NETID_LIN6: - offset = 49; - break; - case NETID_LSFTCAN2: - offset = 50; - break; - default: - /* there is no decoding for the provided id */ - offset = 0; - return false; - } - return true; -} - -inline bool Within(size_t value, size_t min, size_t max) -{ - return ((min <= value) && (value < max)); -} -inline bool IdIsSlaveARange1(size_t fullNetid) -{ - return Within(fullNetid, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE1_OFFSET + PLASMA_SLAVE_NUM); -} -inline bool IdIsSlaveARange2(size_t fullNetid) -{ - return Within(fullNetid, PLASMA_SLAVE1_OFFSET_RANGE2, PLASMA_SLAVE2_OFFSET_RANGE2); -} -inline bool IdIsSlaveBRange1(size_t fullNetid) -{ - return Within(fullNetid, PLASMA_SLAVE2_OFFSET, PLASMA_SLAVE2_OFFSET + PLASMA_SLAVE_NUM); -} -inline bool IdIsSlaveBRange2(unsigned int fullNetid) -{ - return Within(fullNetid, PLASMA_SLAVE2_OFFSET_RANGE2, PLASMA_SLAVE3_OFFSET_RANGE2); -} - -/** @return 0 for main vnet, 1 for slave1, 2 for slave2 */ -inline EPlasmaIonVnetChannel_t GetVnetPos(size_t fullNetid) -{ - if (IdIsSlaveARange1(fullNetid) || IdIsSlaveARange2(fullNetid)) - { - return PlasmaIonVnetChannelA; - } - - if (IdIsSlaveBRange1(fullNetid) || IdIsSlaveBRange2(fullNetid)) - { - return PlasmaIonVnetChannelB; - } - return PlasmaIonVnetChannelMain; -} - -inline unsigned int GetVnetNetid(size_t simpleNetId, EPlasmaIonVnetChannel_t vnetSlot) -{ - if (vnetSlot > 3) - return simpleNetId; - - if (vnetSlot == 0) - return simpleNetId; - - unsigned int offset = 0; - if (NetworkIdToVnetOffset_Range1(simpleNetId, offset)) - { - /* simpleNetId was one of the original networks mapped to slaves */ - unsigned long table[] = { 0, PLASMA_SLAVE1_OFFSET, PLASMA_SLAVE2_OFFSET }; - return offset + table[vnetSlot]; - } - else - { - /* simpleNetid has the simpler offset scheme */ - unsigned long table[] = { 0, PLASMA_SLAVE1_OFFSET_RANGE2, PLASMA_SLAVE2_OFFSET_RANGE2 }; - return simpleNetId + table[vnetSlot]; - } -} -/** - * So if you are passing in the offset from PLASMA_SLAVE1_OFFSET or - * the offset from PLASMA_SLAVE1_OFFSET2, return the vnet agnostic - * netid so caller can commonize handlers without caring about WHICH slave. - */ -inline unsigned int OffsetToSimpleNetworkId(size_t offset) -{ - switch (offset) - { - default: - case 0: - return NETID_DEVICE; - case 1: - return NETID_HSCAN; - case 2: - return NETID_MSCAN; - case 3: - return NETID_SWCAN; - case 4: - return NETID_LSFTCAN; - case 5: - return NETID_FORDSCP; - case 6: - return NETID_J1708; - case 7: - return NETID_AUX; - case 8: - return NETID_JVPW; - case 9: - return NETID_ISO; - case 10: - return NETID_ISOPIC; - case 11: - return NETID_MAIN51; - case 12: - return NETID_RED; - case 13: - return NETID_SCI; - case 14: - return NETID_ISO2; - case 15: - return NETID_ISO14230; - case 16: - return NETID_LIN; - case 17: - return NETID_ISO3; - case 18: - return NETID_HSCAN2; - case 19: - return NETID_HSCAN3; - case 20: - return NETID_ISO4; - case 21: - return NETID_LIN2; - case 22: - return NETID_LIN3; - case 23: - return NETID_LIN4; - case 24: - return NETID_MOST; - case 25: - return NETID_CGI; - case 26: - return NETID_I2C1; - case 27: - return NETID_SPI1; - case 28: - return NETID_FLEXRAY1A; - case 29: - return NETID_MOST25; - case 30: - return NETID_MOST50; - case 31: - return NETID_MOST150; - case 32: - return NETID_HSCAN4; - case 33: - return NETID_HSCAN5; - case 34: - return NETID_RS232; - case 35: - return NETID_UART; - case 36: - return NETID_UART2; - case 37: - return NETID_UART3; - case 38: - return NETID_UART4; - case 39: - return NETID_SWCAN2; - case 40: - return NETID_FLEXRAY1B; - case 41: - return NETID_FLEXRAY2A; - case 42: - return NETID_FLEXRAY2B; - case 43: - return NETID_LIN5; - case 44: - return NETID_ETHERNET; - case 45: - return NETID_ETHERNET_DAQ; - case 46: - return NETID_RED_APP_ERROR; - case 47: - return NETID_HSCAN6; - case 48: - return NETID_HSCAN7; - case 49: - return NETID_LIN6; - case 50: - return NETID_LSFTCAN2; - } -} - -inline unsigned int GetVnetAgnosticNetid(size_t fullNetid) +static inline unsigned int GetVnetAgnosticNetid(size_t fullNetid) { if (IdIsSlaveARange1(fullNetid)) { @@ -548,7 +172,7 @@ int LegacyDLLExport icsneoFindDevices(NeoDeviceEx *devs, int *devCount, unsigned size_t Count = 0; - icsneoFindNeoDevices(NULL, Nd, &NumDevices); + icsneoFindNeoDevices(0, Nd, &NumDevices); if (NumDevices > 0) { @@ -1018,14 +642,16 @@ int LegacyDLLExport icsneoGetSerialNumber(void *hObject, unsigned int *iSerialNu return true; } -int LegacyDLLExport icsneoEnableDOIPLine(void* hObject, bool enable) { +int LegacyDLLExport icsneoEnableDOIPLine(void* hObject, bool enable) +{ if(!icsneoValidateHObject(hObject)) return false; neodevice_t* device = (neodevice_t*)hObject; return icsneo_setDigitalIO(device, ICSNEO_IO_ETH_ACTIVATION, 1, enable); } -int LegacyDLLExport icsneoStartSockServer(void* hObject, int iPort) { +int LegacyDLLExport icsneoStartSockServer(void* hObject, int iPort) +{ // TODO Implement return false; } @@ -1134,37 +760,6 @@ int LegacyDLLExport icsneoOpenNeoDeviceByChannels(NeoDevice *pNeoDevice, void ** return false; } -int LegacyDLLExport icsneoOpenDevice(NeoDeviceEx *pNeoDeviceEx, - void **hObject, - unsigned char *bNetworkIDs, - int bConfigRead, - int iOptions, - OptionsOpenNeoEx *stOptionsOpenNeoEx, - unsigned long reserved) -{ - if (pNeoDeviceEx == nullptr || hObject == nullptr) - return false; - - neodevice_t *device; - try - { - device = &neodevices.at(uint64_t(pNeoDeviceEx->neoDevice.Handle) << 32 | pNeoDeviceEx->neoDevice.SerialNumber); - } - catch (std::out_of_range &e) - { - (void)e; // Unused - return false; - } - - *hObject = device; - if (!icsneo_openDevice(device)) - return false; - - icsneo_setPollingMessageLimit(device, 20000); - icsneo_enableMessagePolling(device); - return icsneo_goOnline(device); -} - int LegacyDLLExport icsneoGetVCAN4Settings(void *hObject, SVCAN4Settings *pSettings, int iNumBytes) { if (!icsneoValidateHObject(hObject)) @@ -1196,9 +791,7 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void *hObject, EPlasmaIonVnetCha return 0; if ((PlasmaIonVnetChannelMain != vnetSlot) && (ulDeviceType != NEODEVICE_PLASMA) && (ulDeviceType != NEODEVICE_ION)) - { return 0; - } switch (ulDeviceType) { @@ -1415,17 +1008,8 @@ int LegacyDLLExport icsneoGetDLLFirmwareInfoEx(void *hObject, stAPIFirmwareInfo int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short Len, void *pVoid) { - bool bCurrentSetting, bHSSWCANRate, bRetVal, bTermination, bFormat; - unsigned long *pTmp, Baud; - int iRetVal = 0, NetworkID; - ISO9141NetworkParms* pISOParms; - EPlasmaIonVnetChannel_t pos; - - unsigned long *pTmp, Baud; - - int iRetVal = 0, NetworkID; - - ISO9141NetworkParms* pISOParms; + unsigned long *pTmp = nullptr; + int iRetVal = 0, iNumBytes = 0, NetworkID; if (!icsneoValidateHObject(hObject)) return false; @@ -1446,7 +1030,6 @@ int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short L case J2534NVCMD_GetNetworkBaudRate: - double dBaud; pTmp = (uint64_t *)&CmdBuf[1]; NetworkID = (uint16_t)*pTmp; pTmp = (uint64_t *)&CmdBuf[5]; @@ -1482,7 +1065,6 @@ int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short L NetworkID = (uint16_t)*pTmp; pTmp = (uint64_t *)&CmdBuf[5]; - pos = GetVnetPos(NetworkID); switch (device->type) { case NEODEVICE_FIRE2: @@ -1504,7 +1086,6 @@ int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short L NetworkID = (uint16_t)*pTmp; pTmp = (uint64_t *)&CmdBuf[5]; - pos = GetVnetPos(NetworkID); switch (device->type) { case NEODEVICE_FIRE2: @@ -1521,7 +1102,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short L else /*Termination OFF*/ Cs.termination_enables &= ~(1ull << CoremininetID); - iRetVal = icsneoSetFire2Settings(hObject, &Cs, iNumBytes, ConfigurationOptionDoNotSaveToEEPROM); + iRetVal = icsneoSetFire2Settings(hObject, &Cs, iNumBytes, 1 /* ConfigurationOptionDoNotSaveToEEPROM */); } break; } @@ -1575,14 +1156,6 @@ int LegacyDLLExport icsneoFirmwareUpdateRequired(void *hObject) return false; } -int LegacyDLLExport icsneoSetFDBitRate(void *hObject, int BitRate, int NetworkID) -{ - neodevice_t *device = (neodevice_t *)hObject; - if (!icsneo_setFDBaudrate(device, (uint16_t)NetworkID, BitRate)) - return false; - return icsneo_settingsApply(device); -} - void LegacyDLLExport icsneoGetDLLVersionEx(unsigned long *dwMSVersion, unsigned long *dwLSVersion) { return; @@ -1607,10 +1180,6 @@ int LegacyDLLExport icsneoSerialNumberFromString(unsigned long *serial, char *da return false; } -int LegacyDLLExport icsneoEnableDOIPLine(void *hObject, bool bActivate) -{ - return false; -} int LegacyDLLExport icsneoGetMiniportAdapterInfo(void *hObject, NETWORK_ADAPTER_INFO *aInfo) { return false; diff --git a/include/icsneo/device/tree/neovired2/neovired2.h b/include/icsneo/device/tree/neovired2/neovired2.h index 93cc464..fdb9df7 100644 --- a/include/icsneo/device/tree/neovired2/neovired2.h +++ b/include/icsneo/device/tree/neovired2/neovired2.h @@ -25,7 +25,7 @@ public: if (!fakedev->com->decoder->decode(msg, packet)) continue; // We failed to decode this packet - if(!msg || msg->type != Message::Type::Main51) + if(!msg || msg->network.getNetID() != Network::NetID::Main51) continue; // Not a message we care about auto sn = std::dynamic_pointer_cast(msg); if(!sn) From a43c0117d6432240221c80a4c4e9f414f5683869 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 13:06:47 -0400 Subject: [PATCH 14/17] API: C: Check nullptr in icsneo_serialStringToNum Otherwise it will implicitly call the std::string constructor and that constructor does not check nullptr. --- api/icsneoc/icsneoc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/icsneoc/icsneoc.cpp b/api/icsneoc/icsneoc.cpp index 046a41d..0d0e4d7 100644 --- a/api/icsneoc/icsneoc.cpp +++ b/api/icsneoc/icsneoc.cpp @@ -84,6 +84,9 @@ bool icsneo_serialNumToString(uint32_t num, char* str, size_t* count) { } uint32_t icsneo_serialStringToNum(const char* str) { + if(!str) + return 0; + return Device::SerialStringToNum(str); } From 45c879c2b6596f0d49b56e45ab9264be545edf3b Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 13:52:09 -0400 Subject: [PATCH 15/17] API: Legacy: Update def file with the correct ordinals --- platform/windows/icsneolegacy.def | 304 ++++++++++++++++++++---------- 1 file changed, 208 insertions(+), 96 deletions(-) diff --git a/platform/windows/icsneolegacy.def b/platform/windows/icsneolegacy.def index b19edee..a3f9fb7 100644 --- a/platform/windows/icsneolegacy.def +++ b/platform/windows/icsneolegacy.def @@ -1,99 +1,211 @@ LIBRARY icsneolegacy -EXPORTS - icsneoFindDevices @1 - icsneoFindNeoDevices @2 - icsneoOpenNeoDevice @3 - icsneoClosePort @4 - icsneoFreeObject @5 - icsneoOpenDevice @6 - icsneoGetMessages @7 - icsneoTxMessages @8 - icsneoTxMessagesEx @9 - icsneoWaitForRxMessagesWithTimeOut @10 - icsneoEnableNetworkRXQueue @11 - icsneoGetTimeStampForMsg @12 - icsneoGetISO15765Status @13 - icsneoSetISO15765RxParameters @14 - icsneoGetConfiguration @15 - icsneoSendConfiguration @16 - icsneoGetFireSettings @17 - icsneoSetFireSettings @18 - icsneoGetVCAN3Settings @19 - icsneoSetVCAN3Settings @20 - icsneoGetFire2Settings @21 - icsneoSetFire2Settings @22 - icsneoGetVCANRFSettings @23 - icsneoGetVCAN412Settings @24 - icsneoSetVCAN412Settings @25 - icsneoGetRADGalaxySettings @26 - icsneoSetRADGalaxySettings @27 - icsneoGetRADStar2Settings @28 - icsneoSetRADStar2Settings @29 - icsneoSetBitRate @30 - icsneoSetBitRateEx @31 - icsneoSetFDBitRate @32 - icsneoGetDeviceParameters @33 - icsneoSetDeviceParameters @34 - icsneoGetVCAN4Settings @35 - icsneoSetVCAN4Settings @36 - icsneoGetDeviceSettingsType @37 - icsneoSetDeviceSettings @38 - icsneoGetDeviceSettings @39 - icsneoSetUSBLatency @40 - icsneoGetCANControllerClockFrequency @41 - icsneoSetCANParameters @42 - icsneoSetCANParametersPhilipsSJA1000 @43 - icsneoOpenRemoteNeoDevice @44 - icsneoFindRemoteNeoDevices @45 - icsneoGetLastAPIError @46 - icsneoGetErrorMessages @47 - icsneoGetErrorInfo @48 - icsneoISO15765_EnableNetworks @49 - icsneoISO15765_DisableNetworks @50 - icsneoISO15765_TransmitMessage @51 - icsneoISO15765_ReceiveMessage @52 - icsneoValidateHObject @53 - icsneoGetDLLVersion @54 - icsneoGetDLLVersionEx @55 - icsneoGetSerialNumber @56 - icsneoSerialNumberFromString @57 - icsneoSerialNumberToString @58 - icsneoStartSockServer @59 - icsneoStopSockServer @60 - icsneoScriptStart @61 - icsneoScriptStop @62 - icsneoScriptLoad @63 - icsneoScriptClear @64 - icsneoScriptStartFBlock @65 - icsneoScriptGetFBlockStatus @66 - icsneoScriptStopFBlock @67 - icsneoScriptGetScriptStatus @68 - icsneoScriptReadAppSignal @69 - icsneoScriptWriteAppSignal @70 - icsneoOpenPortEx @71 - icsneoOpenPort @72 - icsneoFindAllCOMDevices @73 - icsneoEnableNetworkComEx @74 - icsneoEnableNetworkCom @75 - icsneoForceFirmwareUpdate @76 - icsneoGetHWFirmwareInfo @77 - icsneoGetDLLFirmwareInfo @78 - icsneoGetDLLFirmwareInfoEx @79 - icsneoFirmwareUpdateRequired @80 - icsneoJ2534Cmd @81 - icsneoSendRawCmds @82 - icsneoEnableBusVoltageMonitor @83 - icsneoGetBusVoltage @84 - icsneoGetNetidforSlaveVNETs @85 - icsneoGetVnetSimpleNetid @86 - icsneoEnableDOIPLine @87 - icsneoGetMiniportAdapterInfo @88 - icsneoSendHWTimeRequest @89 - icsneoReceiveHWTimeResponse @90 - icsneoEnableBitSmash @91 - icsneoDisableBitSmash @92 - icsneoOpenNeoDeviceByChannels @93 - icsneoISO15765_TransmitMessageEx @94 - icsneoSetVCANRFSettings @95 \ No newline at end of file +EXPORTS + icsneoOpenPort @21 + icsneoClosePort @22 + icsneoGetMessages @23 + icsneoTxMessages @24 + icsneoFreeObject @25 + icsneoGetErrorMessages @26 + icsneoStartSockServer @29 + icsneoSendConfiguration @30 + icsneoGetSerialNumber @32 + icsneoFindAllUSBDevices @33 + icsneoOpenPortEx @34 + icsneoStopSockServer @35 + icsneoGetErrorInfo @36 + icsneoGetDLLVersion @37 + icsneoGetConfiguration @38 + icsneoFindAllCOMDevices @39 + icsneoGetISO15765Status @40 + icsneoSetISO15765RxParameters @41 + icsneoSetPerformanceParameters @42 + icsneoEnableNetworkCom @ 43 + icsneoGetPerformanceParameters @ 44 + icsneoSetupISO15765HwSupport @ 45 + icsneoWaitForRxMessagesWithTimeOut @ 46 + icsneoGetErrorInfoW @47 + icsneoGetOpenPorts @ 48 + icsneoGetPerformanceTimer @ 49 + icsneoFindFirstFreeDevice @ 50 + icsneoJ2534Cmd @ 51 + + icsneoScriptStartFBlock @ 52 + icsneoScriptStopFBlock @ 53 + icsneoScriptGetFBlockStatus @ 54 + icsneoScriptReadTxMessage @ 55 + icsneoScriptWriteTxMessage @ 56 + icsneoScriptStart @ 57 + icsneoScriptStop @ 58 + + icsneoFindNeoDevices @ 62 + icsneoOpenNeoDevice @ 63 + icsneoOpenNeoDeviceBySerialNumber @ 64 + + icsneoForceFirmwareUpdate @ 65 + icsneoGetHWFirmwareInfo @ 66 + icsneoGetDLLFirmwareInfo @ 67 + + icsneoSetupISO15765HwSupportEx @ 68 + + icsneoSetBitRate @ 69 + + icsneoReadSDCard @ 72 + icsneoGetTimeStampForMsg @ 73 + + icsneoWriteSDCard @ 76 + + icsneoScriptLoad @ 77 + icsneoScriptClear @ 78 + icsneoGetLastAPIError @ 79 + icsneoValidateHObject @ 80 + + icsneoScriptReadAppSignal @ 81 + icsneoScriptWriteAppSignal @ 82 + + icsneoScriptReadISO15765_2_TxMessage @ 84 + icsneoScriptWriteISO15765_2_TxMessage @ 85 + icsneoScriptReadRxMessage @ 86 + icsneoScriptWriteRxMessage @ 87 + + icsneoScriptGetScriptStatus @ 91 + + icsneoEnableNetworkRXQueue @ 94 + icsneoGetFireSettings @ 95 + icsneoSetFireSettings @ 96 + + icsneoGetVCAN3Settings @ 97 + icsneoSetVCAN3Settings @ 98 + + icsneoGetDeviceParameters @99 + icsneoSetDeviceParameters @100 + + icsneoSetReflashCallback @101 + + icsneoSetReflashDisplayCallbacks @102 + icsneoClearReflashDisplayCallbacks @103 + + icsneoGetStoredFirmwareInfo @104 + icsneoDownloadISO15765_2_TXScript @ 105 + icsneoTransmitISO15765_2_Message @106 + icsneoClearISO15765_2_TxScript @ 107 + + icsneoGetDLLVersionEx @108 + + icsneoEnable_ISO15765_2_By_Network @ 111 + icsneoDisable_ISO15765_2 @ 112 + icsneoSetISO15765_2_FlowCtlID @ 113 + icsneoClearISO15765_2_FlowCtlID @ 114 + icsneoClearAllISO15765_2_FlowCtlIDs @ 115 + + icsneoSetContext @ 116 + icsneoFindNeoDevicesEx @ 117 + icsneoOpenNeoDeviceEx @ 118 + + icsneoFindRemoteNeoDevices @ 120 + icsneoOpenRemoteNeoDevice @ 121 + icsneoISO15765_EnableNetworks @122 + icsneoISO15765_DisableNetworks @123 + icsneoISO15765_TransmitMessage @124 + + icsneoGetCANControllerClockFrequency @129 + icsneoSetCANParameters @130 + icsneoSetCANParametersPhilipsSJA1000 @131 + + icsneoSendTextApi @132 + icsneoGetTextApi @133 + icsneoScriptReadISO15765_2_RxMessage @ 134 + icsneoScriptWriteISO15765_2_RxMessage @ 135 + + icsneoScriptLoadReadBin @ 136 + icsneoEnableCoreMiniUsbFilter @ 137 + icsneoConfigureNetworkMsgQueue @ 138 + icsneoEnableBusVoltageMonitor @ 139 + icsneoGetBusVoltage @ 140 + icsneoEnableBitSmash @141 + icsneoDisableBitSmash @142 + icsneoReceiveHWTimeResponse @143 + icsneoSendHWTimeRequest @144 + icsneoSetUSBLatency @145 + icsneoLoadDefaultSettings @146 + icsneoGetAllChipVersions @149 + icsneoSetBitRateEx @ 150 + icsneoScriptGetScriptStatusEx @ 151 + icsneoOpenNeoDeviceByChannels @ 152 + icsneoGetChannelLockStatus @ 153 + icsneoRequestEnterSleepMode @ 154 + icsneoEnableNetworkComEx @ 155 + icsneoLockChannels @ 156 + icsneoUnlockChannels @ 157 + + icsneoGetFireVnetSettings @ 160 + icsneoSetFireVnetSettings @ 161 + + icsneoGetFire2Settings @ 162 + icsneoSetFire2Settings @ 163 + icsneoSetFDBitRate @ 164 + + icsneoTxMessagesEx @165 + + icsneoGetVCANRFSettings @ 167 + icsneoSetVCANRFSettings @ 168 + + icsneoFirmwareUpdateRequired @ 169 + + icsneoGetRADGalaxySettings @170 + icsneoSetRADGalaxySettings @171 + + icsneoGetNetidforSlaveVNETs @172 + icsneoGetVnetSimpleNetid @173 + icsneoISO15765_ReceiveMessage @174 + icsneoGetDLLFirmwareInfoEx @175 + icsneoBase36enc @176 + icsneoGetRADStar2Settings @177 + icsneoSetRADStar2Settings @178 + + icsneoGetBackupPowerEnabled @179 + icsneoSetBackupPowerEnabled @180 + icsneoGetBackupPowerReady @181 + icsneoSerialNumberFromString @182 + icsneoSerialNumberToString @183 + icsneoISO15765_TransmitMessageEx @184 + + icsneoGetActiveVNETChannel @ 189 + icsneoSetActiveVNETChannel @ 190 + + icsneoGetDeviceSettings @191 + icsneoSetDeviceSettings @192 + icsneoGetDeviceSettingsType @193 + + icsneoGetVCAN412Settings @ 194 + icsneoSetVCAN412Settings @ 195 + + icsneoGetVividCANSettings @ 196 + icsneoSetVividCANSettings @ 197 + icsneoFindNeoDevicesNewStyle @ 198 + + icsneoGetDeviceStatus @ 202 + + icsneoFindDevices @ 203 + icsneoOpenDevice @ 204 + + icsneoEnableDOIPLine @ 205 + icsneoGetMiniportAdapterInfo @ 206 + + icsneoGetVCAN4Settings @ 207 + icsneoSetVCAN4Settings @ 208 + + icsneoReadWritePHYSettings @ 214 + + icsneoRequestDiskDetails @ 217 + icsneoRequestDiskFormat @ 218 + icsneoRequestDiskFormatProgress @ 219 + icsneoRequestDiskFormatCancel @ 220 + + icsneoGetRADGigastarSettings @ 221 + icsneoSetRADGigastarSettings @ 222 + icsneoGetRADA2BSettings @ 223 + icsneoSetRADA2BSettings @ 224 + + icsneoScriptClearRxMessage @225 \ No newline at end of file From 9b2eae4a6c2d6ccf9e443e44a7c1407a265d7b45 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 15:19:40 -0400 Subject: [PATCH 16/17] API: Legacy: Fix icsneoFindDevices --- api/icsneolegacy/icsneolegacy.cpp | 42 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index c44450d..3a16fc7 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -166,25 +166,41 @@ static inline unsigned int GetVnetAgnosticNetid(size_t fullNetid) //Basic Functions int LegacyDLLExport icsneoFindDevices(NeoDeviceEx *devs, int *devCount, unsigned int *devTypes, unsigned int devTypeCount, POptionsFindNeoEx *POptionsFindNeoEx, unsigned int *zero) { + if (!devs) + return 0; + constexpr size_t MAX_DEVICES = 255; NeoDevice Nd[MAX_DEVICES]; int NumDevices = MAX_DEVICES; - size_t Count = 0; + int Count = 0; - icsneoFindNeoDevices(0, Nd, &NumDevices); - - if (NumDevices > 0) - { - for (const auto &element : Nd) - for (auto j = 0; j < devTypeCount; j++) - if (element.DeviceType == devTypes[j]) - devs[Count++].neoDevice = element; - - return 1; - } - else + if (!icsneoFindNeoDevices(0, Nd, &NumDevices)) return 0; + + for (auto i = 0; i < NumDevices; i++) + { + if (devTypes && devTypeCount) + { + for (auto j = 0; j < devTypeCount; j++) + { + if (Nd[i].DeviceType == devTypes[j]) + { + devs[Count++].neoDevice = Nd[i]; + break; + } + } + } + else + { + devs[Count++].neoDevice = Nd[i]; + } + } + + if (devCount) + *devCount = Count; + + return NumDevices > 0; } int LegacyDLLExport icsneoFindNeoDevices(unsigned long DeviceTypes, NeoDevice *pNeoDevice, int *pNumDevices) From 4588cb55fab3b58659390bd09b418bab427c369a Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Fri, 11 Jun 2021 15:20:41 -0400 Subject: [PATCH 17/17] POSIX: DynamicLib: Force visibility of exports in case of -fvisibility=hidden --- include/icsneo/platform/posix/dynamiclib.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/icsneo/platform/posix/dynamiclib.h b/include/icsneo/platform/posix/dynamiclib.h index cdfb896..6673b17 100644 --- a/include/icsneo/platform/posix/dynamiclib.h +++ b/include/icsneo/platform/posix/dynamiclib.h @@ -9,8 +9,7 @@ #include "icsneo/platform/posix/linux/dynamiclib.h" #endif -// Nothing special is needed to export -#define DLLExport +#define DLLExport __attribute__((visibility("default"))) #define LegacyDLLExport DLLExport // #ifndef ICSNEO_NO_AUTO_DESTRUCT