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/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 4aea0dff3 examples/telnetd: Add support to reset command
4aea0dff3 is described below
commit 4aea0dff38bc0a83f003cd623bf449f7033ba426
Author: Rodrigo Sim <[email protected]>
AuthorDate: Thu Jul 11 18:38:01 2024 -0300
examples/telnetd: Add support to reset command
Signed-off-by: Rodrigo Sim [email protected]
---
examples/telnetd/telnetd.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/examples/telnetd/telnetd.c b/examples/telnetd/telnetd.c
index 72a21a270..1716f145b 100644
--- a/examples/telnetd/telnetd.c
+++ b/examples/telnetd/telnetd.c
@@ -48,6 +48,11 @@
#include <arpa/inet.h>
#include <netinet/in.h>
+#ifdef CONFIG_BOARDCTL_RESET
+# include <sys/boardctl.h>
+# include <sys/ioctl.h>
+#endif
+
#include "netutils/telnetd.h"
#include "netutils/netlib.h"
@@ -68,6 +73,11 @@ struct ptentry_s
****************************************************************************/
static void telnetd_help(int argc, char **argv);
+
+#ifdef CONFIG_BOARDCTL_RESET
+static void telnetd_reset(int argc, char **argv);
+#endif
+
static void telnetd_quit(int argc, char **argv);
static void telnetd_unknown(int argc, char **argv);
static void telnetd_parse(FAR char *line, int len);
@@ -79,6 +89,9 @@ static void telnetd_parse(FAR char *line, int len);
static const struct ptentry_s g_parsetab[] =
{
{"help", telnetd_help},
+ #ifdef CONFIG_BOARDCTL_RESET
+ {"reset", telnetd_reset},
+ #endif
{"exit", telnetd_quit},
{"?", telnetd_help},
{NULL, telnetd_unknown}
@@ -96,6 +109,9 @@ static void telnetd_help(int argc, char **argv)
{
printf("Available commands:\n");
printf(" help, ? - show help\n");
+ #ifdef CONFIG_BOARDCTL_RESET
+ printf(" reset - reset the board\n");
+ #endif
printf(" exit - exit shell\n");
}
@@ -121,6 +137,18 @@ static void telnetd_quit(int argc, char **argv)
exit(0);
}
+/****************************************************************************
+ * Name: telnetd_reset
+ ****************************************************************************/
+#ifdef CONFIG_BOARDCTL_RESET
+static void telnetd_reset(int argc, char **argv)
+{
+ printf("Reset!\n");
+ boardctl(BOARDIOC_RESET, 0);
+ exit(0);
+}
+#endif
+
/****************************************************************************
* Name: telnetd_parse
****************************************************************************/