mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 07:28:54 +08:00
platforms/nuttx: Serial change fsync to tcdrain
Calling serial::write() in quick succession was blowing away the previous buffer, fsync does not guarantee that data is transmitted on serial lines. On the other hand tcdrain waits until the output buffer is empty.
This commit is contained in:
@@ -339,7 +339,7 @@ ssize_t SerialImpl::write(const void *buffer, size_t buffer_size)
|
||||
}
|
||||
|
||||
int written = ::write(_serial_fd, buffer, buffer_size);
|
||||
::fsync(_serial_fd);
|
||||
tcdrain(_serial_fd); // Wait until all output is transmitted
|
||||
|
||||
if (written < 0) {
|
||||
PX4_ERR("%s write error %d", _port, written);
|
||||
|
||||
Reference in New Issue
Block a user