apps: add rptun reset /dev/rptun/xx cmd

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-12-24 17:18:56 +08:00 committed by Xiang Xiao
parent c57677c3ce
commit d5aae96523
2 changed files with 12 additions and 2 deletions

View File

@ -470,7 +470,7 @@ static const struct cmdmap_s g_cmdmap[] =
#endif #endif
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN) #if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
{ "rptun", cmd_rptun, 3, 3, "start|stop|panic <dev-path>" }, { "rptun", cmd_rptun, 3, 4, "start|stop|reset|panic <dev-path> [value]" },
#endif #endif
#ifndef CONFIG_NSH_DISABLE_SET #ifndef CONFIG_NSH_DISABLE_SET

View File

@ -346,6 +346,7 @@ int cmd_reset_cause(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN) #if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
unsigned long val = 0;
int fd; int fd;
int cmd; int cmd;
@ -363,6 +364,15 @@ int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
cmd = RPTUNIOC_STOP; cmd = RPTUNIOC_STOP;
} }
else if (strcmp(argv[1], "reset") == 0)
{
if (argc > 3)
{
val = atoi(argv[3]);
}
cmd = RPTUNIOC_RESET;
}
else if (strcmp(argv[1], "panic") == 0) else if (strcmp(argv[1], "panic") == 0)
{ {
cmd = RPTUNIOC_PANIC; cmd = RPTUNIOC_PANIC;
@ -380,7 +390,7 @@ int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return ERROR; return ERROR;
} }
ioctl(fd, cmd, 0); ioctl(fd, cmd, val);
close(fd); close(fd);
return 0; return 0;