From 57337fe941d7c75880e97185a289a6b3af4ffa39 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 31 Mar 2018 10:46:06 +0200 Subject: [PATCH] chg: add some error messages in order to debug better. --- uart/uart_win32.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uart/uart_win32.c b/uart/uart_win32.c index 3156e10db..7be3a8fe9 100644 --- a/uart/uart_win32.c +++ b/uart/uart_win32.c @@ -62,9 +62,10 @@ serial_port uart_open(const char* pcPortName) { char acPortName[255]; serial_port_windows* sp = malloc(sizeof(serial_port_windows)); - if (sp == 0) + if (sp == 0) { + printf("[!] UART failed to allocate memory\n"); return INVALID_SERIAL_PORT; - + } // Copy the input "com?" to "\\.\COM?" format sprintf(acPortName,"\\\\.\\%s", pcPortName); _strupr(acPortName); @@ -83,12 +84,14 @@ serial_port uart_open(const char* pcPortName) { sp->dcb.DCBlength = sizeof(DCB); if (!BuildCommDCBA("baud=115200 parity=N data=8 stop=1", &sp->dcb)) { uart_close(sp); + printf("[!] UART error cdc setup\n"); return INVALID_SERIAL_PORT; } // Update the active serial port if (!SetCommState(sp->hPort, &sp->dcb)) { uart_close(sp); + printf("[!] UART error while setting com state\n"); return INVALID_SERIAL_PORT; } // all zero's configure: no timeout for read/write used. @@ -101,6 +104,7 @@ serial_port uart_open(const char* pcPortName) { if (!SetCommTimeouts(sp->hPort, &sp->ct)) { uart_close(sp); + printf("[!] UART error while setting comm time outs\n"); return INVALID_SERIAL_PORT; }