You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/01 09:36:59 UTC
[incubator-nuttx-apps] 02/06: apps: add rptun reset /dev/rptun/xx cmd
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit d5aae96523de34812934f467ef8e02cc5f3da868
Author: ligd <li...@xiaomi.com>
AuthorDate: Fri Dec 24 17:18:56 2021 +0800
apps: add rptun reset /dev/rptun/xx cmd
Signed-off-by: ligd <li...@xiaomi.com>
---
nshlib/nsh_command.c | 2 +-
nshlib/nsh_syscmds.c | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index 318ac2a..5bc7ab0 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -470,7 +470,7 @@ static const struct cmdmap_s g_cmdmap[] =
#endif
#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
#ifndef CONFIG_NSH_DISABLE_SET
diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c
index 9470b2c..ce63a2a 100644
--- a/nshlib/nsh_syscmds.c
+++ b/nshlib/nsh_syscmds.c
@@ -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)
int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
+ unsigned long val = 0;
int fd;
int cmd;
@@ -363,6 +364,15 @@ int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
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)
{
cmd = RPTUNIOC_PANIC;
@@ -380,7 +390,7 @@ int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return ERROR;
}
- ioctl(fd, cmd, 0);
+ ioctl(fd, cmd, val);
close(fd);
return 0;