summaryrefslogtreecommitdiff
path: root/nuttx/examples/nsh/nsh_proccmds.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-10 22:02:19 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-10 22:02:19 +0000
commit76ae5226bee0a119ea0866e784d97ef6203c5f0c (patch)
tree6e37498c517ae55ef5a58ce6d6e1fae386f244a6 /nuttx/examples/nsh/nsh_proccmds.c
parent2d0ce7d83a5ee93070da059aa3d6ce85c970c7a4 (diff)
downloadpx4-nuttx-76ae5226bee0a119ea0866e784d97ef6203c5f0c.tar.gz
px4-nuttx-76ae5226bee0a119ea0866e784d97ef6203c5f0c.tar.bz2
px4-nuttx-76ae5226bee0a119ea0866e784d97ef6203c5f0c.zip
Misc NSH enhancements
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@813 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nsh/nsh_proccmds.c')
-rw-r--r--nuttx/examples/nsh/nsh_proccmds.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/nuttx/examples/nsh/nsh_proccmds.c b/nuttx/examples/nsh/nsh_proccmds.c
index 7cd14e437..4140c277d 100644
--- a/nuttx/examples/nsh/nsh_proccmds.c
+++ b/nuttx/examples/nsh/nsh_proccmds.c
@@ -42,6 +42,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <sched.h>
#include "nsh.h"
@@ -162,3 +163,43 @@ void cmd_ps(FAR void *handle, int argc, char **argv)
nsh_output(handle, "PID PRI SCHD TYPE NP STATE NAME\n");
sched_foreach(ps_task, handle);
}
+
+/****************************************************************************
+ * Name: cmd_sleep
+ ****************************************************************************/
+
+#ifndef CONFIG_DISABLE_SIGNALS
+void cmd_sleep(FAR void *handle, int argc, char **argv)
+{
+ char *endptr;
+ long secs;
+
+ secs = strtol(argv[1], &endptr, 0);
+ if (!secs || endptr == argv[1] || *endptr != '\0')
+ {
+ nsh_output(handle, g_fmtarginvalid, argv[0]);
+ return;
+ }
+ sleep(secs);
+}
+#endif
+
+/****************************************************************************
+ * Name: cmd_usleep
+ ****************************************************************************/
+
+#ifndef CONFIG_DISABLE_SIGNALS
+void cmd_usleep(FAR void *handle, int argc, char **argv)
+{
+ char *endptr;
+ long usecs;
+
+ usecs = strtol(argv[1], &endptr, 0);
+ if (!usecs || endptr == argv[1] || *endptr != '\0')
+ {
+ nsh_output(handle, g_fmtarginvalid, argv[0]);
+ return;
+ }
+ usleep(usecs);
+}
+#endif