From 95dce1c429a15ae6f2a393fca3790ea0afac0779 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Wed, 24 Oct 2018 12:51:04 -0400 Subject: [PATCH 1/2] Device describe --- api/icsneoc/icsneoc.cpp | 9 + device/device.cpp | 6 + include/icsneo/device/device.h | 5 + include/icsneo/icsneoc.h | 392 +++++++++++++++++---------------- 4 files changed, 219 insertions(+), 193 deletions(-) diff --git a/api/icsneoc/icsneoc.cpp b/api/icsneoc/icsneoc.cpp index 8bf6552..8114f76 100644 --- a/api/icsneoc/icsneoc.cpp +++ b/api/icsneoc/icsneoc.cpp @@ -268,4 +268,13 @@ bool icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* mess return false; } return true; +} + +bool icsneo_describeDevice(const neodevice_t* device, char* str, size_t* maxLength) { + if(!icsneo_isValidNeoDevice(device)) + return false; + + *maxLength = device->device->describe().copy(str, *maxLength); + str[*maxLength] = '\0'; + return true; } \ No newline at end of file diff --git a/device/device.cpp b/device/device.cpp index 71d3df5..d9e5631 100644 --- a/device/device.cpp +++ b/device/device.cpp @@ -67,6 +67,12 @@ bool Device::SerialStringIsNumeric(const std::string& serial) { return isdigit(serial[0]) && isdigit(serial[1]); } +std::string Device::describe() const { + std::stringstream ss; + ss << getType() << ' ' << getSerial(); + return ss.str(); +} + void Device::enableMessagePolling() { if(messagePollingCallbackID != 0) // We are already polling return; diff --git a/include/icsneo/device/device.h b/include/icsneo/device/device.h index d6bb2e5..aab882f 100644 --- a/include/icsneo/device/device.h +++ b/include/icsneo/device/device.h @@ -37,6 +37,11 @@ public: std::string getSerial() const { return data.serial; } uint32_t getSerialNumber() const { return Device::SerialStringToNum(getSerial()); } const neodevice_t& getNeoDevice() const { return data; } + std::string describe() const; + friend std::ostream& operator<<(std::ostream& os, const Device& device) { + os << device.describe(); + return os; + } virtual bool open(); virtual bool close(); diff --git a/include/icsneo/icsneoc.h b/include/icsneo/icsneoc.h index 927af37..6835f5d 100644 --- a/include/icsneo/icsneoc.h +++ b/include/icsneo/icsneoc.h @@ -1,194 +1,200 @@ -#ifndef __ICSNEOC_H_ -#define __ICSNEOC_H_ - -#include -#include "icsneo/device/neodevice.h" // For neodevice_t -#include "icsneo/communication/message/neomessage.h" // For neomessage_t and friends -#include "icsneo/platform/dynamiclib.h" // Dynamic library loading and exporting - -#ifndef ICSNEOC_DYNAMICLOAD - -#ifdef __cplusplus -extern "C" { -#endif - -extern void DLLExport icsneo_findAllDevices(neodevice_t* devices, size_t* count); - -extern void DLLExport icsneo_freeUnconnectedDevices(); - -extern bool DLLExport icsneo_serialNumToString(uint32_t num, char* str, size_t* count); - -extern uint32_t DLLExport icsneo_serialStringToNum(const char* str); - -extern bool DLLExport icsneo_isValidNeoDevice(const neodevice_t* device); - -extern bool DLLExport icsneo_openDevice(const neodevice_t* device); - -extern bool DLLExport icsneo_closeDevice(const neodevice_t* device); - -extern bool DLLExport icsneo_goOnline(const neodevice_t* device); - -extern bool DLLExport icsneo_goOffline(const neodevice_t* device); - -extern bool DLLExport icsneo_isOnline(const neodevice_t* device); - -extern bool DLLExport icsneo_enableMessagePolling(const neodevice_t* device); - -extern bool DLLExport icsneo_disableMessagePolling(const neodevice_t* device); - -extern bool DLLExport icsneo_getMessages(const neodevice_t* device, neomessage_t* messages, size_t* items); - -extern size_t DLLExport icsneo_getPollingMessageLimit(const neodevice_t* device); - -extern bool DLLExport icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit); - -extern bool DLLExport icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLength); - -extern bool DLLExport icsneo_settingsRefresh(const neodevice_t* device); - -extern bool DLLExport icsneo_settingsApply(const neodevice_t* device); - -extern bool DLLExport icsneo_settingsApplyTemporary(const neodevice_t* device); - -extern bool DLLExport icsneo_settingsApplyDefaults(const neodevice_t* device); - -extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device); - -extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate); - -extern bool DLLExport icsneo_transmit(const neodevice_t* device, const neomessage_t* message); - -extern bool DLLExport icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // ICSNEOC_DYNAMICLOAD - -typedef void(*fn_icsneo_findAllDevices)(neodevice_t* devices, size_t* count); -fn_icsneo_findAllDevices icsneo_findAllDevices; - -typedef void(*fn_icsneo_freeUnconnectedDevices)(); -fn_icsneo_freeUnconnectedDevices icsneo_freeUnconnectedDevices; - -typedef bool(*fn_icsneo_serialNumToString)(uint32_t num, char* str, size_t* count); -fn_icsneo_serialNumToString icsneo_serialNumToString; - -typedef uint32_t(*fn_icsneo_serialStringToNum)(const char* str); -fn_icsneo_serialStringToNum icsneo_serialStringToNum; - -typedef bool(*fn_icsneo_isValidNeoDevice)(const neodevice_t* device); -fn_icsneo_isValidNeoDevice icsneo_isValidNeoDevice; - -typedef bool(*fn_icsneo_openDevice)(const neodevice_t* device); -fn_icsneo_openDevice icsneo_openDevice; - -typedef bool(*fn_icsneo_closeDevice)(const neodevice_t* device); -fn_icsneo_closeDevice icsneo_closeDevice; - -typedef bool(*fn_icsneo_goOnline)(const neodevice_t* device); -fn_icsneo_goOnline icsneo_goOnline; - -typedef bool(*fn_icsneo_goOffline)(const neodevice_t* device); -fn_icsneo_goOffline icsneo_goOffline; - -typedef bool(*fn_icsneo_isOnline)(const neodevice_t* device); -fn_icsneo_isOnline icsneo_isOnline; - -typedef bool(*fn_icsneo_enableMessagePolling)(const neodevice_t* device); -fn_icsneo_enableMessagePolling icsneo_enableMessagePolling; - -typedef bool(*fn_icsneo_disableMessagePolling)(const neodevice_t* device); -fn_icsneo_disableMessagePolling icsneo_disableMessagePolling; - -typedef bool(*fn_icsneo_getMessages)(const neodevice_t* device, neomessage_t* messages, size_t* items); -fn_icsneo_getMessages icsneo_getMessages; - -typedef size_t(*fn_icsneo_getPollingMessageLimit)(const neodevice_t* device); -fn_icsneo_getPollingMessageLimit icsneo_getPollingMessageLimit; - -typedef bool(*fn_icsneo_setPollingMessageLimit)(const neodevice_t* device, size_t newLimit); -fn_icsneo_setPollingMessageLimit icsneo_setPollingMessageLimit; - -typedef bool(*fn_icsneo_getProductName)(const neodevice_t* device, char* str, size_t* maxLength); -fn_icsneo_getProductName icsneo_getProductName; - -typedef bool(*fn_icsneo_settingsRefresh)(const neodevice_t* device); -fn_icsneo_settingsRefresh icsneo_settingsRefresh; - -typedef bool(*fn_icsneo_settingsApply)(const neodevice_t* device); -fn_icsneo_settingsApply icsneo_settingsApply; - -typedef bool(*fn_icsneo_settingsApplyTemporary)(const neodevice_t* device); -fn_icsneo_settingsApplyTemporary icsneo_settingsApplyTemporary; - -typedef bool(*fn_icsneo_settingsApplyDefaults)(const neodevice_t* device); -fn_icsneo_settingsApplyDefaults icsneo_settingsApplyDefaults; - -typedef bool(*fn_icsneo_settingsApplyDefaultsTemporary)(const neodevice_t* device); -fn_icsneo_settingsApplyDefaultsTemporary icsneo_settingsApplyDefaultsTemporary; - -typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate); -fn_icsneo_setBaudrate icsneo_setBaudrate; - -typedef bool(*fn_icsneo_transmit)(const neodevice_t* device, const neomessage_t* message); -fn_icsneo_transmit icsneo_transmit; - -typedef bool(*fn_icsneo_transmitMessages)(const neodevice_t* device, const neomessage_t* messages, size_t count); -fn_icsneo_transmitMessages icsneo_transmitMessages; - -#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func) -#define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3 -void* icsneo_libraryHandle = NULL; -bool icsneo_initialized = false; -bool icsneo_destroyed = false; -int icsneo_init() { - icsneo_destroyed = false; - if(icsneo_initialized) - return 1; - - icsneo_libraryHandle = icsneo_dynamicLibraryLoad(); - if(icsneo_libraryHandle == NULL) - return 2; - - ICSNEO_IMPORTASSERT(icsneo_findAllDevices); - ICSNEO_IMPORTASSERT(icsneo_freeUnconnectedDevices); - ICSNEO_IMPORTASSERT(icsneo_serialNumToString); - ICSNEO_IMPORTASSERT(icsneo_serialStringToNum); - ICSNEO_IMPORTASSERT(icsneo_isValidNeoDevice); - ICSNEO_IMPORTASSERT(icsneo_openDevice); - ICSNEO_IMPORTASSERT(icsneo_closeDevice); - ICSNEO_IMPORTASSERT(icsneo_goOnline); - ICSNEO_IMPORTASSERT(icsneo_goOffline); - ICSNEO_IMPORTASSERT(icsneo_isOnline); - ICSNEO_IMPORTASSERT(icsneo_enableMessagePolling); - ICSNEO_IMPORTASSERT(icsneo_disableMessagePolling); - ICSNEO_IMPORTASSERT(icsneo_getMessages); - ICSNEO_IMPORTASSERT(icsneo_getPollingMessageLimit); - ICSNEO_IMPORTASSERT(icsneo_setPollingMessageLimit); - ICSNEO_IMPORTASSERT(icsneo_getProductName); - ICSNEO_IMPORTASSERT(icsneo_settingsRefresh); - ICSNEO_IMPORTASSERT(icsneo_settingsApply); - ICSNEO_IMPORTASSERT(icsneo_settingsApplyTemporary); - ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults); - ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary); - ICSNEO_IMPORTASSERT(icsneo_setBaudrate); - ICSNEO_IMPORTASSERT(icsneo_transmit); - ICSNEO_IMPORTASSERT(icsneo_transmitMessages); - - icsneo_initialized = true; - return 0; -} - -bool icsneo_close() ICSNEO_DESTRUCTOR { - icsneo_initialized = false; - if(icsneo_destroyed) - return true; - - return icsneo_destroyed = icsneo_dynamicLibraryClose(icsneo_libraryHandle); -} - -#endif // ICSNEOC_DYNAMICLOAD - +#ifndef __ICSNEOC_H_ +#define __ICSNEOC_H_ + +#include +#include "icsneo/device/neodevice.h" // For neodevice_t +#include "icsneo/communication/message/neomessage.h" // For neomessage_t and friends +#include "icsneo/platform/dynamiclib.h" // Dynamic library loading and exporting + +#ifndef ICSNEOC_DYNAMICLOAD + +#ifdef __cplusplus +extern "C" { +#endif + +extern void DLLExport icsneo_findAllDevices(neodevice_t* devices, size_t* count); + +extern void DLLExport icsneo_freeUnconnectedDevices(); + +extern bool DLLExport icsneo_serialNumToString(uint32_t num, char* str, size_t* count); + +extern uint32_t DLLExport icsneo_serialStringToNum(const char* str); + +extern bool DLLExport icsneo_isValidNeoDevice(const neodevice_t* device); + +extern bool DLLExport icsneo_openDevice(const neodevice_t* device); + +extern bool DLLExport icsneo_closeDevice(const neodevice_t* device); + +extern bool DLLExport icsneo_goOnline(const neodevice_t* device); + +extern bool DLLExport icsneo_goOffline(const neodevice_t* device); + +extern bool DLLExport icsneo_isOnline(const neodevice_t* device); + +extern bool DLLExport icsneo_enableMessagePolling(const neodevice_t* device); + +extern bool DLLExport icsneo_disableMessagePolling(const neodevice_t* device); + +extern bool DLLExport icsneo_getMessages(const neodevice_t* device, neomessage_t* messages, size_t* items); + +extern size_t DLLExport icsneo_getPollingMessageLimit(const neodevice_t* device); + +extern bool DLLExport icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit); + +extern bool DLLExport icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLength); + +extern bool DLLExport icsneo_settingsRefresh(const neodevice_t* device); + +extern bool DLLExport icsneo_settingsApply(const neodevice_t* device); + +extern bool DLLExport icsneo_settingsApplyTemporary(const neodevice_t* device); + +extern bool DLLExport icsneo_settingsApplyDefaults(const neodevice_t* device); + +extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device); + +extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate); + +extern bool DLLExport icsneo_transmit(const neodevice_t* device, const neomessage_t* message); + +extern bool DLLExport icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count); + +extern bool DLLExport icsneo_describeDevice(const neodevice_t* device, char* str, size_t* maxLength); + +#ifdef __cplusplus +} // extern "C" +#endif + +#else // ICSNEOC_DYNAMICLOAD + +typedef void(*fn_icsneo_findAllDevices)(neodevice_t* devices, size_t* count); +fn_icsneo_findAllDevices icsneo_findAllDevices; + +typedef void(*fn_icsneo_freeUnconnectedDevices)(); +fn_icsneo_freeUnconnectedDevices icsneo_freeUnconnectedDevices; + +typedef bool(*fn_icsneo_serialNumToString)(uint32_t num, char* str, size_t* count); +fn_icsneo_serialNumToString icsneo_serialNumToString; + +typedef uint32_t(*fn_icsneo_serialStringToNum)(const char* str); +fn_icsneo_serialStringToNum icsneo_serialStringToNum; + +typedef bool(*fn_icsneo_isValidNeoDevice)(const neodevice_t* device); +fn_icsneo_isValidNeoDevice icsneo_isValidNeoDevice; + +typedef bool(*fn_icsneo_openDevice)(const neodevice_t* device); +fn_icsneo_openDevice icsneo_openDevice; + +typedef bool(*fn_icsneo_closeDevice)(const neodevice_t* device); +fn_icsneo_closeDevice icsneo_closeDevice; + +typedef bool(*fn_icsneo_goOnline)(const neodevice_t* device); +fn_icsneo_goOnline icsneo_goOnline; + +typedef bool(*fn_icsneo_goOffline)(const neodevice_t* device); +fn_icsneo_goOffline icsneo_goOffline; + +typedef bool(*fn_icsneo_isOnline)(const neodevice_t* device); +fn_icsneo_isOnline icsneo_isOnline; + +typedef bool(*fn_icsneo_enableMessagePolling)(const neodevice_t* device); +fn_icsneo_enableMessagePolling icsneo_enableMessagePolling; + +typedef bool(*fn_icsneo_disableMessagePolling)(const neodevice_t* device); +fn_icsneo_disableMessagePolling icsneo_disableMessagePolling; + +typedef bool(*fn_icsneo_getMessages)(const neodevice_t* device, neomessage_t* messages, size_t* items); +fn_icsneo_getMessages icsneo_getMessages; + +typedef size_t(*fn_icsneo_getPollingMessageLimit)(const neodevice_t* device); +fn_icsneo_getPollingMessageLimit icsneo_getPollingMessageLimit; + +typedef bool(*fn_icsneo_setPollingMessageLimit)(const neodevice_t* device, size_t newLimit); +fn_icsneo_setPollingMessageLimit icsneo_setPollingMessageLimit; + +typedef bool(*fn_icsneo_getProductName)(const neodevice_t* device, char* str, size_t* maxLength); +fn_icsneo_getProductName icsneo_getProductName; + +typedef bool(*fn_icsneo_settingsRefresh)(const neodevice_t* device); +fn_icsneo_settingsRefresh icsneo_settingsRefresh; + +typedef bool(*fn_icsneo_settingsApply)(const neodevice_t* device); +fn_icsneo_settingsApply icsneo_settingsApply; + +typedef bool(*fn_icsneo_settingsApplyTemporary)(const neodevice_t* device); +fn_icsneo_settingsApplyTemporary icsneo_settingsApplyTemporary; + +typedef bool(*fn_icsneo_settingsApplyDefaults)(const neodevice_t* device); +fn_icsneo_settingsApplyDefaults icsneo_settingsApplyDefaults; + +typedef bool(*fn_icsneo_settingsApplyDefaultsTemporary)(const neodevice_t* device); +fn_icsneo_settingsApplyDefaultsTemporary icsneo_settingsApplyDefaultsTemporary; + +typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate); +fn_icsneo_setBaudrate icsneo_setBaudrate; + +typedef bool(*fn_icsneo_transmit)(const neodevice_t* device, const neomessage_t* message); +fn_icsneo_transmit icsneo_transmit; + +typedef bool(*fn_icsneo_transmitMessages)(const neodevice_t* device, const neomessage_t* messages, size_t count); +fn_icsneo_transmitMessages icsneo_transmitMessages; + +typedef bool(*fn_icsneo_describeDevice)(const neodevice_t* device, char* str, size_t* maxLength); +fn_icsneo_describeDevice icsneo_describeDevice; + +#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func) +#define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3 +void* icsneo_libraryHandle = NULL; +bool icsneo_initialized = false; +bool icsneo_destroyed = false; +int icsneo_init() { + icsneo_destroyed = false; + if(icsneo_initialized) + return 1; + + icsneo_libraryHandle = icsneo_dynamicLibraryLoad(); + if(icsneo_libraryHandle == NULL) + return 2; + + ICSNEO_IMPORTASSERT(icsneo_findAllDevices); + ICSNEO_IMPORTASSERT(icsneo_freeUnconnectedDevices); + ICSNEO_IMPORTASSERT(icsneo_serialNumToString); + ICSNEO_IMPORTASSERT(icsneo_serialStringToNum); + ICSNEO_IMPORTASSERT(icsneo_isValidNeoDevice); + ICSNEO_IMPORTASSERT(icsneo_openDevice); + ICSNEO_IMPORTASSERT(icsneo_closeDevice); + ICSNEO_IMPORTASSERT(icsneo_goOnline); + ICSNEO_IMPORTASSERT(icsneo_goOffline); + ICSNEO_IMPORTASSERT(icsneo_isOnline); + ICSNEO_IMPORTASSERT(icsneo_enableMessagePolling); + ICSNEO_IMPORTASSERT(icsneo_disableMessagePolling); + ICSNEO_IMPORTASSERT(icsneo_getMessages); + ICSNEO_IMPORTASSERT(icsneo_getPollingMessageLimit); + ICSNEO_IMPORTASSERT(icsneo_setPollingMessageLimit); + ICSNEO_IMPORTASSERT(icsneo_getProductName); + ICSNEO_IMPORTASSERT(icsneo_settingsRefresh); + ICSNEO_IMPORTASSERT(icsneo_settingsApply); + ICSNEO_IMPORTASSERT(icsneo_settingsApplyTemporary); + ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults); + ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary); + ICSNEO_IMPORTASSERT(icsneo_setBaudrate); + ICSNEO_IMPORTASSERT(icsneo_transmit); + ICSNEO_IMPORTASSERT(icsneo_transmitMessages); + ICSNEO_IMPORTASSERT(icsneo_describeDevice); + + icsneo_initialized = true; + return 0; +} + +bool icsneo_close() ICSNEO_DESTRUCTOR { + icsneo_initialized = false; + if(icsneo_destroyed) + return true; + + return icsneo_destroyed = icsneo_dynamicLibraryClose(icsneo_libraryHandle); +} + +#endif // ICSNEOC_DYNAMICLOAD + #endif // __ICSNEOC_H_ \ No newline at end of file From 807518fbaea41f8c13f4d0b7a115820805194c9f Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Wed, 24 Oct 2018 12:53:58 -0400 Subject: [PATCH 2/2] Network and device type constant definitions --- include/icsneo/communication/network.h | 146 +++++++++++++++++++++++-- include/icsneo/device/devicetype.h | 51 ++++++++- include/icsneo/icsneoc.h | 1 + 3 files changed, 187 insertions(+), 11 deletions(-) diff --git a/include/icsneo/communication/network.h b/include/icsneo/communication/network.h index b6dbd71..1c75404 100644 --- a/include/icsneo/communication/network.h +++ b/include/icsneo/communication/network.h @@ -1,9 +1,15 @@ #ifndef __NETWORKID_H_ #define __NETWORKID_H_ +#ifndef __cplusplus +#define CONSTEXPR const +#else + #include #include +#define CONSTEXPR constexpr + namespace icsneo { class Network { @@ -115,16 +121,16 @@ public: Any = 0xfffe, // Never actually set as type, but used as flag for filtering Invalid = 0xffff }; - enum class Type { - Invalid, - Internal, // Used for statuses that don't actually need to be transferred to the client application - CAN, - LIN, - FlexRay, - MOST, - Ethernet, - Other, - Any // Never actually set as type, but used as flag for filtering + enum class Type : uint8_t { + Invalid = 0, + Internal = 1, // Used for statuses that don't actually need to be transferred to the client application + CAN = 2, + LIN = 3, + FlexRay = 4, + MOST = 5, + Ethernet = 6, + Any = 0xFE, // Never actually set as type, but used as flag for filtering + Other = 0xFF }; static const char* GetTypeString(Type type) { switch(type) { @@ -412,4 +418,124 @@ private: } +#endif + +#ifdef __ICSNEOC_H_ +CONSTEXPR uint16_t ICSNEO_NETID_DEVICE = 0; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN = 1; +CONSTEXPR uint16_t ICSNEO_NETID_MSCAN = 2; +CONSTEXPR uint16_t ICSNEO_NETID_SWCAN = 3; +CONSTEXPR uint16_t ICSNEO_NETID_LSFTCAN = 4; +CONSTEXPR uint16_t ICSNEO_NETID_FORDSCP = 5; +CONSTEXPR uint16_t ICSNEO_NETID_J1708 = 6; +CONSTEXPR uint16_t ICSNEO_NETID_AUX = 7; +CONSTEXPR uint16_t ICSNEO_NETID_J1850VPW = 8; +CONSTEXPR uint16_t ICSNEO_NETID_ISO = 9; +CONSTEXPR uint16_t ICSNEO_NETID_ISOPIC = 10; +CONSTEXPR uint16_t ICSNEO_NETID_MAIN51 = 11; +CONSTEXPR uint16_t ICSNEO_NETID_RED = 12; +CONSTEXPR uint16_t ICSNEO_NETID_SCI = 13; +CONSTEXPR uint16_t ICSNEO_NETID_ISO2 = 14; +CONSTEXPR uint16_t ICSNEO_NETID_ISO14230 = 15; +CONSTEXPR uint16_t ICSNEO_NETID_LIN = 16; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET1 = 17; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET2 = 18; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET3 = 19; + +// START Device Command Returns +// When we send a command, the device returns on one of these, depending on command +CONSTEXPR uint16_t ICSNEO_NETID_RED_EXT_MEMORYREAD = 20; +CONSTEXPR uint16_t ICSNEO_NETID_RED_INT_MEMORYREAD = 21; +CONSTEXPR uint16_t ICSNEO_NETID_RED_DFLASH_READ = 22; +CONSTEXPR uint16_t ICSNEO_NETID_RED_SDCARD_READ = 23; +CONSTEXPR uint16_t ICSNEO_NETID_CAN_ERRBITS = 24; +CONSTEXPR uint16_t ICSNEO_NETID_RED_DFLASH_WRITE_DONE = 25; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_CAN1_LOGICAL = 26; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_CAN2_LOGICAL = 27; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_LIN1_LOGICAL = 28; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_LIN2_LOGICAL = 29; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_LIN1_ANALOG = 30; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_LIN2_ANALOG = 31; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_MISC_ANALOG = 32; +CONSTEXPR uint16_t ICSNEO_NETID_RED_WAVE_MISCDIO2_LOGICAL = 33; +CONSTEXPR uint16_t ICSNEO_NETID_RED_NETWORK_COM_ENABLE_EX = 34; +CONSTEXPR uint16_t ICSNEO_NETID_RED_NEOVI_NETWORK = 35; +CONSTEXPR uint16_t ICSNEO_NETID_RED_READ_BAUD_SETTINGS = 36; +CONSTEXPR uint16_t ICSNEO_NETID_RED_OLDFORMAT = 37; +CONSTEXPR uint16_t ICSNEO_NETID_RED_SCOPE_CAPTURE = 38; +CONSTEXPR uint16_t ICSNEO_NETID_RED_HARDWARE_EXCEP = 39; +CONSTEXPR uint16_t ICSNEO_NETID_RED_GET_RTC = 40; +// END Device Command Returns + +CONSTEXPR uint16_t ICSNEO_NETID_ISO3 = 41; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN2 = 42; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN3 = 44; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET4 = 45; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET5 = 46; +CONSTEXPR uint16_t ICSNEO_NETID_ISO4 = 47; +CONSTEXPR uint16_t ICSNEO_NETID_LIN2 = 48; +CONSTEXPR uint16_t ICSNEO_NETID_LIN3 = 49; +CONSTEXPR uint16_t ICSNEO_NETID_LIN4 = 50; +//CONSTEXPR uint16_t ICSNEO_NETID_MOST = 51; Old and unused +CONSTEXPR uint16_t ICSNEO_NETID_RED_APP_ERROR = 52; +CONSTEXPR uint16_t ICSNEO_NETID_CGI = 53; +CONSTEXPR uint16_t ICSNEO_NETID_RESET_STATUS = 54; +CONSTEXPR uint16_t ICSNEO_NETID_FB_STATUS = 55; +CONSTEXPR uint16_t ICSNEO_NETID_APP_SIGNAL_STATUS = 56; +CONSTEXPR uint16_t ICSNEO_NETID_READ_DATALINK_CM_TX_MSG = 57; +CONSTEXPR uint16_t ICSNEO_NETID_READ_DATALINK_CM_RX_MSG = 58; +CONSTEXPR uint16_t ICSNEO_NETID_LOGGING_OVERFLOW = 59; +CONSTEXPR uint16_t ICSNEO_NETID_READ_SETTINGS_EX = 60; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN4 = 61; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN5 = 62; +CONSTEXPR uint16_t ICSNEO_NETID_RS232 = 63; +CONSTEXPR uint16_t ICSNEO_NETID_UART = 64; +CONSTEXPR uint16_t ICSNEO_NETID_UART2 = 65; +CONSTEXPR uint16_t ICSNEO_NETID_UART3 = 66; +CONSTEXPR uint16_t ICSNEO_NETID_UART4 = 67; +CONSTEXPR uint16_t ICSNEO_NETID_SWCAN2 = 68; +CONSTEXPR uint16_t ICSNEO_NETID_ETHERNET_DAQ = 69; +CONSTEXPR uint16_t ICSNEO_NETID_DATA_TO_HOST = 70; +CONSTEXPR uint16_t ICSNEO_NETID_TEXTAPI_TO_HOST = 71; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET6 = 73; +CONSTEXPR uint16_t ICSNEO_NETID_RED_VBAT = 74; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET7 = 75; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET8 = 76; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET9 = 77; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET10 = 78; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET11 = 79; +CONSTEXPR uint16_t ICSNEO_NETID_FLEXRAY1A = 80; +CONSTEXPR uint16_t ICSNEO_NETID_FLEXRAY1B = 81; +CONSTEXPR uint16_t ICSNEO_NETID_FLEXRAY2A = 82; +CONSTEXPR uint16_t ICSNEO_NETID_FLEXRAY2B = 83; +CONSTEXPR uint16_t ICSNEO_NETID_LIN5 = 84; +CONSTEXPR uint16_t ICSNEO_NETID_FLEXRAY = 85; +CONSTEXPR uint16_t ICSNEO_NETID_FLEXRAY2 = 86; +CONSTEXPR uint16_t ICSNEO_NETID_OP_ETHERNET12 = 87; +CONSTEXPR uint16_t ICSNEO_NETID_MOST25 = 90; +CONSTEXPR uint16_t ICSNEO_NETID_MOST50 = 91; +CONSTEXPR uint16_t ICSNEO_NETID_MOST150 = 92; +CONSTEXPR uint16_t ICSNEO_NETID_ETHERNET = 93; +CONSTEXPR uint16_t ICSNEO_NETID_GMFSA = 94; +CONSTEXPR uint16_t ICSNEO_NETID_TCP = 95; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN6 = 96; +CONSTEXPR uint16_t ICSNEO_NETID_HSCAN7 = 97; +CONSTEXPR uint16_t ICSNEO_NETID_LIN6 = 98; +CONSTEXPR uint16_t ICSNEO_NETID_LSFTCAN2 = 99; +CONSTEXPR uint16_t ICSNEO_NETID_HW_COM_LATENCY_TEST = 512; +CONSTEXPR uint16_t ICSNEO_NETID_DEVICE_STATUS = 513; +CONSTEXPR uint16_t ICSNEO_NETID_ANY = 0xfffe; // Never actually set as type, but used as flag for filtering +CONSTEXPR uint16_t ICSNEO_NETID_INVALID = 0xffff; + +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_INVALID = 0; +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_INTERNAL = 1; // Used for statuses that don't actually need to be transferred to the client application +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_CAN = 2; +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_LIN = 3; +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_FLEXRAY = 4; +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_MOST = 5; +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_ETHERNET = 6; +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_ANY = 0xFE; // Never actually set as type, but used as flag for filtering +CONSTEXPR uint8_t ICSNEO_NETWORK_TYPE_OTHER = 0xFF; +#endif + #endif \ No newline at end of file diff --git a/include/icsneo/device/devicetype.h b/include/icsneo/device/devicetype.h index 6429a9d..eb72501 100644 --- a/include/icsneo/device/devicetype.h +++ b/include/icsneo/device/devicetype.h @@ -3,15 +3,21 @@ // Hold the length of the longest name, so that C applications can allocate memory accordingly // Currently the longest is "Intrepid Ethernet Evaluation Board" -#define DEVICE_TYPE_LONGEST_NAME (35 + 1) // Add 1 so that if someone forgets, they still have space for null terminator +#define ICSNEO_DEVICETYPE_LONGEST_NAME (35 + 1) // Add 1 so that if someone forgets, they still have space for null terminator +#define ICSNEO_DEVICETYPE_LONGEST_DESCRIPTION (ICSNEO_DEVICETYPE_LONGEST_NAME + 7) // 6 character serial, plus space #ifndef __cplusplus #include + +#define CONSTEXPR const + typedef uint32_t devicetype_t; #else #include #include +#define CONSTEXPR constexpr + typedef uint32_t devicetype_t; namespace icsneo { @@ -19,6 +25,7 @@ namespace icsneo { class DeviceType { public: // This enum used to be a bitfield, but has since become an enum as we have more than 32 devices + // Adding something? Make sure you update the type string and C-compatible defines below! enum Enum : devicetype_t { Unknown = (0x00000000), BLUE = (0x00000001), @@ -161,4 +168,46 @@ private: #endif // __cplusplus +#ifdef __ICSNEOC_H_ // We are using the C API, so we want C-compatible defines +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_UNKNOWN = 0x00000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_BLUE = 0x00000001; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_ECU_AVB = 0x00000002; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADSUPERMOON = 0x00000003; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_DW_VCAN = 0x00000004; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADMOON2 = 0x00000005; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADGIGALOG = 0x00000006; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VCAN4_1 = 0x00000007; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_FIRE = 0x00000008; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADPLUTO = 0x00000009; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VCAN4_2EL = 0x0000000a; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADIO_CANHUB = 0x0000000b; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VCAN3 = 0x00000010; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RED = 0x00000040; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_ECU = 0x00000080; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_IEVB = 0x00000100; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_PENDANT = 0x00000200; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_OBD2_PRO = 0x00000400; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_ECUCHIP_UART = 0x00000800; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_PLASMA = 0x00001000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_DONT_REUSE0 = 0x00002000; // Previously FIRE_VNET +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_NEOANALOG = 0x00004000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_CT_OBD = 0x00008000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_DONT_REUSE1 = 0x00010000; // Previously PLASMA_1_12 +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_DONT_REUSE2 = 0x00020000; // Previously PLASMA_1_13 +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_ION = 0x00040000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADSTAR = 0x00080000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_DONT_REUSE3 = 0x00100000; // Previously ION3 +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VCAN4_4 = 0x00200000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VCAN4_2 = 0x00400000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_CMPROBE = 0x00800000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_EEVB = 0x01000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VCANRF = 0x02000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_FIRE2 = 0x04000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_FLEX = 0x08000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADGALAXY = 0x10000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_RADSTAR2 = 0x20000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_VIVIDCAN = 0x40000000; +CONSTEXPR devicetype_t ICSNEO_DEVICETYPE_OBD2_SIM = 0x80000000; +#endif + #endif \ No newline at end of file diff --git a/include/icsneo/icsneoc.h b/include/icsneo/icsneoc.h index 6835f5d..bb8a38c 100644 --- a/include/icsneo/icsneoc.h +++ b/include/icsneo/icsneoc.h @@ -5,6 +5,7 @@ #include "icsneo/device/neodevice.h" // For neodevice_t #include "icsneo/communication/message/neomessage.h" // For neomessage_t and friends #include "icsneo/platform/dynamiclib.h" // Dynamic library loading and exporting +#include "icsneo/communication/network.h" // Network type and netID defines #ifndef ICSNEOC_DYNAMICLOAD