mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
commander: do not reboot on USB disconnect when armed
Signed-off-by: Andrei Korigodski <akorigod@gmail.com>
This commit is contained in:
committed by
Julian Oes
parent
2e3926b577
commit
4a330c6e0a
@@ -197,6 +197,8 @@ void print_reject_arm(const char *msg);
|
|||||||
|
|
||||||
void print_status();
|
void print_status();
|
||||||
|
|
||||||
|
bool shutdown_if_allowed();
|
||||||
|
|
||||||
transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub, const char *armedBy);
|
transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub, const char *armedBy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -521,6 +523,13 @@ void print_status()
|
|||||||
PX4_INFO("arming: %s", arming_state_names[status.arming_state]);
|
PX4_INFO("arming: %s", arming_state_names[status.arming_state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shutdown_if_allowed()
|
||||||
|
{
|
||||||
|
return TRANSITION_DENIED != arming_state_transition(&status, safety, vehicle_status_s::ARMING_STATE_REBOOT,
|
||||||
|
&armed, false /* fRunPreArmChecks */, &mavlink_log_pub, &status_flags, arm_requirements,
|
||||||
|
hrt_elapsed_time(&commander_boot_timestamp));
|
||||||
|
}
|
||||||
|
|
||||||
transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub_local, const char *armedBy)
|
transition_result_t arm_disarm(bool arm, orb_advert_t *mavlink_log_pub_local, const char *armedBy)
|
||||||
{
|
{
|
||||||
transition_result_t arming_res = TRANSITION_NOT_CHANGED;
|
transition_result_t arming_res = TRANSITION_NOT_CHANGED;
|
||||||
@@ -1511,7 +1520,7 @@ Commander::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if the USB hardware connection went away, reboot */
|
/* if the USB hardware connection went away, reboot */
|
||||||
if (status_flags.usb_connected && !system_power.usb_connected) {
|
if (status_flags.usb_connected && !system_power.usb_connected && shutdown_if_allowed()) {
|
||||||
/*
|
/*
|
||||||
* apparently the USB cable went away but we are still powered,
|
* apparently the USB cable went away but we are still powered,
|
||||||
* so lets reset to a classic non-usb state.
|
* so lets reset to a classic non-usb state.
|
||||||
|
|||||||
Reference in New Issue
Block a user