summaryrefslogtreecommitdiff
path: root/nuttx/examples/nsh
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-29 21:14:45 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-08-29 21:14:45 +0000
commit827914cecd0b52ddd6feebf2fc85f72c0b2574fa (patch)
treeb2d4281c6ee5b914ab043c1e0a02cea848c28d38 /nuttx/examples/nsh
parent66d7eb8e229a93e7401c5b9a7187999cdb53ae7c (diff)
downloadpx4-nuttx-827914cecd0b52ddd6feebf2fc85f72c0b2574fa.tar.gz
px4-nuttx-827914cecd0b52ddd6feebf2fc85f72c0b2574fa.tar.bz2
px4-nuttx-827914cecd0b52ddd6feebf2fc85f72c0b2574fa.zip
Basic telnet NSH on ARM9
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@852 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nsh')
-rw-r--r--nuttx/examples/nsh/nsh.h1
-rw-r--r--nuttx/examples/nsh/nsh_main.c1
-rw-r--r--nuttx/examples/nsh/nsh_serial.c2
-rw-r--r--nuttx/examples/nsh/nsh_telnetd.c9
4 files changed, 6 insertions, 7 deletions
diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h
index 0484f4f21..69ed0f030 100644
--- a/nuttx/examples/nsh/nsh.h
+++ b/nuttx/examples/nsh/nsh.h
@@ -192,6 +192,7 @@ typedef int (*cmd_t)(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
* Public Data
****************************************************************************/
+extern const char g_nshgreeting[];
extern const char g_nshprompt[];
extern const char g_fmtargrequired[];
extern const char g_fmtarginvalid[];
diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c
index ebe243913..35f88b72a 100644
--- a/nuttx/examples/nsh/nsh_main.c
+++ b/nuttx/examples/nsh/nsh_main.c
@@ -161,6 +161,7 @@ static const struct cmdmap_s g_cmdmap[] =
* Public Data
****************************************************************************/
+const char g_nshgreeting[] = "NuttShell (NSH)\n";
const char g_nshprompt[] = "nsh> ";
const char g_fmtargrequired[] = "nsh: %s: missing required argument(s)\n";
const char g_fmtarginvalid[] = "nsh: %s: argument invalid\n";
diff --git a/nuttx/examples/nsh/nsh_serial.c b/nuttx/examples/nsh/nsh_serial.c
index e138cf6c1..b3e60b75f 100644
--- a/nuttx/examples/nsh/nsh_serial.c
+++ b/nuttx/examples/nsh/nsh_serial.c
@@ -343,7 +343,7 @@ int nsh_consolemain(int argc, char *argv[])
{
FAR struct serial_s *pstate = nsh_allocstruct();
- printf("NuttShell (NSH)\n");
+ printf(g_nshgreeting);
fflush(pstate->ss_stream);
for (;;)
diff --git a/nuttx/examples/nsh/nsh_telnetd.c b/nuttx/examples/nsh/nsh_telnetd.c
index a27293472..5cfe7ba50 100644
--- a/nuttx/examples/nsh/nsh_telnetd.c
+++ b/nuttx/examples/nsh/nsh_telnetd.c
@@ -296,11 +296,7 @@ static void nsh_putchar(struct telnetd_s *pstate, uint8 ch)
if (ch == ISO_nl || tio->tio_bufndx == (CONFIG_EXAMPLES_NSH_LINELEN - 1))
{
- if (tio->tio_bufndx > 0)
- {
- pstate->tn_cmd[tio->tio_bufndx] = '\0';
- }
-
+ pstate->tn_cmd[tio->tio_bufndx] = '\0';
nsh_dumpbuffer("TELNET CMD", pstate->tn_cmd, strlen(pstate->tn_cmd));
nsh_parse(&pstate->tn_vtbl, pstate->tn_cmd);
tio->tio_bufndx = 0;
@@ -481,13 +477,14 @@ static void *nsh_connection(void *arg)
{
/* Initialize the thread state structure */
+ memset(tio, 0, sizeof(struct telnetio_s));
tio->tio_sockfd = sockfd;
tio->tio_state = STATE_NORMAL;
pstate->u.tn = tio;
/* Output a greeting */
- nsh_output(&pstate->tn_vtbl, "NuttShell (NSH)\n");
+ nsh_output(&pstate->tn_vtbl, g_nshgreeting);
/* Loop processing each TELNET command */