AP_GPS_NOVA: avoid infinite reading of bytes

if we have a very fast stream of garbage coming in available() may never return 0
This commit is contained in:
Peter Barker 2023-08-10 10:07:56 +10:00 committed by Andrew Tridgell
parent ac993753eb
commit 941e9785d4

View File

@ -86,8 +86,11 @@ AP_GPS_NOVA::read(void)
} }
bool ret = false; bool ret = false;
while (port->available() > 0) { for (uint16_t i=0; i<8192; i++) {
uint8_t temp = port->read(); uint8_t temp;
if (!port->read(temp)) {
break;
}
#if AP_GPS_DEBUG_LOGGING_ENABLED #if AP_GPS_DEBUG_LOGGING_ENABLED
log_data(&temp, 1); log_data(&temp, 1);
#endif #endif