Merge branch 'master' of Lustra:InfiniteWalrus/libicsneo

pull/4/head
Paul Hollinsky 2018-10-25 13:55:41 -04:00
commit 7e6282a7ad
6 changed files with 406 additions and 204 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -1,9 +1,15 @@
#ifndef __NETWORKID_H_
#define __NETWORKID_H_
#ifndef __cplusplus
#define CONSTEXPR const
#else
#include <cstdint>
#include <ostream>
#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

View File

@ -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();

View File

@ -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 <stdint.h>
#define CONSTEXPR const
typedef uint32_t devicetype_t;
#else
#include <ostream>
#include <cstdint>
#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

View File

@ -1,194 +1,201 @@
#ifndef __ICSNEOC_H_
#define __ICSNEOC_H_
#include <stddef.h>
#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 <stddef.h>
#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
#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_