From 9d924bea3f919a364038fc9b06f4f8d279f94ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=83=C2=BCng?= Date: Mon, 24 Jul 2017 13:12:24 +0200 Subject: [PATCH] reboot command: add lock/unlock commands to test the shutdown lock If needed it could be used in scripts as well. --- src/systemcmds/reboot/reboot.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/systemcmds/reboot/reboot.c b/src/systemcmds/reboot/reboot.c index 2d0c5ae970..ffd8181c64 100644 --- a/src/systemcmds/reboot/reboot.c +++ b/src/systemcmds/reboot/reboot.c @@ -43,6 +43,7 @@ #include #include #include +#include __EXPORT int reboot_main(int argc, char *argv[]); @@ -52,6 +53,8 @@ static void print_usage(void) PRINT_MODULE_USAGE_NAME_SIMPLE("reboot", "command"); PRINT_MODULE_USAGE_PARAM_FLAG('b', "Reboot into bootloader", true); + + PRINT_MODULE_USAGE_ARG("lock|unlock", "Take/release the shutdown lock (for testing)", true); } int reboot_main(int argc, char *argv[]) @@ -75,6 +78,28 @@ int reboot_main(int argc, char *argv[]) } } + if (myoptind >= 0 && myoptind < argc) { + int ret = -1; + + if (strcmp(argv[myoptind], "lock") == 0) { + ret = px4_shutdown_lock(); + + if (ret != 0) { + PX4_ERR("lock failed (%i)", ret); + } + } + + if (strcmp(argv[myoptind], "unlock") == 0) { + ret = px4_shutdown_unlock(); + + if (ret != 0) { + PX4_ERR("unlock failed (%i)", ret); + } + } + + return ret; + } + int ret = px4_shutdown_request(true, to_bootloader); if (ret < 0) {