From 1938cfbd7e08b15a7f3ee269c2d523d29adbdafd Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 2 Aug 2016 14:23:59 +0200 Subject: [PATCH] echo on shell --- source/firmware/kernel/shell.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/firmware/kernel/shell.c b/source/firmware/kernel/shell.c index 1edfd13..0cfdba2 100644 --- a/source/firmware/kernel/shell.c +++ b/source/firmware/kernel/shell.c @@ -44,17 +44,19 @@ static void parse(const char *buffer, unsigned int len) static void rx_func(void *arg) { - char buffer[80]; + char buffer[81]; unsigned int index = 0; int ret = 0; open(shell_object.shell_device); while(1) { ret = read(shell_object.shell_device, &buffer[index], - sizeof(buffer) / sizeof(buffer[0]) - index); + sizeof(buffer) / sizeof(buffer[0]) - index - 1); if(ret) { + write(shell_object.shell_device, &buffer[index], ret); // echo if((buffer[index + ret - 1] == '\n') || (buffer[index + ret - 1] == '\r')) { buffer[index + ret - 1] = '\n'; parse(buffer, index + ret); + buffer[index + ret] = '\0'; index = 0; } else