From c834589daa575f594c1cf340203a032fea74ea8f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 9 Oct 2014 12:27:32 +1100 Subject: [PATCH] HAL_Linux: reduce the number of times we split up UART reads --- libraries/AP_HAL_Linux/UARTDriver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_Linux/UARTDriver.cpp b/libraries/AP_HAL_Linux/UARTDriver.cpp index a87e4220da..1597cbd218 100644 --- a/libraries/AP_HAL_Linux/UARTDriver.cpp +++ b/libraries/AP_HAL_Linux/UARTDriver.cpp @@ -648,12 +648,12 @@ void LinuxUARTDriver::_timer_tick(void) uint16_t _head; n = BUF_SPACE(_readbuf); if (n > 0) { - if (_readbuf_tail < _head) { + uint16_t n1 = _readbuf_size - _readbuf_tail; + if (n1 >= n) { // one read will do assert(_readbuf_tail+n <= _readbuf_size); _read_fd(&_readbuf[_readbuf_tail], n); } else { - uint16_t n1 = _readbuf_size - _readbuf_tail; assert(_readbuf_tail+n1 <= _readbuf_size); int ret = _read_fd(&_readbuf[_readbuf_tail], n1); if (ret == n1 && n > n1) {