C API: Digital IO function use stdbool.h
This requirement is already in place and makes the API more consistentpull/32/head
parent
eb5a84132a
commit
9ba21d5dc7
|
|
@ -621,7 +621,7 @@ bool icsneo_getTimestampResolution(const neodevice_t* device, uint16_t* resoluti
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool icsneo_getDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, uint8_t* value) {
|
bool icsneo_getDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, bool* value) {
|
||||||
if(!icsneo_isValidNeoDevice(device))
|
if(!icsneo_isValidNeoDevice(device))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -634,13 +634,13 @@ bool icsneo_getDigitalIO(const neodevice_t* device, neoio_t type, uint32_t numbe
|
||||||
if(!val.has_value())
|
if(!val.has_value())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*value = uint8_t(*val);
|
*value = *val;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool icsneo_setDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, uint8_t value) {
|
bool icsneo_setDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, bool value) {
|
||||||
if(!icsneo_isValidNeoDevice(device))
|
if(!icsneo_isValidNeoDevice(device))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return device->device->setDigitalIO(static_cast<icsneo::IO>(type), number, bool(value));
|
return device->device->setDigitalIO(static_cast<icsneo::IO>(type), number, value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -497,7 +497,7 @@ int icsneoEnableDOIPLine(void* hObject, bool enable) {
|
||||||
if(!icsneoValidateHObject(hObject))
|
if(!icsneoValidateHObject(hObject))
|
||||||
return false;
|
return false;
|
||||||
neodevice_t* device = (neodevice_t*)hObject;
|
neodevice_t* device = (neodevice_t*)hObject;
|
||||||
return icsneo_setDigitalIO(device, ICSNEO_IO_ETH_ACTIVATION, 1, uint8_t(enable));
|
return icsneo_setDigitalIO(device, ICSNEO_IO_ETH_ACTIVATION, 1, enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
int icsneoStartSockServer(void* hObject, int iPort) {
|
int icsneoStartSockServer(void* hObject, int iPort) {
|
||||||
|
|
|
||||||
|
|
@ -613,7 +613,7 @@ int main() {
|
||||||
printf("Select from the following:\n");
|
printf("Select from the following:\n");
|
||||||
|
|
||||||
printf("[1] Ethernet (DoIP) Activation Line");
|
printf("[1] Ethernet (DoIP) Activation Line");
|
||||||
uint8_t val;
|
bool val;
|
||||||
bool haveVal = icsneo_getDigitalIO(selectedDevice, ICSNEO_IO_ETH_ACTIVATION, 1, &val);
|
bool haveVal = icsneo_getDigitalIO(selectedDevice, ICSNEO_IO_ETH_ACTIVATION, 1, &val);
|
||||||
if(!haveVal) {
|
if(!haveVal) {
|
||||||
neoevent_t event;
|
neoevent_t event;
|
||||||
|
|
|
||||||
|
|
@ -724,7 +724,7 @@ extern bool DLLExport icsneo_getTimestampResolution(const neodevice_t* device, u
|
||||||
*
|
*
|
||||||
* These values are often not populated if the device is not "online".
|
* These values are often not populated if the device is not "online".
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_getDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, uint8_t* value);
|
extern bool DLLExport icsneo_getDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, bool* value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get the value of a digital IO for the given device
|
* \brief Get the value of a digital IO for the given device
|
||||||
|
|
@ -736,7 +736,7 @@ extern bool DLLExport icsneo_getDigitalIO(const neodevice_t* device, neoio_t typ
|
||||||
*
|
*
|
||||||
* Note that this function is not synchronous with the device confirming the change.
|
* Note that this function is not synchronous with the device confirming the change.
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_setDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, uint8_t value);
|
extern bool DLLExport icsneo_setDigitalIO(const neodevice_t* device, neoio_t type, uint32_t number, bool value);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
@ -888,10 +888,10 @@ fn_icsneo_getSupportedDevices icsneo_getSupportedDevices;
|
||||||
typedef bool(*fn_icsneo_getTimestampResolution)(const neodevice_t* device, uint16_t* resolution);
|
typedef bool(*fn_icsneo_getTimestampResolution)(const neodevice_t* device, uint16_t* resolution);
|
||||||
fn_icsneo_getTimestampResolution icsneo_getTimestampResolution;
|
fn_icsneo_getTimestampResolution icsneo_getTimestampResolution;
|
||||||
|
|
||||||
typedef bool(*fn_icsneo_getDigitalIO)(const neodevice_t* device, neoio_t type, uint32_t number, uint8_t* value);
|
typedef bool(*fn_icsneo_getDigitalIO)(const neodevice_t* device, neoio_t type, uint32_t number, bool* value);
|
||||||
fn_icsneo_getDigitalIO icsneo_getDigitalIO;
|
fn_icsneo_getDigitalIO icsneo_getDigitalIO;
|
||||||
|
|
||||||
typedef bool(*fn_icsneo_setDigitalIO)(const neodevice_t* device, neoio_t type, uint32_t number, uint8_t value);
|
typedef bool(*fn_icsneo_setDigitalIO)(const neodevice_t* device, neoio_t type, uint32_t number, bool value);
|
||||||
fn_icsneo_setDigitalIO icsneo_setDigitalIO;
|
fn_icsneo_setDigitalIO icsneo_setDigitalIO;
|
||||||
|
|
||||||
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
|
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue