mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-30 02:30:35 +08:00
fix commander: need to copy all battery states in a cycle
Previously if in a cycle only a disconnected battery status updated, the battery health state would switch to unhealthy during that time. Fixes intermittent 'Arming denied! Check battery' preflight failures on v5x with 1 power module connected.
This commit is contained in:
@@ -3796,13 +3796,12 @@ void Commander::battery_status_check()
|
||||
battery_status_s batteries[ORB_MULTI_MAX_INSTANCES];
|
||||
size_t num_connected_batteries = 0;
|
||||
|
||||
|
||||
for (size_t i = 0; i < sizeof(_battery_subs) / sizeof(_battery_subs[0]); i++) {
|
||||
if (_battery_subs[i].updated() && _battery_subs[i].copy(&batteries[num_connected_batteries])) {
|
||||
// We need to update the status flag if ANY battery is updated, because the system source might have
|
||||
// changed, or might be nothing (if there is no battery connected)
|
||||
battery_sub_updated = true;
|
||||
// We need to update the status flag if ANY battery is updated, because the system source might have
|
||||
// changed, or might be nothing (if there is no battery connected)
|
||||
battery_sub_updated |= _battery_subs[i].updated();
|
||||
|
||||
if (_battery_subs[i].copy(&batteries[num_connected_batteries])) {
|
||||
if (batteries[num_connected_batteries].connected) {
|
||||
num_connected_batteries++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user