AP_RangeFinder_NMEA: add hondex custom message support

This commit is contained in:
Randy Mackay 2021-10-15 21:04:22 +09:00 committed by Peter Barker
parent 2bffaef9ca
commit 85dbb70df5
2 changed files with 10 additions and 2 deletions

View File

@ -124,7 +124,7 @@ bool AP_RangeFinder_NMEA::decode_latest_term()
}
const uint8_t checksum = (nibble_high << 4u) | nibble_low;
if (checksum == _checksum) {
if ((_sentence_type == SONAR_DBT || _sentence_type == SONAR_DPT) && !is_negative(_distance_m)) {
if ((_sentence_type == SONAR_DBT || _sentence_type == SONAR_DPT || _sentence_type == SONAR_HDED) && !is_negative(_distance_m)) {
// return true if distance is valid
return true;
}
@ -155,6 +155,8 @@ bool AP_RangeFinder_NMEA::decode_latest_term()
_sentence_type = SONAR_DPT;
} else if (strcmp(term_type, "MTW") == 0) {
_sentence_type = SONAR_MTW;
} else if (strcmp(term_type, "ED") == 0) {
_sentence_type = SONAR_HDED;
} else {
_sentence_type = SONAR_UNKNOWN;
}
@ -176,6 +178,11 @@ bool AP_RangeFinder_NMEA::decode_latest_term()
if (_term_number == 1) {
_temp_unvalidated = strtof(_term, NULL);
}
} else if (_sentence_type == SONAR_HDED) {
// parse HDED (Hondex custom message)
if (_term_number == 4) {
_distance_m = strtof(_term, NULL);
}
}
return false;

View File

@ -38,7 +38,8 @@ private:
SONAR_UNKNOWN = 0,
SONAR_DBT,
SONAR_DPT,
SONAR_MTW // mean water temperature
SONAR_MTW, // mean water temperature
SONAR_HDED, // hondex custom sonar message
};
// get a distance reading