mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-09 08:00:35 +08:00
mavlink USB auto start/stop on boards with VBUS
- no longer start sercon or mavlink usb by default - on USB connection (VBUS) monitor serial USB at low rate and start Mavlink if there's a HEARTBEAT or nshterm on 3 consecutive carriage returns - the mavlink USB instance is automatically stopped and serdis executed if USB is disconnected - skipping Mavlink USB (and sercon) saves a considerable amount of memory on older boards
This commit is contained in:
@@ -1911,31 +1911,6 @@ Commander::run()
|
||||
_status_flags.condition_power_input_valid = true;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_RESET)
|
||||
|
||||
if (!_status_flags.circuit_breaker_engaged_usb_check && _status_flags.usb_connected) {
|
||||
/* if the USB hardware connection went away, reboot */
|
||||
if (_system_power_usb_connected && !system_power.usb_connected) {
|
||||
/*
|
||||
* Apparently the USB cable went away but we are still powered,
|
||||
* so we bring the system back to a nominal state for flight.
|
||||
* This is important to unload the USB stack of the OS which is
|
||||
* a relatively complex piece of software that is non-essential
|
||||
* for flight and continuing to run it would add a software risk
|
||||
* without a need. The clean approach to unload it is to reboot.
|
||||
*/
|
||||
if (shutdown_if_allowed() && (px4_reboot_request(false, 400_ms) == 0)) {
|
||||
mavlink_log_critical(&_mavlink_log_pub, "USB disconnected, rebooting for flight safety\t");
|
||||
events::send(events::ID("commander_reboot_usb_disconnect"), {events::Log::Critical, events::LogInternal::Info},
|
||||
"USB disconnected, rebooting for flight safety");
|
||||
|
||||
while (1) { px4_usleep(1); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CONFIG_BOARDCTL_RESET
|
||||
|
||||
_system_power_usb_connected = system_power.usb_connected;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user