From 5a13c4384f393664c23f4e1577bd95b944227066 Mon Sep 17 00:00:00 2001 From: Gregor Best Date: Sun, 3 Jan 2016 17:35:59 +0100 Subject: [PATCH] Implement serial port baudrate selection for OpenBSD Signed-off-by: Gregor Best --- xs/src/libslic3r/GCodeSender.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/GCodeSender.cpp b/xs/src/libslic3r/GCodeSender.cpp index c9c3cf22d..3e41cf526 100644 --- a/xs/src/libslic3r/GCodeSender.cpp +++ b/xs/src/libslic3r/GCodeSender.cpp @@ -8,14 +8,15 @@ #include #include +#if defined(__APPLE__) || defined(__linux) || defined(__OpenBSD__) +#include +#endif #if __APPLE__ #include -#include #include #endif #ifdef __linux #include -#include #include #endif @@ -99,8 +100,7 @@ GCodeSender::set_baud_rate(unsigned int baud_rate) speed_t newSpeed = baud_rate; ioctl(handle, IOSSIOSPEED, &newSpeed); ::tcsetattr(handle, TCSANOW, &ios); -#endif -#ifdef __linux +#elif __linux termios ios; ::tcgetattr(handle, &ios); ::cfsetispeed(&ios, B38400); @@ -121,6 +121,13 @@ GCodeSender::set_baud_rate(unsigned int baud_rate) } ioctl(handle, TIOCSSERIAL, &ss); + printf("< set_baud_rate: %u\n", baud_rate); +#elif __OpenBSD__ + struct termios ios; + ::tcgetattr(handle, &ios); + ::cfsetspeed(&ios, baud_rate); + if (::tcsetattr(handle, TCSAFLUSH, &ios) != 0) + printf("Failed to set baud rate: %s\n", strerror(errno)); #else //throw invalid_argument ("OS does not currently support custom bauds"); #endif