mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
The icsneolegacy API finds devices correctly now
This commit is contained in:
@@ -55,13 +55,13 @@ void icsneo_freeUnconnectedDevices() {
|
||||
|
||||
bool icsneo_serialNumToString(uint32_t num, char* str, size_t* count) {
|
||||
auto result = Device::SerialNumToString(num);
|
||||
if(*count <= result.length()) {
|
||||
if(*count < result.length()) {
|
||||
*count = result.length() + 1; // This is how big of a buffer we need
|
||||
return false;
|
||||
}
|
||||
strncpy(str, result.c_str(), *count);
|
||||
str[*count - 1] = '\0';
|
||||
*count = result.length();
|
||||
|
||||
*count = result.copy(str, *count);
|
||||
str[*count] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,6 +208,6 @@ bool icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLeng
|
||||
return false;
|
||||
|
||||
*maxLength = device->device->getType().toString().copy(str, *maxLength);
|
||||
str[*maxLength + 1] = '\0';
|
||||
str[*maxLength] = '\0';
|
||||
return true;
|
||||
}
|
||||
@@ -6,11 +6,12 @@
|
||||
|
||||
static NeoDevice OldNeoDeviceFromNew(const neodevice_t* newnd) {
|
||||
NeoDevice oldnd = { 0 };
|
||||
oldnd.DeviceType = newnd->type;
|
||||
oldnd.SerialNumber = icsneo_serialStringToNum(newnd->serial);
|
||||
oldnd.NumberOfClients = 0;
|
||||
oldnd.MaxAllowedClients = 1;
|
||||
static_assert(sizeof(neodevice_handle_t) <= sizeof(oldnd.Handle), "neodevice_handle_t size must be at least sizeof(int) for compatibility reasons");
|
||||
*(neodevice_handle_t*)(&oldnd.Handle) = newnd->handle;
|
||||
static_assert(sizeof(neodevice_handle_t) == sizeof(oldnd.Handle), "neodevice_handle_t size must be sizeof(int) for compatibility reasons");
|
||||
oldnd.Handle = newnd->handle;
|
||||
return oldnd;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user