apps/nshlib: Expand reboot and poweroff commands to include a second, optional mode argument
This commit is contained in:
parent
23066a71f0
commit
bee98898f0
@ -416,8 +416,8 @@ config NSH_DISABLE_PASSWD
|
||||
|
||||
config NSH_DISABLE_POWEROFF
|
||||
bool "Disable poweroff"
|
||||
default n if !DEFAULT_SMALL && !BOARDCTL_RESET
|
||||
default y if DEFAULT_SMALL || BOARDCTL_RESET
|
||||
default n if !DEFAULT_SMALL
|
||||
default y if DEFAULT_SMALL
|
||||
depends on BOARDCTL_POWEROFF
|
||||
|
||||
config NSH_DISABLE_PRINTF
|
||||
@ -453,8 +453,8 @@ config NSH_DISABLE_READLINK
|
||||
|
||||
config NSH_DISABLE_REBOOT
|
||||
bool "Disable reboot"
|
||||
default n if !DEFAULT_SMALL && !BOARDCTL_POWEROFF
|
||||
default y if DEFAULT_SMALL || BOARDCTL_POWEROFF
|
||||
default n if !DEFAULT_SMALL
|
||||
default y if DEFAULT_SMALL
|
||||
depends on BOARDCTL_RESET
|
||||
|
||||
config NSH_DISABLE_RM
|
||||
|
@ -919,10 +919,12 @@ o passwd <username> <password>
|
||||
|
||||
Set the password for the existing user <username> to <password>
|
||||
|
||||
o poweroff
|
||||
o poweroff [<n>]
|
||||
|
||||
Shutdown and power off the system. This command depends on hardware
|
||||
support to power down or reset the system.
|
||||
Shutdown and power off the system. This command depends on board-
|
||||
specific hardware support to power down the system. The optional,
|
||||
decimal numeric argument <n> may be included to provide power off
|
||||
mode to board-specific power off logic.
|
||||
|
||||
NOTE: Supporting both the poweroff and shutdown commands is redundant.
|
||||
|
||||
@ -975,10 +977,12 @@ o readlink <link>
|
||||
|
||||
Show target of a soft link.
|
||||
|
||||
o reboot
|
||||
o reboot [<n>]
|
||||
|
||||
Reset and reboot the system immediately. This command depends on hardware
|
||||
support to reset the system.
|
||||
support to reset the system. The optional, decimal numeric argument <n>
|
||||
may be included to provide reboot mode to board-specific reboot
|
||||
logic.
|
||||
|
||||
NOTE: Supporting both the reboot and shutdown commands is redundant.
|
||||
|
||||
|
@ -378,7 +378,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_POWEROFF)
|
||||
{ "poweroff", cmd_poweroff, 1, 1, NULL },
|
||||
{ "poweroff", cmd_poweroff, 1, 2, NULL },
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_DISABLE_PRINTF
|
||||
@ -412,7 +412,7 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_RESET) && !defined(CONFIG_NSH_DISABLE_REBOOT)
|
||||
{ "reboot", cmd_reboot, 1, 1, NULL },
|
||||
{ "reboot", cmd_reboot, 1, 2, NULL },
|
||||
#endif
|
||||
|
||||
#ifdef NSH_HAVE_DIROPTS
|
||||
|
@ -190,7 +190,14 @@ int cmd_poweroff(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
* off the board due to some constraints.
|
||||
*/
|
||||
|
||||
(void)boardctl(BOARDIOC_POWEROFF, EXIT_SUCCESS);
|
||||
if (argc > 1)
|
||||
{
|
||||
(void)boardctl(BOARDIOC_POWEROFF, atoi(argv[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)boardctl(BOARDIOC_POWEROFF, EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* boarctl() will not return in any case. It if does, it means that
|
||||
* there was a problem with the shutdown operaion.
|
||||
@ -213,7 +220,14 @@ int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
* reset the board due to some constraints.
|
||||
*/
|
||||
|
||||
(void)boardctl(BOARDIOC_RESET, EXIT_SUCCESS);
|
||||
if (argc > 1)
|
||||
{
|
||||
(void)boardctl(BOARDIOC_RESET, atoi(argv[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)boardctl(BOARDIOC_RESET, EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* boarctl() will not return in this case. It if does, it means that
|
||||
* there was a problem with the reset operaion.
|
||||
|
Loading…
Reference in New Issue
Block a user