From ba75b9c35e14de9dd05c20a68fd6244577d70939 Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Wed, 25 Sep 2024 08:18:05 -0800 Subject: [PATCH] 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. --- platforms/nuttx/src/px4/common/SerialImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/nuttx/src/px4/common/SerialImpl.cpp b/platforms/nuttx/src/px4/common/SerialImpl.cpp index 4264976f44..904d6124b1 100644 --- a/platforms/nuttx/src/px4/common/SerialImpl.cpp +++ b/platforms/nuttx/src/px4/common/SerialImpl.cpp @@ -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);