summaryrefslogtreecommitdiff
path: root/apps/examples/nsh
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-02 16:04:09 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-02 16:04:09 +0000
commit426dc74b959df16ea2c63ddefb07aa874a17a367 (patch)
tree1642619d0c60b8a67c98baaca85e372bf524d8e4 /apps/examples/nsh
parent27d64b50095b5a95d4c41244993ca42d5062c627 (diff)
downloadnuttx-426dc74b959df16ea2c63ddefb07aa874a17a367.tar.gz
nuttx-426dc74b959df16ea2c63ddefb07aa874a17a367.tar.bz2
nuttx-426dc74b959df16ea2c63ddefb07aa874a17a367.zip
NSH now uses the new Telnet daemon and built-in tasks started by NSH can be used over Telnet
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4361 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples/nsh')
-rw-r--r--apps/examples/nsh/nsh_main.c56
1 files changed, 21 insertions, 35 deletions
diff --git a/apps/examples/nsh/nsh_main.c b/apps/examples/nsh/nsh_main.c
index 53235a835..5d302e397 100644
--- a/apps/examples/nsh/nsh_main.c
+++ b/apps/examples/nsh/nsh_main.c
@@ -1,8 +1,8 @@
/****************************************************************************
* examples/nsh/nsh_main.c
*
- * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -81,56 +81,42 @@
int user_start(int argc, char *argv[])
{
- int mid_priority;
-#if defined(CONFIG_NSH_CONSOLE) && defined(CONFIG_NSH_TELNET)
+ int exitval = 0;
int ret;
-#endif
/* Initialize the NSH library */
nsh_initialize();
- /* Set the priority of this task to something in the middle so that 'nice'
- * can both raise and lower the priority.
+ /* If the Telnet console is selected as a front-end, then start the
+ * Telnet daemon.
*/
- mid_priority = (sched_get_priority_max(SCHED_NSH) + sched_get_priority_min(SCHED_NSH)) >> 1;
- {
- struct sched_param param;
-
- param.sched_priority = mid_priority;
- (void)sched_setscheduler(0, SCHED_NSH, &param);
- }
-
- /* If both the console and telnet are selected as front-ends, then run
- * the telnet front end on another thread.
- */
-
-#if defined(CONFIG_NSH_CONSOLE) && defined(CONFIG_NSH_TELNET)
-# ifndef CONFIG_CUSTOM_STACK
- ret = task_create("nsh_telnetmain", mid_priority, CONFIG_NSH_STACKSIZE,
- nsh_telnetmain, NULL);
-# else
- ret = task_create("nsh_telnetmain", mid_priority, nsh_telnetmain, NULL);
-# endif
+#ifdef CONFIG_NSH_TELNET
+ ret = nsh_telnetstart();
if (ret < 0)
- {
+ {
/* The daemon is NOT running. Report the the error then fail...
* either with the serial console up or just exiting.
*/
- fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", errno);
+ fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
+ exitval = 1;
}
-
- /* If only the telnet front-end is selected, run it on this thread */
-
-#elif defined(CONFIG_NSH_TELNET)
- return nsh_telnetmain(0, NULL);
#endif
-/* If the serial console front end is selected, then run it on this thread */
+ /* If the serial console front end is selected, then run it on this thread */
#ifdef CONFIG_NSH_CONSOLE
- return nsh_consolemain(0, NULL);
+ ret = nsh_consolemain(0, NULL);
+
+ /* nsh_consolemain() should not return. So if we get here, something
+ * is wrong.
+ */
+
+ fprintf(stderr, "ERROR: nsh_consolemain() returned: %d\n", ret);
+ exitval = 1;
#endif
+
+ return exitval;
}