From 8e1151ac02cdfa84440d5e671ab62e89dcec499b Mon Sep 17 00:00:00 2001 From: Will Xyen Date: Tue, 19 Jan 2021 21:10:34 -0800 Subject: [PATCH] aciodrv: address review also some formatting fixes --- src/main/aciodrv/device.c | 49 +++++++++++++++++++++----------- src/main/aciodrv/device.h | 4 ++- src/main/aciodrv/icca.c | 10 +++++++ src/main/aciodrv/icca.h | 3 +- src/main/aciodrv/kfca.c | 20 ++++++------- src/main/aciodrv/port.c | 12 +++++--- src/main/aciotest/main.c | 1 + src/main/bio2drv/bi2a-iidx.c | 11 +++++-- src/main/bio2drv/bi2a-sdvx.c | 12 +++++++- src/main/camhook/cam.c | 6 ++-- src/main/eamio-icca/eamio-icca.c | 1 + src/main/hooklib/memfile.c | 32 +++++++++++---------- src/main/hooklib/memfile.h | 5 +++- src/main/iidxio-bio2/iidxio.c | 1 + src/main/sdvxio-bio2/sdvxio.c | 1 + src/main/sdvxio-kfca/sdvxio.c | 1 + 16 files changed, 114 insertions(+), 55 deletions(-) diff --git a/src/main/aciodrv/device.c b/src/main/aciodrv/device.c index 57c6868..3d58965 100644 --- a/src/main/aciodrv/device.c +++ b/src/main/aciodrv/device.c @@ -12,9 +12,11 @@ /* Enable to dump all data to the logger */ //#define AC_IO_MSG_LOG +#define ACIO_MAX_NODES_PER_PORT 16 + struct aciodrv_device_ctx { HANDLE fd; - char node_products[16][4]; // 16 devices max + char node_products[ACIO_MAX_NODES_PER_PORT][ACIO_NODE_PRODUCT_CODE_LEN]; uint8_t msg_counter; uint8_t node_count; }; @@ -51,12 +53,12 @@ static bool aciodrv_device_init(struct aciodrv_device_ctx *device) #ifdef AC_IO_MSG_LOG static void -aciodrv_device_log_buffer(const char *msg, const uint8_t *buffer, int length) +aciodrv_device_log_buffer(struct aciodrv_device_ctx *device, const char *msg, const uint8_t *buffer, int length) { char str[4096]; hex_encode_uc((const void *) buffer, length, str, sizeof(str)); - log_misc("%s, length %d: %s", msg, length, str); + log_misc("[%x] %s, length %d: %s", device->fd, msg, length, str); } #endif @@ -67,12 +69,12 @@ static bool aciodrv_device_send(struct aciodrv_device_ctx *device, const uint8_t uint8_t checksum = 0; if (length > sizeof(send_buf)) { - log_warning("Send buffer overflow"); + log_warning("[%x] Send buffer overflow", device->fd); return false; } #ifdef AC_IO_MSG_LOG - aciodrv_device_log_buffer("Send (1)", buffer, length); + aciodrv_device_log_buffer("Send (1)", device, buffer, length); #endif send_buf[send_buf_pos++] = AC_IO_SOF; @@ -98,11 +100,11 @@ static bool aciodrv_device_send(struct aciodrv_device_ctx *device, const uint8_t } #ifdef AC_IO_MSG_LOG - aciodrv_device_log_buffer("Send (2)", send_buf, send_buf_pos); + aciodrv_device_log_buffer("Send (2)", device, send_buf, send_buf_pos); #endif if (aciodrv_port_write(device->fd, send_buf, send_buf_pos) != send_buf_pos) { - log_warning("Sending data with length %d failed", send_buf_pos); + log_warning("[%x] Sending data with length %d failed", device->fd, send_buf_pos); return false; } @@ -172,13 +174,13 @@ static int aciodrv_device_receive(struct aciodrv_device_ctx *device, uint8_t *bu } #ifdef AC_IO_MSG_LOG - aciodrv_device_log_buffer("Recv (1)", recv_buf, recv_size); + aciodrv_device_log_buffer("Recv (1)", device, recv_buf, recv_size); log_warning("Expected %d got %d", max_resp_size - 6, recv_buf[4]); #endif /* recv_size - 1: omit checksum for checksum calc */ if ((recv_size - 1) > max_resp_size) { - log_warning("Expected %d got %d", max_resp_size - 6, recv_buf[4]); + log_warning("[%x] Expected %d got %d", device->fd, max_resp_size - 6, recv_buf[4]); return -1; } for (int i = 0; i < recv_size - 1; i++) { @@ -189,12 +191,13 @@ static int aciodrv_device_receive(struct aciodrv_device_ctx *device, uint8_t *bu result_size = recv_size - 1; #ifdef AC_IO_MSG_LOG - aciodrv_device_log_buffer("Recv (2)", buffer, result_size); + aciodrv_device_log_buffer("Recv (2)", device, buffer, result_size); #endif if (checksum != recv_buf[recv_size - 1]) { log_warning( - "Invalid message checksum: %02X != %02X", + "[%x] Invalid message checksum: %02X != %02X", + device->fd, checksum, recv_buf[recv_size - 1]); return -1; @@ -289,13 +292,16 @@ static bool aciodrv_device_start_node(struct aciodrv_device_ctx *device, uint8_t struct aciodrv_device_ctx *aciodrv_device_open(const char *port_path, int baud) { HANDLE port = aciodrv_port_open(port_path, baud); + if (!port) { return NULL; } - struct aciodrv_device_ctx *device = malloc(sizeof(struct aciodrv_device_ctx)); + struct aciodrv_device_ctx *device = xmalloc(sizeof(struct aciodrv_device_ctx)); + memset(device, 0, sizeof(struct aciodrv_device_ctx)); device->fd = port; + device->msg_counter = 1; if (!aciodrv_device_init(device)) { aciodrv_device_close(device); @@ -303,6 +309,7 @@ struct aciodrv_device_ctx *aciodrv_device_open(const char *port_path, int baud) } device->node_count = aciodrv_device_enum_nodes(device); + if (device->node_count == 0) { aciodrv_device_close(device); return false; @@ -323,6 +330,7 @@ struct aciodrv_device_ctx *aciodrv_device_open(const char *port_path, int baud) } } + log_info("Opening ACIO device on [%x]", device->fd); return device; } @@ -337,7 +345,7 @@ bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx *device, ui return false; } - memcpy(product, device->node_products[node_id], 4); + memcpy(product, device->node_products[node_id], ACIO_NODE_PRODUCT_CODE_LEN); return true; } @@ -348,7 +356,8 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa #ifdef AC_IO_MSG_LOG log_info( - "Beginning send on %d: %04x (%d b)", + "[%x] Beginning send on %d: %04x (%d b)", + device->fd, msg->addr, msg->cmd.code, send_size); @@ -360,7 +369,7 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa uint16_t req_code = msg->cmd.code; #ifdef AC_IO_MSG_LOG - log_info("Beginning recv: (%d b)", max_resp_size); + log_info("[%x] Beginning recv: (%d b)", device->fd, max_resp_size); #endif if (aciodrv_device_receive(device, (uint8_t *) msg, max_resp_size) <= 0) { return false; @@ -368,9 +377,11 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa if (req_code != msg->cmd.code) { log_warning( - "Received invalid response %04X for request %04X", + "[%x] Received invalid response %04X for request %04X on fd %x", + device->fd, msg->cmd.code, - req_code); + req_code, + device->fd); return false; } @@ -379,6 +390,10 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa void aciodrv_device_close(struct aciodrv_device_ctx *device) { + log_assert(device); + + log_info("Closing ACIO on [%x]", device->fd); + aciodrv_port_close(device->fd); free(device); diff --git a/src/main/aciodrv/device.h b/src/main/aciodrv/device.h index e326896..4e7adb3 100644 --- a/src/main/aciodrv/device.h +++ b/src/main/aciodrv/device.h @@ -7,6 +7,8 @@ #include "windows.h" +#define ACIO_NODE_PRODUCT_CODE_LEN 4 + struct aciodrv_device_ctx; /** @@ -35,7 +37,7 @@ uint8_t aciodrv_device_get_node_count(struct aciodrv_device_ctx *device); * @return True on success, false on error. If True the variable product * contains the identifier of the queried node. */ -bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx *device, uint8_t node_id, char product[4]); +bool aciodrv_device_get_node_product_ident(struct aciodrv_device_ctx *device, uint8_t node_id, char product[ACIO_NODE_PRODUCT_CODE_LEN]); /** * Send a message to the ACIO bus and receive an answer. diff --git a/src/main/aciodrv/icca.c b/src/main/aciodrv/icca.c index a3902a0..859a049 100644 --- a/src/main/aciodrv/icca.c +++ b/src/main/aciodrv/icca.c @@ -12,6 +12,8 @@ static bool aciodrv_icca_queue_loop_start( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id; msg.cmd.code = ac_io_u16(AC_IO_ICCA_CMD_QUEUE_LOOP_START); msg.cmd.nbytes = 1; @@ -33,6 +35,8 @@ static bool aciodrv_icca_queue_loop_start( bool aciodrv_icca_init(struct aciodrv_device_ctx *device, uint8_t node_id) { + log_assert(device); + if (!aciodrv_icca_queue_loop_start(device, node_id + 1)) { return false; } @@ -48,6 +52,8 @@ bool aciodrv_icca_set_state( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_ICCA_CMD_SET_SLOT_STATE); msg.cmd.nbytes = 2; @@ -77,6 +83,8 @@ bool aciodrv_icca_get_state( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_ICCA_CMD_POLL); msg.cmd.nbytes = 1; @@ -105,6 +113,8 @@ bool aciodrv_icca_read_card( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_ICCA_CMD_ENGAGE); msg.cmd.nbytes = 1; diff --git a/src/main/aciodrv/icca.h b/src/main/aciodrv/icca.h index 44424d9..a7cd595 100644 --- a/src/main/aciodrv/icca.h +++ b/src/main/aciodrv/icca.h @@ -30,7 +30,8 @@ bool aciodrv_icca_init(struct aciodrv_device_ctx *device, uint8_t node_id); */ bool aciodrv_icca_set_state( struct aciodrv_device_ctx *device, - uint8_t node_id, int slot_state, + uint8_t node_id, + int slot_state, struct ac_io_icca_state *state); /** diff --git a/src/main/aciodrv/kfca.c b/src/main/aciodrv/kfca.c index 9a3a93f..4b097c0 100644 --- a/src/main/aciodrv/kfca.c +++ b/src/main/aciodrv/kfca.c @@ -11,18 +11,13 @@ static bool aciodrv_kfca_watchdog_start( struct aciodrv_device_ctx *device, uint8_t node_id) { - // exit early and don't actually call watchdog - // the watchdog call actually returns different sized packets depending on - // the state this results in an issue during packet processing (see: #68) - return true; - - /* struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_WATCHDOG); msg.cmd.nbytes = 2; - msg.cmd.nbytes = 2; // uint16_t: 6000 msg.cmd.raw[0] = 23; @@ -33,11 +28,10 @@ static bool aciodrv_kfca_watchdog_start( log_warning("Starting watchdog failed"); return false; } - log_warning("Started watchdog of node %d, status: %d", - node_id, msg.cmd.status); + log_warning("Started watchdog of node %d, sz: %d, status: %d", + node_id, msg.cmd.nbytes, msg.cmd.status); return true; - */ } bool aciodrv_kfca_amp( @@ -50,6 +44,8 @@ bool aciodrv_kfca_amp( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_AMP_CONTROL); msg.cmd.nbytes = 4; @@ -76,6 +72,8 @@ bool aciodrv_kfca_init( struct aciodrv_device_ctx *device, uint8_t node_id) { + log_assert(device); + if (!aciodrv_kfca_watchdog_start(device, node_id)) { return false; } @@ -95,6 +93,8 @@ bool aciodrv_kfca_poll( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_POLL); msg.cmd.nbytes = sizeof(*pout); diff --git a/src/main/aciodrv/port.c b/src/main/aciodrv/port.c index 415cc4f..d3ffea9 100644 --- a/src/main/aciodrv/port.c +++ b/src/main/aciodrv/port.c @@ -100,7 +100,7 @@ HANDLE aciodrv_port_open(const char *port_path, int baud) goto fail; } - log_info("Opened ACIO device on %s", port_path); + log_info("[%x] Opened ACIO device on %s", port_fd, port_path); return port_fd; @@ -115,18 +115,20 @@ int aciodrv_port_read(HANDLE port_fd, void *bytes, int nbytes) { DWORD nread; + log_assert(bytes); + if (port_fd == NULL) { return -1; } if (!ClearCommError(port_fd, NULL, NULL)) { - log_warning("ClearCommError failed"); + log_warning("[%x] ClearCommError failed", port_fd); return -1; } if (!ReadFile(port_fd, bytes, nbytes, &nread, NULL)) { - log_warning("ReadFile failed: err = %lu", GetLastError()); + log_warning("[%x] ReadFile failed: err = %lu", port_fd, GetLastError()); return -1; } @@ -138,12 +140,14 @@ int aciodrv_port_write(HANDLE port_fd, const void *bytes, int nbytes) { DWORD nwrit; + log_assert(bytes); + if (port_fd == NULL) { return -1; } if (!WriteFile(port_fd, bytes, nbytes, &nwrit, NULL)) { - log_warning("WriteFile failed: err = %lu", GetLastError()); + log_warning("[%x] WriteFile failed: err = %lu", port_fd, GetLastError()); return -1; } diff --git a/src/main/aciotest/main.c b/src/main/aciotest/main.c index 4cddca8..9ed271f 100644 --- a/src/main/aciotest/main.c +++ b/src/main/aciotest/main.c @@ -72,6 +72,7 @@ int main(int argc, char **argv) struct aciodrv_device_ctx *device = aciodrv_device_open(argv[1], atoi(argv[2])); + if (!device) { printf("Opening acio device failed\n"); return -1; diff --git a/src/main/bio2drv/bi2a-iidx.c b/src/main/bio2drv/bi2a-iidx.c index 666f9d2..29713a0 100644 --- a/src/main/bio2drv/bi2a-iidx.c +++ b/src/main/bio2drv/bi2a-iidx.c @@ -20,6 +20,8 @@ static bool bio2drv_bi2a_iidx_init_io( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(BIO2_BI2A_CMD_INIT); msg.cmd.nbytes = 1; @@ -42,6 +44,8 @@ static bool bio2drv_bi2a_iidx_watchdog_start( struct aciodrv_device_ctx *device, uint8_t node_id) { + log_assert(device); + // exit early and don't actually call watchdog // the watchdog call actually returns different sized packets depending on // the state this results in an issue during packet processing (see: #68) @@ -53,7 +57,6 @@ static bool bio2drv_bi2a_iidx_watchdog_start( msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_WATCHDOG); msg.cmd.nbytes = 2; - msg.cmd.nbytes = 2; // uint16_t: 6000 msg.cmd.raw[0] = 23; @@ -74,6 +77,8 @@ static bool bio2drv_bi2a_iidx_watchdog_start( bool bio2drv_bi2a_iidx_init(struct aciodrv_device_ctx *device, uint8_t node_id) { + log_assert(device); + if (!bio2drv_bi2a_iidx_init_io(device, node_id)) { return false; } @@ -93,6 +98,8 @@ bool bio2drv_bi2a_iidx_poll( { struct ac_io_message msg; + // log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(BIO2_BI2A_CMD_POLL); msg.cmd.nbytes = sizeof(*pout); @@ -103,7 +110,7 @@ bool bio2drv_bi2a_iidx_poll( device, &msg, offsetof(struct ac_io_message, cmd.raw) + sizeof(*pin))) { - log_warning("Polling of node %d failed", node_id + 1); + log_warning("[%x] Polling of node %d failed", node_id + 1); return false; } diff --git a/src/main/bio2drv/bi2a-sdvx.c b/src/main/bio2drv/bi2a-sdvx.c index f8b6b25..1d8172a 100644 --- a/src/main/bio2drv/bi2a-sdvx.c +++ b/src/main/bio2drv/bi2a-sdvx.c @@ -16,6 +16,8 @@ static bool bio2drv_bi2a_sdvx_init_io(struct aciodrv_device_ctx *device, uint8_t { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(BIO2_BI2A_CMD_INIT); msg.cmd.nbytes = 1; @@ -36,6 +38,8 @@ static bool bio2drv_bi2a_sdvx_init_io(struct aciodrv_device_ctx *device, uint8_t static bool bio2drv_bi2a_sdvx_watchdog_start(struct aciodrv_device_ctx *device, uint8_t node_id) { + log_assert(device); + // exit early and don't actually call watchdog // the watchdog call actually returns different sized packets depending on // the state this results in an issue during packet processing (see: #68) @@ -54,7 +58,7 @@ static bool bio2drv_bi2a_sdvx_watchdog_start(struct aciodrv_device_ctx *device, msg.cmd.raw[1] = 112; if (!aciodrv_send_and_recv( - &msg, offsetof(struct ac_io_message, cmd.raw) + 2 + device, &msg, offsetof(struct ac_io_message, cmd.raw) + 2 )) { log_warning("Starting watchdog failed"); return false; } @@ -76,6 +80,8 @@ bool bio2drv_bi2a_sdvx_amp( { struct ac_io_message msg; + log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_AMP_CONTROL); msg.cmd.nbytes = 4; @@ -103,6 +109,8 @@ bool bio2drv_bi2a_sdvx_amp( bool bio2drv_bi2a_sdvx_init(struct aciodrv_device_ctx *device, uint8_t node_id) { + log_assert(device); + if (!bio2drv_bi2a_sdvx_init_io(device, node_id)) { return false; } @@ -126,6 +134,8 @@ bool bio2drv_bi2a_sdvx_poll( { struct ac_io_message msg; + // log_assert(device); + msg.addr = node_id + 1; msg.cmd.code = ac_io_u16(AC_IO_CMD_KFCA_POLL); msg.cmd.nbytes = sizeof(*pout); diff --git a/src/main/camhook/cam.c b/src/main/camhook/cam.c index d21fb9e..939c308 100644 --- a/src/main/camhook/cam.c +++ b/src/main/camhook/cam.c @@ -341,14 +341,14 @@ static HRESULT my_MFEnumDeviceSources( for (UINT32 i = 0; i < nsrcs; ++i) { api = (*pppSourceActivate)[i]; - + ret = com_proxy_wrap(&api_proxy, api, sizeof(*api->lpVtbl)); - + if (ret != S_OK) { log_warning("Wrapping com proxy failed: %08lx", ret); return ret; } - + api_vtbl = api_proxy->vptr; real_GetAllocatedString = api_vtbl->GetAllocatedString; diff --git a/src/main/eamio-icca/eamio-icca.c b/src/main/eamio-icca/eamio-icca.c index 7fe6080..d14a216 100644 --- a/src/main/eamio-icca/eamio-icca.c +++ b/src/main/eamio-icca/eamio-icca.c @@ -49,6 +49,7 @@ bool eam_io_init( thread_create_t create, thread_join_t join, thread_destroy_t destroy) { acio_device_ctx = aciodrv_device_open("COM1", 57600); + if (acio_device_ctx == NULL) { log_warning("Opening acio device on COM1 failed"); return false; diff --git a/src/main/hooklib/memfile.c b/src/main/hooklib/memfile.c index c53d5ab..17ea6ba 100644 --- a/src/main/hooklib/memfile.c +++ b/src/main/hooklib/memfile.c @@ -25,16 +25,11 @@ struct file_entry { static struct array hooked_files; static CRITICAL_SECTION hooked_files_cs; - BOOL my_GetFileInformationByHandle( - HANDLE hFile, - LPBY_HANDLE_FILE_INFORMATION lpFileInformation -); + HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation); -BOOL (*real_GetFileInformationByHandle)( - HANDLE hFile, - LPBY_HANDLE_FILE_INFORMATION lpFileInformation -); +BOOL (*real_GetFileInformationByHandle) +(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation); static const struct hook_symbol memfile_hook_kernel32_syms[] = { {.name = "GetFileInformationByHandle", @@ -42,7 +37,6 @@ static const struct hook_symbol memfile_hook_kernel32_syms[] = { .link = (void **) &real_GetFileInformationByHandle}, }; - void memfile_hook_init(void) { array_init(&hooked_files); @@ -82,7 +76,10 @@ void memfile_hook_fini(void) } void memfile_hook_add_fd( - const char *path, enum memfile_hook_path_mode path_mode, const void *data, uint32_t sz) + const char *path, + enum memfile_hook_path_mode path_mode, + const void *data, + uint32_t sz) { log_assert(path != NULL); @@ -110,7 +107,11 @@ void memfile_hook_add_fd( LeaveCriticalSection(&hooked_files_cs); - log_misc("memfile_hook_add_fd: path %s, mode %d, data size %d", path, path_mode, sz); + log_misc( + "memfile_hook_add_fd: path %s, mode %d, data size %d", + path, + path_mode, + sz); } static struct file_entry *memfile_hook_match_irp(const struct irp *irp) @@ -155,7 +156,10 @@ static HRESULT memfile_hook_irp_read(struct file_entry *entry, struct irp *irp) size_t nread = min(entry->sz - entry->pos, irp->read.nbytes); if (nread > 0) { - memcpy(irp->read.bytes + irp->read.pos, (uint8_t*)entry->data + entry->pos, nread); + memcpy( + irp->read.bytes + irp->read.pos, + (uint8_t *) entry->data + entry->pos, + nread); entry->pos += nread; irp->read.pos += nread; @@ -248,9 +252,7 @@ HRESULT memfile_hook_dispatch_irp(struct irp *irp) // this isn't a standard iohook IRP atm. BOOL my_GetFileInformationByHandle( - HANDLE hFile, - LPBY_HANDLE_FILE_INFORMATION lpFileInformation -) + HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) { struct file_entry *entry; for (size_t i = 0; i < hooked_files.nitems; i++) { diff --git a/src/main/hooklib/memfile.h b/src/main/hooklib/memfile.h index 98e0285..fad04bb 100644 --- a/src/main/hooklib/memfile.h +++ b/src/main/hooklib/memfile.h @@ -32,7 +32,10 @@ enum memfile_hook_path_mode { * @param sz size of file */ void memfile_hook_add_fd( - const char *path, enum memfile_hook_path_mode path_mode, const void *data, uint32_t sz); + const char *path, + enum memfile_hook_path_mode path_mode, + const void *data, + uint32_t sz); /** * iohook dispatch function. Needs to be installed. diff --git a/src/main/iidxio-bio2/iidxio.c b/src/main/iidxio-bio2/iidxio.c index 47e8125..189b763 100644 --- a/src/main/iidxio-bio2/iidxio.c +++ b/src/main/iidxio-bio2/iidxio.c @@ -117,6 +117,7 @@ bool iidx_io_init( } bio2_device_ctx = aciodrv_device_open(selected_port, config_bio2.baud); + if (bio2_device_ctx == NULL) { log_info("Opening BIO2 device on [%s] failed", selected_port); return 0; diff --git a/src/main/sdvxio-bio2/sdvxio.c b/src/main/sdvxio-bio2/sdvxio.c index 3174180..4207e8a 100644 --- a/src/main/sdvxio-bio2/sdvxio.c +++ b/src/main/sdvxio-bio2/sdvxio.c @@ -102,6 +102,7 @@ bool sdvx_io_init( } bio2_device_ctx = aciodrv_device_open(selected_port, config_bio2.baud); + if (bio2_device_ctx == NULL) { log_info("Opening BIO2 device on [%s] failed", selected_port); return 0; diff --git a/src/main/sdvxio-kfca/sdvxio.c b/src/main/sdvxio-kfca/sdvxio.c index 21f8709..0d06737 100644 --- a/src/main/sdvxio-kfca/sdvxio.c +++ b/src/main/sdvxio-kfca/sdvxio.c @@ -81,6 +81,7 @@ bool sdvx_io_init( cconfig_finit(config); acio_device_ctx = aciodrv_device_open(config_kfca.port, config_kfca.baud); + if (acio_device_ctx == NULL) { log_info("Opening acio device on [%s] failed", config_kfca.port); return 0;