AP_GPS: NMEA: only decode each measage once

This commit is contained in:
Iampete1 2020-07-29 09:47:37 +01:00 committed by Peter Barker
parent e1b6ef3e14
commit 997ffcf30d
2 changed files with 6 additions and 0 deletions

View File

@ -87,6 +87,9 @@ bool AP_GPS_NMEA::_decode(char c)
case '\r':
case '\n':
case '*':
if (_sentence_done) {
return false;
}
if (_term_offset < sizeof(_term)) {
_term[_term_offset] = 0;
valid_sentence = _term_complete();
@ -103,6 +106,7 @@ bool AP_GPS_NMEA::_decode(char c)
_is_checksum_term = false;
_gps_data_good = false;
_sentence_length = 1;
_sentence_done = false;
return valid_sentence;
}
@ -227,6 +231,7 @@ bool AP_GPS_NMEA::_term_complete()
{
// handle the last term in a message
if (_is_checksum_term) {
_sentence_done = true;
uint8_t nibble_high = 0;
uint8_t nibble_low = 0;
if (!hex_to_uint8(_term[0], nibble_high) || !hex_to_uint8(_term[1], nibble_low)) {

View File

@ -122,6 +122,7 @@ private:
uint8_t _term_offset; ///< character offset with the term being received
uint16_t _sentence_length;
bool _gps_data_good; ///< set when the sentence indicates data is good
bool _sentence_done; ///< set when a sentence has been fully decoded
// The result of parsing terms within a message is stored temporarily until
// the message is completely processed and the checksum validated.