Skip to content

Commit

Permalink
added flush function for serial port
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwatkins committed Aug 18, 2017
1 parent 90c3176 commit 208e74a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/serial/include/serial/SerialPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class SerialPort {
int sendArray(unsigned char *buffer, int len);
int sendString(std::string msg);
int getArray (unsigned char *buffer, int len);

void flushPort(boost::asio::serial_port& serial_port, flush_type what);

enum flush_type
{
flush_receive = TCIFLUSH,
flush_send = TCIOFLUSH,
flush_both = TCIOFLUSH
};
};


Expand Down
7 changes: 7 additions & 0 deletions src/serial/src/serial/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "serial/SerialPort.h"



SerialPort::SerialPort() {
port = new boost::asio::serial_port(io);
}
Expand Down Expand Up @@ -38,4 +39,10 @@ int SerialPort::getArray (unsigned char *buffer, int len){
return i;
}

void SerialPort::flushPort(boost::asio::serial_port& serial_port, flush_type what)
{
::tcflush(serial_port.lowest_layer().native_handle(), what);
}



0 comments on commit 208e74a

Please sign in to comment.