mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
mavlink: tcflush() uart before closing it
On NuttX with flow control, if no one was reading from the uart, the close() call would block indefinitely waiting for data to be sent.
This commit is contained in:
@@ -324,12 +324,9 @@ Mavlink::destroy_all_instances()
|
||||
}
|
||||
}
|
||||
|
||||
//we know all threads have exited, so it's safe to manipulate the linked list and delete objects.
|
||||
//we know all threads have exited, so it's safe to delete objects.
|
||||
for (Mavlink *inst_to_del : mavlink_module_instances) {
|
||||
if (inst_to_del != nullptr) {
|
||||
delete inst_to_del;
|
||||
inst_to_del = nullptr;
|
||||
}
|
||||
delete inst_to_del;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
@@ -2533,6 +2530,8 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
_streams.clear();
|
||||
|
||||
if (_uart_fd >= 0 && !_is_usb_uart) {
|
||||
/* discard all pending data, as close() might block otherwise on NuttX with flow control enabled */
|
||||
tcflush(_uart_fd, TCIOFLUSH);
|
||||
/* close UART */
|
||||
::close(_uart_fd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user