You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/30 19:51:54 UTC

[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a change in pull request #1099: rptun cmd update

pkarashchenko commented on a change in pull request #1099:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1099#discussion_r838910598



##########
File path: nshlib/nsh_syscmds.c
##########
@@ -343,23 +341,94 @@ 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;
+    }
+  else if (strcmp(argv[1], "dump") == 0)
+    {
+      cmd = RPTUNIOC_DUMP;
+    }
+  else if (strcmp(argv[1], "ping") == 0)
+    {
+      if (argc != 6)
+        {
+          nsh_output(vtbl, g_fmtarginvalid, path);
+          return ERROR;
+        }
+
+      ping.times = atoi(argv[3]);
+      ping.len   = atoi(argv[4]);
+      ping.ack   = atoi(argv[5]);
+
+      cmd = RPTUNIOC_PING;
+      val = (unsigned long)&ping;
+    }
   else
     {
       nsh_output(vtbl, g_fmtarginvalid, argv[1]);
       return ERROR;
     }
 
-  fd = open(argv[2], 0);
+  fd = open(path, 0);
   if (fd < 0)
     {
-      nsh_output(vtbl, g_fmtarginvalid, argv[2]);
+      nsh_output(vtbl, g_fmtarginvalid, path);
       return ERROR;
     }
 
-  ioctl(fd, cmd, 0);
+  cmd = ioctl(fd, cmd, val);
 
   close(fd);
-  return 0;
+
+  return cmd;
+}
+
+static int cmd_rptun_recursive(FAR struct nsh_vtbl_s *vtbl,
+                               const char *dirpath,
+                               struct dirent *entryp, void *pvarg)
+{
+  char *path;
+  int ret;
+
+  if (DIRENT_ISDIRECTORY(entryp->d_type))
+    {
+      return 0;
+    }
+
+  path = nsh_getdirpath(vtbl, dirpath, entryp->d_name);

Review comment:
       Does getdirpath always return non-NULL value?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org