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