CF/BF - Ensure that ESC voltage/current meters do not read random memory
when reading data from unconfigured motors.
This commit is contained in:
parent
526c15521d
commit
1f4644557d
|
@ -220,11 +220,12 @@ void currentMeterESCReadMotor(uint8_t motorNumber, currentMeter_t *meter)
|
|||
currentMeterReset(meter);
|
||||
#else
|
||||
escSensorData_t *escData = getEscSensorData(motorNumber);
|
||||
if (escData->dataAge <= ESC_BATTERY_AGE_MAX) {
|
||||
if (escData && escData->dataAge <= ESC_BATTERY_AGE_MAX) {
|
||||
meter->amperage = escData->current;
|
||||
meter->amperageLatest = escData->current;
|
||||
meter->mAhDrawn = escData->consumption;
|
||||
return;
|
||||
} else {
|
||||
currentMeterReset(meter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -221,9 +221,13 @@ void voltageMeterESCReadMotor(uint8_t motorNumber, voltageMeter_t *voltageMeter)
|
|||
voltageMeterReset(voltageMeter);
|
||||
#else
|
||||
escSensorData_t *escData = getEscSensorData(motorNumber);
|
||||
if (escData) {
|
||||
voltageMeter->unfiltered = escData->dataAge <= ESC_BATTERY_AGE_MAX ? escData->voltage / 10 : 0;
|
||||
voltageMeter->filtered = voltageMeter->unfiltered; // no filtering for ESC motors currently.
|
||||
} else {
|
||||
voltageMeterReset(voltageMeter);
|
||||
}
|
||||
|
||||
voltageMeter->unfiltered = escData->dataAge <= ESC_BATTERY_AGE_MAX ? escData->voltage / 10 : 0;
|
||||
voltageMeter->filtered = voltageMeter->unfiltered; // no filtering for ESC motors currently.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue