setRAW in Serial

This commit is contained in:
2021-08-30 12:49:32 +02:00
parent 88e0d4a241
commit f30158383b
3 changed files with 24 additions and 1 deletions

View File

@@ -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();

View File

@@ -165,7 +165,8 @@ public:
void setRTS(bool enabled);
void setDTR(bool enabled);
void setRAW();
~TimeoutSerial();
private:

View File

@@ -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");