From 8680f1ab52c3558149f72eacc4caf2f853069eb8 Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Wed, 20 Jun 2018 02:01:08 -0700 Subject: [PATCH] AP_HAL_SITL: Clear UART buffers when opening a port --- libraries/AP_HAL_SITL/UARTDriver.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/AP_HAL_SITL/UARTDriver.cpp b/libraries/AP_HAL_SITL/UARTDriver.cpp index 607fde7d48..f605bc2c37 100644 --- a/libraries/AP_HAL_SITL/UARTDriver.cpp +++ b/libraries/AP_HAL_SITL/UARTDriver.cpp @@ -105,6 +105,11 @@ void UARTDriver::begin(uint32_t baud, uint16_t rxSpace, uint16_t txSpace) free(s); } + if (hal.console != this) { // don't clear USB buffers (allows early startup messages to escape) + _readbuffer.clear(); + _writebuffer.clear(); + } + _set_nonblocking(_fd); }