setRAW in Serial
This commit is contained in:
@@ -260,6 +260,27 @@ void TimeoutSerial::readCompleted(const boost::system::error_code& error,
|
|||||||
result=resultError;
|
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)
|
void TimeoutSerial::setRTS(bool enabled)
|
||||||
{
|
{
|
||||||
int fd = port.native_handle();
|
int fd = port.native_handle();
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ public:
|
|||||||
|
|
||||||
void setRTS(bool enabled);
|
void setRTS(bool enabled);
|
||||||
void setDTR(bool enabled);
|
void setDTR(bool enabled);
|
||||||
|
void setRAW();
|
||||||
|
|
||||||
~TimeoutSerial();
|
~TimeoutSerial();
|
||||||
|
|
||||||
|
|||||||
1
main.cpp
1
main.cpp
@@ -152,6 +152,7 @@ int main(int argc, char* argv[])
|
|||||||
serial.setTimeout(posix_time::seconds(5));
|
serial.setTimeout(posix_time::seconds(5));
|
||||||
serial.setDTR(false);
|
serial.setDTR(false);
|
||||||
serial.setRTS(false);
|
serial.setRTS(false);
|
||||||
|
serial.setRAW();
|
||||||
boost::this_thread::sleep(posix_time::milliseconds(5000));
|
boost::this_thread::sleep(posix_time::milliseconds(5000));
|
||||||
|
|
||||||
line = serial.readStringUntil("\n");
|
line = serial.readStringUntil("\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user