From f30158383b63975d56be29539915f3c6e3958df9 Mon Sep 17 00:00:00 2001 From: Jaro Date: Mon, 30 Aug 2021 12:49:32 +0200 Subject: [PATCH] setRAW in Serial --- TimeoutSerial.cpp | 21 +++++++++++++++++++++ TimeoutSerial.h | 3 ++- main.cpp | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/TimeoutSerial.cpp b/TimeoutSerial.cpp index 405b061..d59109d 100755 --- a/TimeoutSerial.cpp +++ b/TimeoutSerial.cpp @@ -260,6 +260,27 @@ void TimeoutSerial::readCompleted(const boost::system::error_code& error, result=resultError; } +void TimeoutSerial::setRAW() +{ + int fd = port.native_handle(); + struct termios options; + + fcntl(fd, F_SETFL, 0); + + /* get the current options */ + tcgetattr(fd, &options); + + options.c_cflag |= (CLOCAL | CREAD); + options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); + options.c_oflag &= ~OPOST; + + tcsetattr(fd, TCSANOW, &options); + +} + + + + void TimeoutSerial::setRTS(bool enabled) { int fd = port.native_handle(); diff --git a/TimeoutSerial.h b/TimeoutSerial.h index 598126a..21af1ab 100755 --- a/TimeoutSerial.h +++ b/TimeoutSerial.h @@ -165,7 +165,8 @@ public: void setRTS(bool enabled); void setDTR(bool enabled); - + void setRAW(); + ~TimeoutSerial(); private: diff --git a/main.cpp b/main.cpp index afdc96a..22cd577 100755 --- a/main.cpp +++ b/main.cpp @@ -152,6 +152,7 @@ int main(int argc, char* argv[]) serial.setTimeout(posix_time::seconds(5)); serial.setDTR(false); serial.setRTS(false); + serial.setRAW(); boost::this_thread::sleep(posix_time::milliseconds(5000)); line = serial.readStringUntil("\n");