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 08:17:39 UTC

[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a change in pull request #1111: apps/nsh:add resetcause command

xiaoxiang781216 commented on a change in pull request #1111:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1111#discussion_r838236258



##########
File path: nshlib/nsh_command.c
##########
@@ -586,6 +586,10 @@ static const struct cmdmap_s g_cmdmap[] =
 #ifndef CONFIG_NSH_DISABLE_XD
   { "xd",       cmd_xd,       3, 3, "<hex-address> <byte-count>" },
 #endif
+
+#if defined(CONFIG_BOARDCTL_RESET_CAUSE) && !defined(CONFIG_NSH_DISABLE_RESET_CAUSE)
+  { "resetcause",   cmd_reset_cause,   1, 1, NULL },

Review comment:
       let's keep the command in the order.

##########
File path: nshlib/nsh_syscmds.c
##########
@@ -518,3 +518,21 @@ int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
   return OK;
 }
 #endif
+
+#if defined(CONFIG_BOARDCTL_RESET_CAUSE) && !defined(CONFIG_NSH_DISABLE_RESET_CAUSE)

Review comment:
       keep the order too.

##########
File path: nshlib/nsh_syscmds.c
##########
@@ -518,3 +518,21 @@ int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
   return OK;
 }
 #endif
+
+#if defined(CONFIG_BOARDCTL_RESET_CAUSE) && !defined(CONFIG_NSH_DISABLE_RESET_CAUSE)
+int cmd_reset_cause(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+{
+  int ret;
+  struct boardioc_reset_cause_s cause;
+  memset(&cause, 0, sizeof(cause));
+
+  ret = boardctl(BOARDIOC_RESET_CAUSE, &cause);
+  if (ret < 0)
+    {
+       nsh_error(vtbl, g_fmtcmdfailed, argv[0], "boardctl", NSH_ERRNO);
+       return ERROR;
+    }
+  nsh_output(vtbl, "cause:%x, flag:%x\n", cause.cause, cause.flag);

Review comment:
       should we map cause to string xxx(yy)?

##########
File path: nshlib/nsh_syscmds.c
##########
@@ -518,3 +518,21 @@ int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
   return OK;
 }
 #endif
+
+#if defined(CONFIG_BOARDCTL_RESET_CAUSE) && !defined(CONFIG_NSH_DISABLE_RESET_CAUSE)
+int cmd_reset_cause(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+{
+  int ret;
+  struct boardioc_reset_cause_s cause;
+  memset(&cause, 0, sizeof(cause));

Review comment:
       don't need memset




-- 
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