Skip to content

Commit

Permalink
commander: add check for 5V overcurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
bkueng committed May 22, 2024
1 parent a9962dc commit e1ffc2c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/modules/commander/HealthAndArmingChecks/checks/powerCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class PowerChecks : public HealthAndArmingCheckBase

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,
Expand Down

0 comments on commit e1ffc2c

Please sign in to comment.