summaryrefslogtreecommitdiff
path: root/apps/nshlib/nsh_telnetd.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-29 22:11:04 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-29 22:11:04 +0000
commit7b78d906d966d2c2b266bce9c1c0c8fef19c3103 (patch)
treede34ca63f68a004de6c9d864ef380a56b870e84a /apps/nshlib/nsh_telnetd.c
parentf5308beae0c268fa2b27e3a524e76afe871b6234 (diff)
downloadpx4-nuttx-7b78d906d966d2c2b266bce9c1c0c8fef19c3103.tar.gz
px4-nuttx-7b78d906d966d2c2b266bce9c1c0c8fef19c3103.tar.bz2
px4-nuttx-7b78d906d966d2c2b266bce9c1c0c8fef19c3103.zip
Add support for a login script (in addition to the init script); Add logic so that a USB console session can connect and reconnect to the USB serial device
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5582 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_telnetd.c')
-rw-r--r--apps/nshlib/nsh_telnetd.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/apps/nshlib/nsh_telnetd.c b/apps/nshlib/nsh_telnetd.c
index 478935d7f..76ed81086 100644
--- a/apps/nshlib/nsh_telnetd.c
+++ b/apps/nshlib/nsh_telnetd.c
@@ -1,7 +1,7 @@
/****************************************************************************
* apps/nshlib/nsh_telnetd.c
*
- * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -198,15 +198,29 @@ int nsh_telnetmain(int argc, char *argv[])
}
#endif /* CONFIG_NSH_TELNET_LOGIN */
+ /* The following logic mostly the same as the login in nsh_session.c. It
+ * differs only in that gets() is called to get the command instead of
+ * readline().
+ */
+
/* Present the NSH greeting */
fputs(g_nshgreeting, pstate->cn_outstream);
fflush(pstate->cn_outstream);
- /* Execute the startup script */
+ /* Execute the startup script. If standard console is also defined, then
+ * we will not bother with the initscript here (although it is safe to
+ * call nshinitscript multiple times).
+ */
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_CONSOLE)
- (void)nsh_script(&pstate->cn_vtbl, "init", NSH_INITPATH);
+ (void)nsh_initscript(&pstate->cn_vtbl);
+#endif
+
+ /* Execute the login script */
+
+#ifdef CONFIG_NSH_ROMFSRC
+ (void)nsh_loginscript(&pstate->cn_vtbl);
#endif
/* Then enter the command line parsing loop */
@@ -261,8 +275,8 @@ int nsh_telnetmain(int argc, char *argv[])
* NuttX configuration setting.
*
* Returned Values:
- * Zero if the Telnet daemon was successfully started. A negated errno
- * value will be returned on failure.
+ * The task ID of the Telnet daemon was successfully started. A negated
+ * errno value will be returned on failure.
*
****************************************************************************/
@@ -271,6 +285,15 @@ int nsh_telnetstart(void)
struct telnetd_config_s config;
int ret;
+ /* Initialize any USB tracing options that were requested. If standard
+ * console is also defined, then we will defer this step to the standard
+ * console.
+ */
+
+#if defined(CONFIG_NSH_USBDEV_TRACE) && !defined(CONFIG_NSH_CONSOLE)
+ usbtrace_enable(TRACE_BITSET);
+#endif
+
/* Configure the telnet daemon */
config.d_port = HTONS(CONFIG_NSH_TELNETD_PORT);