AP_GPS: fixed handling of empty HDT/THS sentences

fixes #22432
This commit is contained in:
Andrew Tridgell 2022-12-19 08:02:12 +11:00
parent 01cad1c4aa
commit fc5ae600ef

View File

@ -48,6 +48,9 @@ extern const AP_HAL::HAL& hal;
#define AP_GPS_NMEA_CONFIG_PERIOD_MS 15000U
#endif
// a quiet nan for invalid values
#define QNAN nanf("GPS")
// Convenience macros //////////////////////////////////////////////////////////
//
#define DIGIT_TO_VAL(_x) (_x - '0')
@ -120,6 +123,7 @@ bool AP_GPS_NMEA::_decode(char c)
_is_checksum_term = false;
_sentence_length = 1;
_sentence_done = false;
_new_gps_yaw = QNAN;
return false;
}
@ -377,6 +381,10 @@ bool AP_GPS_NMEA::_term_complete()
// use AGRICA
break;
}
if (isnan(_new_gps_yaw)) {
// empty sentence
break;
}
_last_yaw_ms = now;
state.gps_yaw = wrap_360(_new_gps_yaw*0.01f);
state.have_gps_yaw = true;