commander: add check for 5V overcurrent

This commit is contained in:
Beat Küng
2024-05-16 15:51:04 +02:00
parent a9962dc44d
commit e1ffc2cdaa
2 changed files with 31 additions and 0 deletions
@@ -142,6 +142,36 @@ void PowerChecks::checkAndReport(const Context &context, Report &reporter)
power_module_count, _param_com_power_count.get());
}
}
// Overcurrent detection
if (system_power.hipower_5v_oc) {
/* EVENT
* @description
* Check the power supply
*/
reporter.healthFailure(NavModes::All, health_component_t::system,
events::ID("check_power_oc_hipower"),
events::Log::Error, "Overcurrent detected for the hipower 5V supply");
}
if (system_power.periph_5v_oc) {
/* EVENT
* @description
* Check the power supply
*/
reporter.healthFailure(NavModes::All, health_component_t::system,
events::ID("check_power_oc_periph"),
events::Log::Error, "Overcurrent detected for the peripheral 5V supply");
}
if (system_power.hipower_5v_oc || system_power.periph_5v_oc) {
if (context.isArmed() && !_overcurrent_warning_sent) {
_overcurrent_warning_sent = true;
events::send(events::ID("check_power_oc_report"),
events::Log::Error,
"5V overcurrent detected, landing advised");
}
}
}
} else {
@@ -48,6 +48,7 @@ public:
private:
uORB::Subscription _system_power_sub{ORB_ID(system_power)};
bool _overcurrent_warning_sent{false};
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
(ParamInt<px4::params::CBRK_SUPPLY_CHK>) _param_cbrk_supply_chk,