diff --git a/libraries/AP_HAL_ChibiOS/UARTDriver.cpp b/libraries/AP_HAL_ChibiOS/UARTDriver.cpp index 888f9a6671..624a8e7a91 100644 --- a/libraries/AP_HAL_ChibiOS/UARTDriver.cpp +++ b/libraries/AP_HAL_ChibiOS/UARTDriver.cpp @@ -582,6 +582,27 @@ bool UARTDriver::discard_input() return true; } +ssize_t UARTDriver::read(uint8_t *buffer, uint16_t count) +{ + if (lock_read_key != 0 || _uart_owner_thd != chThdGetSelfX()){ + return -1; + } + if (!_initialised) { + return -1; + } + + const uint32_t ret = _readbuf.read(buffer, count); + if (ret == 0) { + return 0; + } + + if (!_rts_is_active) { + update_rts_line(); + } + + return ret; +} + int16_t UARTDriver::read() { if (lock_read_key != 0 || _uart_owner_thd != chThdGetSelfX()){ diff --git a/libraries/AP_HAL_ChibiOS/UARTDriver.h b/libraries/AP_HAL_ChibiOS/UARTDriver.h index 7ebf4d5d02..10581ff234 100644 --- a/libraries/AP_HAL_ChibiOS/UARTDriver.h +++ b/libraries/AP_HAL_ChibiOS/UARTDriver.h @@ -44,6 +44,7 @@ public: uint32_t available() override; uint32_t txspace() override; int16_t read() override; + ssize_t read(uint8_t *buffer, uint16_t count) override; int16_t read_locked(uint32_t key) override; void _timer_tick(void) override;