selfcheck.py: address situation when individual cells voltage is unknown

When length of cell_voltage array is 1, it means that cell voltage is
unknown and overall voltage is reported instead. Consider this situation
gathering the number of cells from PX4 parameters.
This commit is contained in:
Oleg Kalachev
2024-04-25 22:20:01 +03:00
parent dacaa8ebde
commit 70439f172d

View File

@@ -303,6 +303,14 @@ def check_fcu():
failure('cell voltage is not available, https://clover.coex.tech/power')
else:
cell = battery.cell_voltage[0]
# number of cells 1 means this is overall voltage
if len(battery.cell_voltage) == 1:
n_cells = get_param('BAT1_N_CELLS', strict=False)
if n_cells is None:
# older PX4
n_cells = get_param('BAT_N_CELLS', strict=True)
cell /= n_cells
if cell > 4.3 or cell < 3.0:
failure('incorrect cell voltage: %.2f V, https://clover.coex.tech/power', cell)
elif cell < 3.7: