From 3c6738e15d480fd226556b2fab7693670c4bcd98 Mon Sep 17 00:00:00 2001 From: Vrong Date: Tue, 18 Jul 2017 22:24:30 +0200 Subject: [PATCH] Fixed badly set bitrate causing sweep object creation to hang on Linux (#117) * Fixed badly set bitrate causing sweep object creation to hang on Linux * Removed redundant condition in get_baud --- libsweep/src/unix/serial.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libsweep/src/unix/serial.cc b/libsweep/src/unix/serial.cc index 14c475e..6c0a1d5 100644 --- a/libsweep/src/unix/serial.cc +++ b/libsweep/src/unix/serial.cc @@ -26,6 +26,11 @@ 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 +#ifdef B115200 + return B115200; +#endif return bitrate; } @@ -148,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;