aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/shell/shell.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-22 14:02:36 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-22 14:02:36 +0000
commitf8c7e7e99cc005392dd099be9c3670e8386bd518 (patch)
tree31b0b157ab7fd2dd95a74f95fbd25fc6acfaa9a4 /os/various/shell/shell.c
parent8b53874c73dabebaa1cf57c4fef45c1a3ccf4cc5 (diff)
downloadChibiOS-f8c7e7e99cc005392dd099be9c3670e8386bd518.tar.gz
ChibiOS-f8c7e7e99cc005392dd099be9c3670e8386bd518.tar.bz2
ChibiOS-f8c7e7e99cc005392dd099be9c3670e8386bd518.zip
Fixed shell dependencies on RT.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9150 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/various/shell/shell.c')
-rw-r--r--os/various/shell/shell.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/os/various/shell/shell.c b/os/various/shell/shell.c
index 69461e00e..a0998fbbe 100644
--- a/os/various/shell/shell.c
+++ b/os/various/shell/shell.c
@@ -134,8 +134,14 @@ THD_FUNCTION(shellThread, p) {
while (true) {
chprintf(chp, "ch> ");
if (shellGetLine(chp, line, sizeof(line))) {
+#if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)
chprintf(chp, "\r\nlogout");
break;
+#else
+ /* Putting a delay in order to avoid an endless loop trying to read
+ an unavailable stream.*/
+ osalThreadSleepMilliseconds(100);
+#endif
}
lp = parse_arguments(line, &tokp);
cmd = lp;
@@ -188,6 +194,7 @@ void shellInit(void) {
chEvtObjectInit(&shell_terminated);
}
+#if !defined(_CHIBIOS_NIL_) || defined(__DOXYGEN__)
/**
* @brief Terminates the shell.
* @note Must be invoked from the command handlers.
@@ -205,6 +212,7 @@ void shellExit(msg_t msg) {
chEvtBroadcastI(&shell_terminated);
chThdExitS(msg);
}
+#endif
/**
* @brief Reads a whole line from the input channel.
@@ -231,17 +239,19 @@ bool shellGetLine(BaseSequentialStream *chp, char *line, unsigned size) {
while (true) {
char c;
- if (chSequentialStreamRead(chp, (uint8_t *)&c, 1) == 0)
+ if (streamRead(chp, (uint8_t *)&c, 1) == 0)
return true;
+#if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)
if (c == 4) {
chprintf(chp, "^D");
return true;
}
+#endif
if ((c == 8) || (c == 127)) {
if (p != line) {
- chSequentialStreamPut(chp, c);
- chSequentialStreamPut(chp, 0x20);
- chSequentialStreamPut(chp, c);
+ streamPut(chp, c);
+ streamPut(chp, 0x20);
+ streamPut(chp, c);
p--;
}
continue;
@@ -254,7 +264,7 @@ bool shellGetLine(BaseSequentialStream *chp, char *line, unsigned size) {
if (c < 0x20)
continue;
if (p < line + size - 1) {
- chSequentialStreamPut(chp, c);
+ streamPut(chp, c);
*p++ = (char)c;
}
}