Device: Add isOnlineSupported()

pull/64/head
Kyle Schwarz 2024-02-13 21:24:51 +00:00 committed by Kyle Johannes
parent 3264a1ecbe
commit 4782e26bed
8 changed files with 59 additions and 11 deletions

View File

@ -740,4 +740,11 @@ int icsneo_getDeviceStatus(const neodevice_t* device, void* status, size_t* size
*size = rawMessage->data.size(); *size = rawMessage->data.size();
return true; return true;
} }
bool icsneo_isOnlineSupported(const neodevice_t* device) {
if(!icsneo_isValidNeoDevice(device))
return false;
return device->device->isOnlineSupported();
}

View File

@ -417,8 +417,19 @@ int LegacyDLLExport icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, u
*hObject = device; *hObject = device;
if (!icsneo_openDevice(device)) if (!icsneo_openDevice(device))
return false; return false;
return icsneo_setPollingMessageLimit(device, 20000) && icsneo_enableMessagePolling(device) && icsneo_goOnline(device); if (icsneo_isOnlineSupported(device)) {
if (!icsneo_setPollingMessageLimit(device, 20000))
return false;
if (!icsneo_enableMessagePolling(device))
return false;
if (!icsneo_goOnline(device))
return false;
}
return true;
} }
int LegacyDLLExport icsneoOpenDevice( int LegacyDLLExport icsneoOpenDevice(
@ -447,7 +458,18 @@ int LegacyDLLExport icsneoOpenDevice(
if(!icsneo_openDevice(device)) if(!icsneo_openDevice(device))
return false; return false;
return icsneo_setPollingMessageLimit(device, 20000) && icsneo_enableMessagePolling(device) && icsneo_goOnline(device); if (icsneo_isOnlineSupported(device)) {
if (!icsneo_setPollingMessageLimit(device, 20000))
return false;
if (!icsneo_enableMessagePolling(device))
return false;
if (!icsneo_goOnline(device))
return false;
}
return true;
} }
int LegacyDLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors) int LegacyDLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors)

View File

@ -685,6 +685,8 @@ public:
uint64_t pos, uint8_t* into, uint64_t amount, std::optional<VSAMetadata> metadata = std::nullopt uint64_t pos, uint8_t* into, uint64_t amount, std::optional<VSAMetadata> metadata = std::nullopt
); );
virtual bool isOnlineSupported() const { return true; }
protected: protected:
bool online = false; bool online = false;
int messagePollingCallbackID = 0; int messagePollingCallbackID = 0;

View File

@ -64,6 +64,8 @@ public:
virtual uint8_t getPhyAddrOrPort() const = 0; virtual uint8_t getPhyAddrOrPort() const = 0;
bool isOnlineSupported() const override { return false; }
protected: protected:
using Device::Device; using Device::Device;

View File

@ -25,6 +25,8 @@ public:
bool getEthPhyRegControlSupported() const override { return true; } bool getEthPhyRegControlSupported() const override { return true; }
bool isOnlineSupported() const override { return false; }
protected: protected:
RADMoon3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) { RADMoon3(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<RADMoon3Settings>(makeDriver); initialize<RADMoon3Settings>(makeDriver);

View File

@ -27,6 +27,8 @@ public:
return false; return false;
} }
bool isOnlineSupported() const override { return false; }
protected: protected:
VividCAN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) { VividCAN(neodevice_t neodevice, const driver_factory_t& makeDriver) : Device(neodevice) {
initialize<VividCANSettings>(makeDriver); initialize<VividCANSettings>(makeDriver);

View File

@ -817,25 +817,33 @@ extern bool DLLExport icsneo_setTerminationFor(const neodevice_t* device, neonet
* *
* This function populates the device status structures and sub members. * This function populates the device status structures and sub members.
*/ */
extern int icsneo_getDeviceStatus(const neodevice_t* device, void* status, size_t* size); extern int DLLExport icsneo_getDeviceStatus(const neodevice_t* device, void* status, size_t* size);
/** /**
* \brief Get the real-time clock for the given device. * \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. * \param[in] device A pointer to the neodevice_t structure specifying the device to read the RTC from.
* \param[out] output A pointer to a uint64_t where the RTC will be stored. This value is in seconds. * \param[out] output A pointer to a uint64_t where the RTC will be stored. This value is in seconds.
* \returns True if the RTC was successfully retrieved. * \returns True if the RTC was successfully retrieved.
*/ */
extern bool icsneo_getRTC(const neodevice_t* device, uint64_t* output); extern bool DLLExport icsneo_getRTC(const neodevice_t* device, uint64_t* output);
/** /**
* \brief Set the real-time clock for the given device. * \brief Set the real-time clock for the given device.
* \param[out] device A pointer to the neodevice_t structure specifying the device to write the RTC to. * \param[in] device A pointer to the neodevice_t structure specifying the device to write the RTC to.
* \param[in] input A uint64_t object holding the RTC value. This value is in seconds. * \param[in] input A uint64_t object holding the RTC value. This value is in seconds.
* \returns True if the RTC was successfully set. * \returns True if the RTC was successfully set.
*/ */
extern bool icsneo_setRTC(const neodevice_t* device, uint64_t input); extern bool DLLExport icsneo_setRTC(const neodevice_t* device, uint64_t input);
/**
* \brief Check if the device supports the ability to go online
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
* \returns True if the device supports the ability to go online
*/
extern bool DLLExport icsneo_isOnlineSupported(const neodevice_t* device);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
@ -1017,6 +1025,9 @@ fn_icsneo_getRTC icsneo_getRTC;
typedef bool (*fn_icsneo_setRTC)(const neodevice_t* device, uint64_t input); typedef bool (*fn_icsneo_setRTC)(const neodevice_t* device, uint64_t input);
fn_icsneo_setRTC icsneo_setRTC; fn_icsneo_setRTC icsneo_setRTC;
typedef bool(*fn_icsneo_isOnlineSupported)(const neodevice_t* device);
fn_icsneo_isOnlineSupported icsneo_isOnlineSupported;
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func) #define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
#define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3 #define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3
void* icsneo_libraryHandle = NULL; void* icsneo_libraryHandle = NULL;
@ -1089,6 +1100,7 @@ int icsneo_init() {
ICSNEO_IMPORTASSERT(icsneo_getDeviceStatus); ICSNEO_IMPORTASSERT(icsneo_getDeviceStatus);
ICSNEO_IMPORTASSERT(icsneo_getRTC); ICSNEO_IMPORTASSERT(icsneo_getRTC);
ICSNEO_IMPORTASSERT(icsneo_setRTC); ICSNEO_IMPORTASSERT(icsneo_setRTC);
ICSNEO_IMPORTASSERT(icsneo_isOnlineSupported);
icsneo_initialized = true; icsneo_initialized = true;
return 0; return 0;

View File

@ -24,10 +24,9 @@ extern "C" {
extern int LegacyDLLExport icsneoFindDevices(NeoDeviceEx* pNeoDeviceEx, int* pNumDevices, unsigned int* DeviceTypes, unsigned int numDeviceTypes,POptionsFindNeoEx* pOptionsNeoEx, unsigned int* reserved); 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 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 icsneoOpenNeoDevice(NeoDevice* pNeoDevice, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int bSyncToPC);
extern int LegacyDLLExport icsneoOpenDevice(NeoDeviceEx* pNeoDeviceEx, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int iOptions, OptionsOpenNeoEx* stOptionsOpenNeoEx, unsigned long reserved); extern int LegacyDLLExport icsneoOpenDevice(NeoDeviceEx* pNeoDeviceEx, void** hObject, unsigned char* bNetworkIDs, int bConfigRead, int iOptions, OptionsOpenNeoEx* stOptionsOpenNeoEx, unsigned long reserved);
extern int LegacyDLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors); extern int LegacyDLLExport icsneoClosePort(void* hObject, int* pNumberOfErrors);
extern void LegacyDLLExport icsneoFreeObject(void* hObject); 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 //Message Functions
extern int LegacyDLLExport icsneoGetMessages(void* hObject, icsSpyMessage* pMsg, int* pNumberOfMessages, int* pNumberOfErrors); extern int LegacyDLLExport icsneoGetMessages(void* hObject, icsSpyMessage* pMsg, int* pNumberOfMessages, int* pNumberOfErrors);