From 85f89812d5d4f2a55a26ab82c51bae092122fc6d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 27 Jun 2024 18:40:21 +1000 Subject: [PATCH] AP_Generator: avoid use of int16_t-read --- libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp b/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp index 21725b932c..7a13bed22e 100644 --- a/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp @@ -43,11 +43,9 @@ void AP_Generator_IE_FuelCell::update() const uint32_t now = AP_HAL::millis(); // Read any available data - uint32_t nbytes = MIN(_uart->available(),30u); - while (nbytes-- > 0) { - const int16_t c = _uart->read(); - if (c < 0) { - // Nothing to decode + for (uint8_t i=0; i<30; i++) { // process at most n bytes + uint8_t c; + if (!_uart->read(c)) { break; }