From d128d8482048e39e13631c13e58849799f205077 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 30 Dec 2023 13:34:57 +1100 Subject: [PATCH] HAL_SITL: fixed unbuffered UART writes in SITL this was causing PPP to slow down by about 1000x due to duplicate writes --- libraries/AP_HAL_SITL/UARTDriver.cpp | 1 + libraries/AP_HAL_SITL/UARTDriver.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libraries/AP_HAL_SITL/UARTDriver.cpp b/libraries/AP_HAL_SITL/UARTDriver.cpp index 1fa4d0f9685672..9b7516af6938bb 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.cpp +++ b/libraries/AP_HAL_SITL/UARTDriver.cpp @@ -799,6 +799,7 @@ uint16_t UARTDriver::read_from_async_csv(uint8_t *buffer, uint16_t space) void UARTDriver::handle_writing_from_writebuffer_to_device() { + WITH_SEMAPHORE(write_mtx); if (!_connected) { _check_reconnect(); return; diff --git a/libraries/AP_HAL_SITL/UARTDriver.h b/libraries/AP_HAL_SITL/UARTDriver.h index 7555ae596b9a06..70d1fa332f4b27 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.h +++ b/libraries/AP_HAL_SITL/UARTDriver.h @@ -109,6 +109,8 @@ class HALSITL::UARTDriver : public AP_HAL::UARTDriver { uint32_t last_read_tick_us; uint32_t last_write_tick_us; + HAL_Semaphore write_mtx; + SITL::SerialDevice *_sim_serial_device; struct {