Add poweroff and reboot NSH commands as alternatives to the shutdown command
This commit is contained in:
parent
165637ce27
commit
95eea325cf
@ -297,6 +297,12 @@ config NSH_DISABLE_NSFMOUNT
|
||||
default n
|
||||
depends on NFS
|
||||
|
||||
config NSH_DISABLE_POWEROFF
|
||||
bool "Disable poweroff"
|
||||
default n if !DEFAULT_SMALL && !BOARDCTL_RESET
|
||||
default y if DEFAULT_SMALL || BOARDCTL_RESET
|
||||
depends on BOARDCTL_POWEROFF
|
||||
|
||||
config NSH_DISABLE_PS
|
||||
bool "Disable ps"
|
||||
default n
|
||||
@ -316,6 +322,12 @@ config NSH_DISABLE_PWD
|
||||
bool "Disable pwd"
|
||||
default n
|
||||
|
||||
config NSH_DISABLE_REBOOT
|
||||
bool "Disbable reboot"
|
||||
default n if !DEFAULT_SMALL && !BOARDCTL_POWEROFF
|
||||
default y if DEFAULT_SMALL || BOARDCTL_POWEROFF
|
||||
depends on BOARDCTL_RESET
|
||||
|
||||
config NSH_DISABLE_RM
|
||||
bool "Disable rm"
|
||||
default n
|
||||
@ -332,10 +344,11 @@ config NSH_DISABLE_SH
|
||||
bool "Disable sh"
|
||||
default n
|
||||
|
||||
config CONFIG_NSH_DISABLE_SHUTDOWN
|
||||
bool "Disable sh"
|
||||
default n
|
||||
depends on BOARDCTL_POWEROFF
|
||||
config NSH_DISABLE_SHUTDOWN
|
||||
bool "Disable shutdown"
|
||||
default n if !DEFAULT_SMALL && BOARD_POWEROFF && BOARD_RESET
|
||||
default y if DEFAULT_SMALL || !BOARD_POWEROFF || !BOARD_RESET
|
||||
depends on BOARDCTL_POWEROFF || BOARDCTL_RESET
|
||||
|
||||
config NSH_DISABLE_SLEEP
|
||||
bool "Disable sleep"
|
||||
|
@ -762,18 +762,6 @@ o nfsmount <server-address> <mount-point> <remote-path>
|
||||
Mount the remote NFS server directory <remote-path> at <mount-point> on the target machine.
|
||||
<server-address> is the IP address of the remote server.
|
||||
|
||||
o ps
|
||||
|
||||
Show the currently active threads and tasks. For example,
|
||||
|
||||
nsh> ps
|
||||
PID PRI SCHD TYPE NP STATE NAME
|
||||
0 0 FIFO TASK READY Idle Task()
|
||||
1 128 RR TASK RUNNING init()
|
||||
2 128 FIFO TASK WAITSEM nsh_telnetmain()
|
||||
3 100 RR PTHREAD WAITSEM <pthread>(21)
|
||||
nsh>
|
||||
|
||||
o ping [-c <count>] [-i <interval>] <ip-address>
|
||||
ping6 [-c <count>] [-i <interval>] <ip-address>
|
||||
|
||||
@ -796,6 +784,25 @@ o ping [-c <count>] [-i <interval>] <ip-address>
|
||||
|
||||
ping6 differs from ping in that it uses IPv6 addressing.
|
||||
|
||||
o poweroff
|
||||
|
||||
Shutdown and power off the system. This command depends on hardware
|
||||
support to power down or reset the system.
|
||||
|
||||
NOTE: Supporting both the poweroff and shutdown commands is redundant.
|
||||
|
||||
o ps
|
||||
|
||||
Show the currently active threads and tasks. For example,
|
||||
|
||||
nsh> ps
|
||||
PID PRI SCHD TYPE NP STATE NAME
|
||||
0 0 FIFO TASK READY Idle Task()
|
||||
1 128 RR TASK RUNNING init()
|
||||
2 128 FIFO TASK WAITSEM nsh_telnetmain()
|
||||
3 100 RR PTHREAD WAITSEM <pthread>(21)
|
||||
nsh>
|
||||
|
||||
o put [-b|-n] [-f <remote-path>] -h <ip-address> <local-path>
|
||||
|
||||
Copy the file at <local-address> to the host whose IP address is
|
||||
@ -823,6 +830,13 @@ o pwd
|
||||
/dev
|
||||
nsh>
|
||||
|
||||
o reboot
|
||||
|
||||
Reset and reboot the system immediately. This command depends on hardware
|
||||
support to reset the system.
|
||||
|
||||
NOTE: Supporting both the reboot and shutdown commands is redundant.
|
||||
|
||||
o rm <file-path>
|
||||
|
||||
Remove the specified <file-path> name from the mounted file system.
|
||||
@ -891,6 +905,9 @@ o shutdown [--reboot]
|
||||
down or reset the system; one, both, or neither behavior may be
|
||||
supported.
|
||||
|
||||
NOTE: The shutdown command duplicates the behavior of the poweroff and
|
||||
reboot commands.
|
||||
|
||||
o sleep <sec>
|
||||
|
||||
Pause execution (sleep) of <sec> seconds.
|
||||
@ -988,11 +1005,13 @@ Command Dependencies on Configuration Settings
|
||||
mount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_READABLE (see note 3)
|
||||
mv (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0) (see note 4)
|
||||
nfsmount !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET && CONFIG_NFS
|
||||
poweroff CONFIG_BOARDCTL_POWEROFF
|
||||
ping CONFIG_NET && CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING && !CONFIG_DISABLE_SIGNALS
|
||||
ping6 CONFIG_NET && CONFIG_NET_ICMPv6 && CONFIG_NET_ICMPv6_PING && !CONFIG_DISABLE_SIGNALS
|
||||
ps --
|
||||
put CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && MTU >= 558 (see note 1,2)
|
||||
pwd !CONFIG_DISABLE_ENVIRON && CONFIG_NFILE_DESCRIPTORS > 0
|
||||
reboot CONFIG_BOARDCTL_RESET
|
||||
rm (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)
|
||||
rmdir (((!CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_WRITABLE) || !CONFIG_DISABLE_PSEUDOFS_OPERATIONS) && CONFIG_NFILE_DESCRIPTORS > 0)
|
||||
set !CONFIG_DISABLE_ENVIRON
|
||||
@ -1033,13 +1052,14 @@ also allow it to squeeze into very small memory footprints.
|
||||
CONFIG_NSH_DISABLE_MD5 CONFIG_NSH_DISABLE_MB, CONFIG_NSH_DISABLE_MKDIR,
|
||||
CONFIG_NSH_DISABLE_MKFATFS, CONFIG_NSH_DISABLE_MKFIFO, CONFIG_NSH_DISABLE_MKRD,
|
||||
CONFIG_NSH_DISABLE_MH, CONFIG_NSH_DISABLE_MOUNT, CONFIG_NSH_DISABLE_MW,
|
||||
CONFIG_NSH_DISABLE_MV, CONFIG_NSH_DISABLE_NFSMOUNT, CONFIG_NSH_DISABLE_PS,
|
||||
CONFIG_NSH_DISABLE_PING, CONFIG_NSH_DISABLE_PING6, CONFIG_NSH_DISABLE_PUT,
|
||||
CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_RM, CONFIG_NSH_DISABLE_RMDIR,
|
||||
CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH, CONFIG_NSH_DISABLE_SHUTDOWN,
|
||||
CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT,
|
||||
CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_URLDECODE, CONFIG_NSH_DISABLE_URLENCODE,
|
||||
CONFIG_NSH_DISABLE_USLEEP, CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD
|
||||
CONFIG_NSH_DISABLE_MV, CONFIG_NSH_DISABLE_NFSMOUNT, CONFIG_NSH_DISABLE_POWEROFF,
|
||||
CONFIG_NSH_DISABLE_PS, CONFIG_NSH_DISABLE_PING, CONFIG_NSH_DISABLE_PING6,
|
||||
CONFIG_NSH_DISABLE_PUT, CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_REBOOT,
|
||||
CONFIG_NSH_DISABLE_RM, CONFIG_NSH_DISABLE_RMDIR, CONFIG_NSH_DISABLE_SET,
|
||||
CONFIG_NSH_DISABLE_SH, CONFIG_NSH_DISABLE_SHUTDOWN, CONFIG_NSH_DISABLE_SLEEP,
|
||||
CONFIG_NSH_DISABLE_TEST, CONFIG_NSH_DISABLE_UMOUNT, CONFIG_NSH_DISABLE_UNSET,
|
||||
CONFIG_NSH_DISABLE_URLDECODE, CONFIG_NSH_DISABLE_URLENCODE, CONFIG_NSH_DISABLE_USLEEP,
|
||||
CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD
|
||||
|
||||
Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE. In that
|
||||
case, the help command is still available but will be slightly smaller.
|
||||
|
@ -988,6 +988,14 @@ void nsh_usbtrace(void);
|
||||
# endif
|
||||
#endif /* CONFIG_NET */
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_POWEROFF)
|
||||
int cmd_poweroff(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_RESET) && !defined(CONFIG_NSH_DISABLE_REBOOT)
|
||||
int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#if (defined(CONFIG_BOARDCTL_POWEROFF) || defined(CONFIG_BOARDCTL_RESET)) && \
|
||||
!defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||
int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
|
@ -329,6 +329,10 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_POWEROFF)
|
||||
{ "poweroff", cmd_poweroff, 1, 1, NULL },
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_DISABLE_PS
|
||||
{ "ps", cmd_ps, 1, 1, NULL },
|
||||
#endif
|
||||
@ -345,6 +349,10 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_RESET) && !defined(CONFIG_NSH_DISABLE_REBOOT)
|
||||
{ "reboot", cmd_reboot, 1, 1, NULL },
|
||||
#endif
|
||||
|
||||
#ifdef NSH_HAVE_DIROPTS
|
||||
# ifndef CONFIG_NSH_DISABLE_RM
|
||||
{ "rm", cmd_rm, 2, 2, "<file-path>" },
|
||||
|
@ -150,10 +150,56 @@ int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* boarctl() will not return in any case. It if does, it means that
|
||||
* there was a problem with the shutdown operaion.
|
||||
* there was a problem with the shutdown/resaet operaion.
|
||||
*/
|
||||
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
|
||||
return ERROR;
|
||||
}
|
||||
#endif /* CONFIG_BOARDCTL_POWEROFF && !CONFIG_NSH_DISABLE_SHUTDOWN */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_poweroff
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && !defined(CONFIG_NSH_DISABLE_POWEROFF)
|
||||
int cmd_poweroff(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
/* Invoke the BOARDIOC_POWEROFF board control to shutdown the board. If
|
||||
* the board_power_off function returns, then it was not possible to power-
|
||||
* off the board due to some constraints.
|
||||
*/
|
||||
|
||||
(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.
|
||||
*/
|
||||
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_reboot
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_RESET) && !defined(CONFIG_NSH_DISABLE_REBOOT)
|
||||
int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
/* Invoke the BOARDIOC_RESET board control to reset the board. If
|
||||
* the board_reset() function returns, then it was not possible to
|
||||
* reset the board due to some constraints.
|
||||
*/
|
||||
|
||||
(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.
|
||||
*/
|
||||
|
||||
nsh_output(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
|
||||
return ERROR;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user