From 9ba21d5dc7daab9d6de0771652ceed76a42fdf74 Mon Sep 17 00:00:00 2001 From: Paul Hollinsky Date: Sun, 11 Apr 2021 20:54:59 -0400 Subject: [PATCH] C API: Digital IO function use stdbool.h This requirement is already in place and makes the API more consistent --- api/icsneoc/icsneoc.cpp | 8 ++++---- api/icsneolegacy/icsneolegacy.cpp | 2 +- examples/c/interactive/src/main.c | 2 +- include/icsneo/icsneoc.h | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api/icsneoc/icsneoc.cpp b/api/icsneoc/icsneoc.cpp index a227976..41dd378 100644 --- a/api/icsneoc/icsneoc.cpp +++ b/api/icsneoc/icsneoc.cpp @@ -621,7 +621,7 @@ bool icsneo_getTimestampResolution(const neodevice_t* device, uint16_t* resoluti 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)) return false; @@ -634,13 +634,13 @@ bool icsneo_getDigitalIO(const neodevice_t* device, neoio_t type, uint32_t numbe if(!val.has_value()) return false; - *value = uint8_t(*val); + *value = *val; 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)) return false; - return device->device->setDigitalIO(static_cast(type), number, bool(value)); + return device->device->setDigitalIO(static_cast(type), number, value); } diff --git a/api/icsneolegacy/icsneolegacy.cpp b/api/icsneolegacy/icsneolegacy.cpp index 3380356..9097060 100644 --- a/api/icsneolegacy/icsneolegacy.cpp +++ b/api/icsneolegacy/icsneolegacy.cpp @@ -497,7 +497,7 @@ int icsneoEnableDOIPLine(void* hObject, bool enable) { if(!icsneoValidateHObject(hObject)) return false; 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) { diff --git a/examples/c/interactive/src/main.c b/examples/c/interactive/src/main.c index 6a09b89..c8b7859 100644 --- a/examples/c/interactive/src/main.c +++ b/examples/c/interactive/src/main.c @@ -613,7 +613,7 @@ int main() { printf("Select from the following:\n"); printf("[1] Ethernet (DoIP) Activation Line"); - uint8_t val; + bool val; bool haveVal = icsneo_getDigitalIO(selectedDevice, ICSNEO_IO_ETH_ACTIVATION, 1, &val); if(!haveVal) { neoevent_t event; diff --git a/include/icsneo/icsneoc.h b/include/icsneo/icsneoc.h index c58bf00..77003cc 100644 --- a/include/icsneo/icsneoc.h +++ b/include/icsneo/icsneoc.h @@ -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". */ -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 @@ -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. */ -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 } // extern "C" @@ -888,10 +888,10 @@ fn_icsneo_getSupportedDevices icsneo_getSupportedDevices; typedef bool(*fn_icsneo_getTimestampResolution)(const neodevice_t* device, uint16_t* resolution); 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; -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; #define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)