mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 17:43:34 +08:00
battery: skip charge estimation if N cells is 0
This triggers the undefined behaviour fuzzer, so let's try to fix it. Signed-off-by: Julian Oes <julian@oes.ch>
This commit is contained in:
@@ -206,6 +206,10 @@ void Battery::sumDischarged(const hrt_abstime ×tamp, float current_a)
|
|||||||
|
|
||||||
float Battery::calculateStateOfChargeVoltageBased(const float voltage_v, const float current_a)
|
float Battery::calculateStateOfChargeVoltageBased(const float voltage_v, const float current_a)
|
||||||
{
|
{
|
||||||
|
if (_params.n_cells == 0) {
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// remaining battery capacity based on voltage
|
// remaining battery capacity based on voltage
|
||||||
float cell_voltage = voltage_v / _params.n_cells;
|
float cell_voltage = voltage_v / _params.n_cells;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user