protocol_splitter: tcflush() uart before closing it

This commit is contained in:
Beat Küng
2021-06-17 09:40:57 -04:00
committed by Daniel Agar
parent 14ec7a0d93
commit 1c3f30be01
@@ -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)
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);
}
}