apps/nshlib: Add rptun cmd for boot remote core.
This commit is contained in:
parent
93017735ef
commit
611bc6c139
@ -487,6 +487,11 @@ config NSH_DISABLE_ROUTE
|
|||||||
default y if DEFAULT_SMALL
|
default y if DEFAULT_SMALL
|
||||||
default n if !DEFAULT_SMALL
|
default n if !DEFAULT_SMALL
|
||||||
|
|
||||||
|
config NSH_DISABLE_RPTUN
|
||||||
|
bool "Disable rptun"
|
||||||
|
default n
|
||||||
|
depends on RPTUN
|
||||||
|
|
||||||
config NSH_DISABLE_SET
|
config NSH_DISABLE_SET
|
||||||
bool "Disable set"
|
bool "Disable set"
|
||||||
default n
|
default n
|
||||||
|
@ -1167,6 +1167,10 @@ int cmd_irqinfo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
|||||||
int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
|
||||||
|
int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined(CONFIG_BOARDCTL_POWEROFF) || defined(CONFIG_BOARDCTL_RESET)) && \
|
#if (defined(CONFIG_BOARDCTL_POWEROFF) || defined(CONFIG_BOARDCTL_RESET)) && \
|
||||||
!defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
!defined(CONFIG_NSH_DISABLE_SHUTDOWN)
|
||||||
int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
int cmd_shutdown(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||||
|
@ -436,6 +436,10 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
|
||||||
|
{ "rptun", cmd_rptun, 3, 3, "<start|stop> <dev-path>" },
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_DISABLE_SET
|
#ifndef CONFIG_NSH_DISABLE_SET
|
||||||
#ifdef CONFIG_NSH_VARS
|
#ifdef CONFIG_NSH_VARS
|
||||||
# if !defined(CONFIG_DISABLE_ENVIRON) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
# if !defined(CONFIG_DISABLE_ENVIRON) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||||
|
@ -39,8 +39,11 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <nuttx/rptun/rptun.h>
|
||||||
#include <sys/boardctl.h>
|
#include <sys/boardctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -238,6 +241,49 @@ int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: cmd_rptun
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
|
||||||
|
int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int fd, cmd;
|
||||||
|
|
||||||
|
if (argc < 3)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtargrequired, argv[0]);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[1], "start") == 0)
|
||||||
|
{
|
||||||
|
cmd = RPTUNIOC_START;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[1], "stop") == 0)
|
||||||
|
{
|
||||||
|
cmd = RPTUNIOC_STOP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtarginvalid, argv[1]);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = open(argv[2], 0);
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtarginvalid, argv[2]);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ioctl(fd, cmd, 0);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: cmd_uname
|
* Name: cmd_uname
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user