From 7043738f3b9e0bf530219a972799d4e7bd09b42e Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Wed, 20 Jun 2018 02:00:28 -0700 Subject: [PATCH] AP_HAL_Linux: Clear UART buffers when opening a port --- libraries/AP_HAL_Linux/UARTDriver.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/AP_HAL_Linux/UARTDriver.cpp b/libraries/AP_HAL_Linux/UARTDriver.cpp index e3e518fc82..f8308ddaa1 100644 --- a/libraries/AP_HAL_Linux/UARTDriver.cpp +++ b/libraries/AP_HAL_Linux/UARTDriver.cpp @@ -108,6 +108,10 @@ void UARTDriver::_allocate_buffers(uint16_t rxS, uint16_t txS) if (_writebuf.set_size(txS) && _readbuf.set_size(rxS)) { _initialised = true; } + if (hal.console != this) { // don't clear USB buffers (allows early startup messages to escape) + _readbuf.clear(); + _writebuf.clear(); + } } void UARTDriver::_deallocate_buffers()