diff --git a/libraries/AP_HAL_SITL/UARTDriver.cpp b/libraries/AP_HAL_SITL/UARTDriver.cpp index 401fb17a0c..b30dad3e79 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.cpp +++ b/libraries/AP_HAL_SITL/UARTDriver.cpp @@ -787,6 +787,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 cac1dc4e7a..45c00de18b 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.h +++ b/libraries/AP_HAL_SITL/UARTDriver.h @@ -110,6 +110,8 @@ private: uint32_t last_read_tick_us; uint32_t last_write_tick_us; + HAL_Semaphore write_mtx; + SITL::SerialDevice *_sim_serial_device; struct {