1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Fix data type overflow in HDOP calculation in Smartport telemetry

Calculation used uint8_t which overflowed and corrupted the satellite count portion of the telemetry value.
This commit is contained in:
Bruce Luckcuck 2019-10-26 19:36:25 -04:00
parent 13d46c7d84
commit 8aa86c25cf

View file

@ -763,7 +763,7 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear
#ifdef USE_GPS
if (sensors(SENSOR_GPS)) {
// satellite accuracy HDOP: 0 = worst [HDOP > 5.5m], 9 = best [HDOP <= 1.0m]
uint8_t hdop = constrain(scaleRange(gpsSol.hdop, 100, 550, 9, 0), 0, 9) * 100;
uint16_t hdop = constrain(scaleRange(gpsSol.hdop, 100, 550, 9, 0), 0, 9) * 100;
smartPortSendPackage(id, (STATE(GPS_FIX) ? 1000 : 0) + (STATE(GPS_FIX_HOME) ? 2000 : 0) + hdop + gpsSol.numSat);
*clearToSend = false;
} else if (featureIsEnabled(FEATURE_GPS)) {