reboot command: add lock/unlock commands to test the shutdown lock

If needed it could be used in scripts as well.
This commit is contained in:
Beat Küng 2017-07-24 13:12:24 +02:00 committed by Lorenz Meier
parent dcb5f80180
commit 9d924bea3f
1 changed files with 25 additions and 0 deletions

View File

@ -43,6 +43,7 @@
#include <px4_module.h>
#include <px4_shutdown.h>
#include <systemlib/systemlib.h>
#include <string.h>
__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) {