mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 01:53:33 +08:00
commander: reboot/shutdown usability fixes
- always check with state machine before reboot/shutdown - respect BOARD_HAS_POWER_CONTROL (shutdown from command, low battery, power button) - px4_shutdown_request add optional delay and always execute from HPWORK - px4_shutdown_request split out px4_reboot_request
This commit is contained in:
@@ -35,7 +35,8 @@ px4_add_module(
|
||||
MAIN reboot
|
||||
COMPILE_FLAGS
|
||||
SRCS
|
||||
reboot.c
|
||||
reboot.cpp
|
||||
DEPENDS
|
||||
px4_platform
|
||||
)
|
||||
|
||||
|
||||
@@ -45,9 +45,7 @@
|
||||
#include <px4_platform_common/shutdown.h>
|
||||
#include <string.h>
|
||||
|
||||
__EXPORT int reboot_main(int argc, char *argv[]);
|
||||
|
||||
static void print_usage(void)
|
||||
static void print_usage()
|
||||
{
|
||||
PRINT_MODULE_DESCRIPTION("Reboot the system");
|
||||
|
||||
@@ -57,13 +55,13 @@ static void print_usage(void)
|
||||
PRINT_MODULE_USAGE_ARG("lock|unlock", "Take/release the shutdown lock (for testing)", true);
|
||||
}
|
||||
|
||||
int reboot_main(int argc, char *argv[])
|
||||
extern "C" __EXPORT int reboot_main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
bool to_bootloader = false;
|
||||
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = NULL;
|
||||
const char *myoptarg = nullptr;
|
||||
|
||||
while ((ch = px4_getopt(argc, argv, "b", &myoptind, &myoptarg)) != -1) {
|
||||
switch (ch) {
|
||||
@@ -100,7 +98,7 @@ int reboot_main(int argc, char *argv[])
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ret = px4_shutdown_request(true, to_bootloader);
|
||||
int ret = px4_reboot_request(to_bootloader);
|
||||
|
||||
if (ret < 0) {
|
||||
PX4_ERR("reboot failed (%i)", ret);
|
||||
Reference in New Issue
Block a user