From ba3da796f7480bfec3a4fe5292ff3a58e6efbfde Mon Sep 17 00:00:00 2001 From: "vrong@vrong.org" Date: Tue, 18 Jul 2017 09:43:25 +0200 Subject: [PATCH 1/2] Fixed badly set bitrate causing sweep object creation to hang on Linux --- libsweep/src/unix/serial.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libsweep/src/unix/serial.cc b/libsweep/src/unix/serial.cc index 14c475e..686e410 100644 --- a/libsweep/src/unix/serial.cc +++ b/libsweep/src/unix/serial.cc @@ -26,6 +26,15 @@ static speed_t get_baud(int32_t bitrate) { throw error{"Only baud rate 115200 is supported at this time."}; return -1; } + + // translate human readable bitrate to termios bitrate + if (bitrate == 115200) + { + #ifdef B115200 + bitrate = B115200; + #endif + } + return bitrate; } From 2f2b5d5ce56aa4b34346a9122b588fc6cf8ecbe2 Mon Sep 17 00:00:00 2001 From: "vrong@vrong.org" Date: Tue, 18 Jul 2017 19:58:52 +0200 Subject: [PATCH 2/2] Removed redundant condition in get_baud --- libsweep/src/unix/serial.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libsweep/src/unix/serial.cc b/libsweep/src/unix/serial.cc index 686e410..6c0a1d5 100644 --- a/libsweep/src/unix/serial.cc +++ b/libsweep/src/unix/serial.cc @@ -27,14 +27,10 @@ static speed_t get_baud(int32_t bitrate) { return -1; } - // translate human readable bitrate to termios bitrate - if (bitrate == 115200) - { - #ifdef B115200 - bitrate = B115200; - #endif - } - +// translate human readable bitrate to termios bitrate +#ifdef B115200 + return B115200; +#endif return bitrate; } @@ -157,7 +153,7 @@ void device_read(device_s serial, void* to, int32_t len) { } else { throw error{"reading from serial device failed"}; } - } else if(ret == 0){ + } else if (ret == 0) { throw error{"encountered EOF on serial device"}; } else { bytes_read += ret;