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:
Daniel Agar
2020-05-06 13:53:54 -04:00
parent 45ebbb895a
commit 746a8f5cf9
96 changed files with 332 additions and 528 deletions
+2 -1
View File
@@ -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);
+1 -2
View File
@@ -33,7 +33,6 @@
px4_add_module(
MODULE systemcmds__shutdown
MAIN shutdown
COMPILE_FLAGS
SRCS
shutdown.c
shutdown.cpp
)
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2016 PX4 Development Team. All rights reserved.
* Copyright (C) 2016-2020 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,16 +35,10 @@
* @file shutdown.c
* Tool similar to UNIX shutdown command.
*/
#include <px4_platform_common/shutdown.h>
#include <px4_platform_common/tasks.h>
__EXPORT int shutdown_main(int argc, char *argv[]);
int shutdown_main(int argc, char *argv[])
extern "C" __EXPORT int shutdown_main(int argc, char *argv[])
{
(void)argc;
(void)argv;
const bool to_bootloader = false;
px4_systemreset(to_bootloader);
return px4_shutdown_request();
}
+1 -1
View File
@@ -58,7 +58,6 @@ set(srcs
test_microbench_matrix.cpp
test_microbench_uorb.cpp
test_mixer.cpp
test_mount.c
test_param.c
test_parameters.cpp
test_perf.c
@@ -80,6 +79,7 @@ set(srcs
if(${PX4_PLATFORM} STREQUAL "nuttx")
list(APPEND srcs
test_mount.cpp
test_time.c
test_uart_break.c
)
@@ -40,6 +40,7 @@
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/posix.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/shutdown.h>
#include <sys/stat.h>
#include <dirent.h>
@@ -56,8 +57,7 @@
const int fsync_tries = 1;
const int abort_tries = 10;
int
test_mount(int argc, char *argv[])
int test_mount(int argc, char *argv[])
{
const unsigned iterations = 2000;
const unsigned alignments = 10;
@@ -289,7 +289,7 @@ test_mount(int argc, char *argv[])
fsync(fileno(stdout));
fsync(fileno(stderr));
px4_usleep(50000);
px4_systemreset(false);
px4_reboot_request();
/* never going to get here */
return 0;
+1 -1
View File
@@ -69,6 +69,7 @@ const struct {
#ifdef __PX4_NUTTX
{"file", test_file, OPT_NOJIGTEST | OPT_NOALLTEST},
{"led", test_led, 0},
{"mount", test_mount, OPT_NOJIGTEST | OPT_NOALLTEST},
{"time", test_time, OPT_NOJIGTEST},
{"uart_baudchange", test_uart_baudchange, OPT_NOJIGTEST},
{"uart_break", test_uart_break, OPT_NOJIGTEST | OPT_NOALLTEST},
@@ -102,7 +103,6 @@ const struct {
{"microbench_uorb", test_microbench_uorb, 0},
{"mixer", test_mixer, OPT_NOJIGTEST},
{"mixer", test_mixer, OPT_NOJIGTEST},
{"mount", test_mount, OPT_NOJIGTEST | OPT_NOALLTEST},
{"param", test_param, 0},
{"parameters", test_parameters, 0},
{"perf", test_perf, OPT_NOJIGTEST},