icsneolegacy: implemented getDeviceStatus in C and legacy
-Added missing DLL asserts for getRTC() and setRTC() in icsneoc.hpull/56/head
parent
1e773ba9ab
commit
f907d6759f
|
|
@ -714,3 +714,30 @@ bool icsneo_setRTC(const neodevice_t* device, uint64_t input)
|
|||
const std::chrono::system_clock::time_point time(duration);
|
||||
return device->device->setRTC(time);
|
||||
}
|
||||
|
||||
int icsneo_getDeviceStatus(const neodevice_t* device, void* status, size_t* size) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
if(status == nullptr || size == nullptr)
|
||||
return false;
|
||||
|
||||
std::shared_ptr<Message> msg = device->device->com->waitForMessageSync([&]() {
|
||||
return device->device->com->sendCommand(Command::RequestStatusUpdate);
|
||||
}, std::make_shared<MessageFilter>(Network::NetID::DeviceStatus), std::chrono::milliseconds(100));
|
||||
|
||||
if(!msg) // Did not receive a message
|
||||
return false;
|
||||
|
||||
auto rawMessage = std::static_pointer_cast<RawMessage>(msg);
|
||||
if(!rawMessage || (rawMessage->network.getNetID() != Network::NetID::DeviceStatus))
|
||||
return false;
|
||||
|
||||
if(*size < rawMessage->data.size())
|
||||
return false;
|
||||
|
||||
std::copy(rawMessage->data.begin(), rawMessage->data.end(), static_cast<uint8_t*>(status));
|
||||
*size = rawMessage->data.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -912,6 +912,18 @@ int LegacyDLLExport icsneoStopSockServer(void* hObject)
|
|||
return false;
|
||||
}
|
||||
|
||||
int LegacyDLLExport icsneoGetDeviceStatus(void* hObject, icsDeviceStatus* deviceStatus, size_t* deviceStatusSize)
|
||||
{
|
||||
if (!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
|
||||
|
||||
if (deviceStatus == nullptr || deviceStatusSize == nullptr)
|
||||
return false;
|
||||
|
||||
return icsneo_getDeviceStatus(device, deviceStatus, deviceStatusSize);
|
||||
}
|
||||
|
||||
//CoreMini Script functions
|
||||
int LegacyDLLExport icsneoScriptStart(void* hObject, int iLocation)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2416,24 +2416,110 @@ typedef struct _icsSpyMessageVSB
|
|||
m.NetworkID2 = X >> 8; \
|
||||
} while (0)
|
||||
|
||||
#define RADJUPITER_NUM_PORTS 8
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
typedef struct _ethernetNetworkStatus_t
|
||||
{
|
||||
uint16_t networkId;
|
||||
uint8_t linkStatus;
|
||||
uint8_t linkFullDuplex;
|
||||
uint8_t linkSpeed; // see ethLinkSpeed
|
||||
uint8_t linkMode; // for automotive networks - see opEthLinkMode
|
||||
} ethernetNetworkStatus_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t backupPowerGood;
|
||||
uint8_t backupPowerEnabled;
|
||||
uint8_t usbHostPowerEnabled;
|
||||
uint8_t ethernetActivationLineEnabled;
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
} icsFire2DeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ethernetActivationLineEnabled;
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
uint8_t unused;
|
||||
} icsFire2VnetDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ethernetActivationLineEnabled;
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
uint8_t unused;
|
||||
} icsVcan4DeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ethernetActivationLineEnabled;
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
uint8_t unused;
|
||||
} icsFlexVnetzDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ethernetActivationLineEnabled;
|
||||
ethernetNetworkStatus_t ethernetStatus[3];
|
||||
uint8_t ethernetActivationLineEnabled_2;
|
||||
} icsFire3DeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus[4];
|
||||
} icsRadMoonDuoDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus[RADJUPITER_NUM_PORTS-1];
|
||||
} icsRadJupiterDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
} icsOBD2ProDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus[4];
|
||||
} icsRadPlutoDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
} icsVcan4IndustrialDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
} icsRadEpsilonDeviceStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ethernetNetworkStatus_t ethernetStatus;
|
||||
} icsRadBMSDeviceStatus;
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(4)
|
||||
|
||||
typedef union {
|
||||
icsFire2DeviceStatus fire2Status;
|
||||
icsVcan4DeviceStatus vcan4Status;
|
||||
icsFlexVnetzDeviceStatus flexVnetzStatus;
|
||||
icsFire3DeviceStatus fire3Status;
|
||||
icsRadMoonDuoDeviceStatus radMoonDuoStatus;
|
||||
icsRadJupiterDeviceStatus jupiterStatus;
|
||||
icsOBD2ProDeviceStatus obd2proStatus;
|
||||
icsRadPlutoDeviceStatus plutoStatus;
|
||||
icsVcan4IndustrialDeviceStatus vcan4indStatus;
|
||||
icsRadBMSDeviceStatus radBMSStatus;
|
||||
} icsDeviceStatus;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int8_t szName[128]; //Adaptor name - ASCII Null terminated
|
||||
|
|
|
|||
|
|
@ -808,6 +808,17 @@ extern bool DLLExport icsneo_isTerminationEnabledFor(const neodevice_t* device,
|
|||
*/
|
||||
extern bool DLLExport icsneo_setTerminationFor(const neodevice_t* device, neonetid_t netid, bool enabled);
|
||||
|
||||
/**
|
||||
* \brief Return the device status structures for a specified device.
|
||||
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||
* \param[in] status A pointer to a device status structure for the current device.
|
||||
* \param[in] size The size of the current device status structure in bytes.
|
||||
* \returns True if the device status was successfully read.
|
||||
*
|
||||
* This function populates the device status structures and sub members.
|
||||
*/
|
||||
extern int icsneo_getDeviceStatus(const neodevice_t* device, void* status, size_t* size);
|
||||
|
||||
/**
|
||||
* \brief Get the real-time clock for the given device.
|
||||
* \param[out] device A pointer to the neodevice_t structure specifying the device to read the RTC from.
|
||||
|
|
@ -997,6 +1008,15 @@ fn_icsneo_isTerminationEnabledFor icsneo_isTerminationEnabledFor;
|
|||
typedef bool(*fn_icsneo_setTerminationFor)(const neodevice_t* device, neonetid_t netid, bool enabled);
|
||||
fn_icsneo_setTerminationFor icsneo_setTerminationFor;
|
||||
|
||||
typedef int (*fn_icsneo_getDeviceStatus)(const neodevice_t* device, void* status, size_t* size);
|
||||
fn_icsneo_getDeviceStatus icsneo_getDeviceStatus;
|
||||
|
||||
typedef bool (*fn_icsneo_getRTC)(const neodevice_t* device, uint64_t* output);
|
||||
fn_icsneo_getRTC icsneo_getRTC;
|
||||
|
||||
typedef bool (*fn_icsneo_setRTC)(const neodevice_t* device, uint64_t input);
|
||||
fn_icsneo_setRTC icsneo_setRTC;
|
||||
|
||||
#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;
|
||||
|
|
@ -1066,6 +1086,9 @@ int icsneo_init() {
|
|||
ICSNEO_IMPORTASSERT(icsneo_canTerminationBeEnabledFor);
|
||||
ICSNEO_IMPORTASSERT(icsneo_isTerminationEnabledFor);
|
||||
ICSNEO_IMPORTASSERT(icsneo_setTerminationFor);
|
||||
ICSNEO_IMPORTASSERT(icsneo_getDeviceStatus);
|
||||
ICSNEO_IMPORTASSERT(icsneo_getRTC);
|
||||
ICSNEO_IMPORTASSERT(icsneo_setRTC);
|
||||
|
||||
icsneo_initialized = true;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ extern unsigned int LegacyDLLExport icsneoGetCANControllerClockFrequency(void* h
|
|||
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);
|
||||
|
||||
extern int LegacyDLLExport icsneoGetDeviceStatus(void* hObject, icsDeviceStatus* deviceStatus, size_t* deviceStatusSize);
|
||||
|
||||
//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);
|
||||
|
|
@ -131,7 +133,7 @@ extern int LegacyDLLExport icsneoScriptGetScriptStatus(void* hObject, int* piSta
|
|||
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)
|
||||
//Deprecated (but still supported in the DLL)
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ EXPORTS
|
|||
; icsneoSetVividCANSettings @ 197
|
||||
; icsneoFindNeoDevicesNewStyle @ 198
|
||||
|
||||
; icsneoGetDeviceStatus @ 202
|
||||
icsneoGetDeviceStatus @ 202
|
||||
|
||||
icsneoFindDevices @ 203
|
||||
icsneoOpenDevice @ 204
|
||||
|
|
|
|||
Loading…
Reference in New Issue