mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-13 20:10:35 +08:00
commander: ensure health report is always sent out before failsafe notificaation
As the failsafe message can reference the health report, the health report needs to be sent out first. This is generally the case, except there is a rate limiter set to 2 seconds. So if the report changes quickly, it is sent out delayed (potentially after the failsafe report).
This commit is contained in:
@@ -716,6 +716,8 @@ Commander::Commander() :
|
||||
}
|
||||
|
||||
updateParameters();
|
||||
|
||||
_failsafe.setOnNotifyUserCallback(&Commander::onFailsafeNotifyUserTrampoline, this);
|
||||
}
|
||||
|
||||
Commander::~Commander()
|
||||
@@ -3000,6 +3002,20 @@ void Commander::send_parachute_command()
|
||||
set_tune_override(tune_control_s::TUNE_ID_PARACHUTE_RELEASE);
|
||||
}
|
||||
|
||||
void Commander::onFailsafeNotifyUserTrampoline(void *arg)
|
||||
{
|
||||
Commander *commander = static_cast<Commander *>(arg);
|
||||
commander->onFailsafeNotifyUser();
|
||||
}
|
||||
|
||||
void Commander::onFailsafeNotifyUser()
|
||||
{
|
||||
// If we are about to inform about a failsafe, we need to ensure any pending health report is sent out first,
|
||||
// as the failsafe message might reference that. This is only needed in case the report is currently rate-limited,
|
||||
// i.e. it had a recent previous change already.
|
||||
_health_and_arming_checks.reportIfUnreportedDifferences();
|
||||
}
|
||||
|
||||
int Commander::print_usage(const char *reason)
|
||||
{
|
||||
if (reason) {
|
||||
|
||||
Reference in New Issue
Block a user