Browse Source

protocol_splitter: tcflush() uart before closing it

release/1.12
Beat Küng 4 years ago committed by Daniel Agar
parent
commit
1c3f30be01
  1. 3
      src/drivers/protocol_splitter/protocol_splitter.cpp

3
src/drivers/protocol_splitter/protocol_splitter.cpp

@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
#include <sys/ioctl.h>
#include <assert.h>
#include <unistd.h>
#include <termios.h>
#include <cstdint>
#include <string.h>
@ -220,6 +221,8 @@ DevCommon::DevCommon(const char *device_path) @@ -220,6 +221,8 @@ DevCommon::DevCommon(const char *device_path)
DevCommon::~DevCommon()
{
if (_fd >= 0) {
/* discard all pending data, as close() might block otherwise on NuttX with flow control enabled */
tcflush(_fd, TCIOFLUSH);
::close(_fd);
}
}

Loading…
Cancel
Save