From 023f675caa505454c2168f392c15072f85ea8ab0 Mon Sep 17 00:00:00 2001 From: wb2osz Date: Tue, 21 Sep 2021 13:29:29 -0400 Subject: [PATCH] Avoid serial port write error for Windows, --- src/serial_port.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/serial_port.c b/src/serial_port.c index 5fbc5e0..c57ee20 100644 --- a/src/serial_port.c +++ b/src/serial_port.c @@ -304,17 +304,12 @@ int serial_port_write (MYFDTYPE fd, char *str, int len) { text_color_set(DW_COLOR_ERROR); dw_printf ("Error writing to serial port. Error %d.\n\n", err); + return (-1); } } - else if ((int)nwritten != len) - { - // Do we want this message here? - // Or rely on caller to check and provide something more meaningful for the usage? - //text_color_set(DW_COLOR_ERROR); - //dw_printf ("Error writing to serial port. Only %d of %d written.\n\n", (int)nwritten, len); - } - return (nwritten); + // nwritten is 0 for asynchronous write, at this point, so just return the requested len. + return (len); #else int written;