From 86f5c0eec3c7b4b19cb70086228db29a24a7b17d Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 19 Nov 2024 18:13:28 +0100 Subject: [PATCH] batteryCheck: fix enabling circuit breaker still causing battery failsafes Failing checks caused failsafe flags to stay true when enabling the circuit breaker but not rebooting. Resetting the failsafe flags state when the circuit breaker is set resolves this issue. --- .../commander/HealthAndArmingChecks/checks/batteryCheck.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp index 339eae1a3a2c..d453c724d5a4 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/batteryCheck.cpp @@ -75,6 +75,10 @@ static constexpr const char *battery_fault_reason_str(battery_fault_reason_t bat void BatteryChecks::checkAndReport(const Context &context, Report &reporter) { if (circuit_breaker_enabled_by_val(_param_cbrk_supply_chk.get(), CBRK_SUPPLY_CHK_KEY)) { + // Reset related failsafe flags otherwise failures from before disabling the check cause failsafes without reported reason + reporter.failsafeFlags().battery_unhealthy = false; + reporter.failsafeFlags().battery_low_remaining_time = false; + reporter.failsafeFlags().battery_warning = battery_status_s::BATTERY_WARNING_NONE; return; }