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);
|
||||
|
||||
@@ -292,7 +292,9 @@ int icsneoGetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetFireSettings(void* hObject, SFireSettings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
@@ -308,7 +310,9 @@ int icsneoGetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumByt
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetVCAN3Settings(void* hObject, SVCAN3Settings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
@@ -324,7 +328,9 @@ int icsneoGetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumByt
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetFire2Settings(void* hObject, SFire2Settings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
@@ -340,7 +346,9 @@ int icsneoGetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumB
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetVCANRFSettings(void* hObject, SVCANRFSettings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
@@ -356,7 +364,9 @@ int icsneoGetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNu
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetVCAN412Settings(void* hObject, SVCAN412Settings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
@@ -372,7 +382,9 @@ int icsneoGetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetRADGalaxySettings(void* hObject, SRADGalaxySettings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
@@ -388,7 +400,9 @@ int icsneoGetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int i
|
||||
if(!icsneoValidateHObject(hObject))
|
||||
return false;
|
||||
neodevice_t* device = (neodevice_t*)hObject;
|
||||
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
|
||||
if(icsneo_settingsReadStructure(device, pSettings, iNumBytes) == -1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
int icsneoSetRADStar2Settings(void* hObject, SRADStar2Settings* pSettings, int iNumBytes, int bSaveToEEPROM) {
|
||||
|
||||
Reference in New Issue
Block a user