mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 02:13:34 +08:00
protocol_splitter: tcflush() uart before closing it
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user