mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Standardized int-returning functions in icsneoc library to return -1 on failure. Updated icsneolegacy accordingly, and added headers for message callback functionality in c
This commit is contained in:
+14
-4
@@ -229,7 +229,7 @@ bool icsneo_getMessages(const neodevice_t* device, neomessage_t* messages, size_
|
||||
|
||||
size_t icsneo_getPollingMessageLimit(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
return device->device->getPollingMessageLimit();
|
||||
}
|
||||
@@ -242,6 +242,16 @@ bool icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int icsneo_addMessageCallback(const neodevice_t* device, void (*callback) (neomessage_t*)) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool icsneo_removeMessageCallback(const neodevice_t* device, int id) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
}
|
||||
|
||||
bool icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLength) {
|
||||
// TAG String copy function
|
||||
if(maxLength == nullptr) {
|
||||
@@ -326,9 +336,9 @@ bool icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device) {
|
||||
return device->device->settings->applyDefaults(true);
|
||||
}
|
||||
|
||||
size_t icsneo_settingsReadStructure(const neodevice_t* device, void* structure, size_t structureSize) {
|
||||
int icsneo_settingsReadStructure(const neodevice_t* device, void* structure, size_t structureSize) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
size_t readSize = device->device->settings->getSize();
|
||||
if(structure == nullptr) // Structure size request
|
||||
@@ -343,7 +353,7 @@ size_t icsneo_settingsReadStructure(const neodevice_t* device, void* structure,
|
||||
const void* deviceStructure = device->device->settings->getRawStructurePointer();
|
||||
if(deviceStructure == nullptr) {
|
||||
EventManager::GetInstance().add(APIEvent::Type::SettingsNotAvailable, APIEvent::Severity::Error);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(structure, deviceStructure, readSize);
|
||||
|
||||
Reference in New Issue
Block a user