From d5266221ef92d652dbcf762fd0d1ad71df4bc75d Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Thu, 3 Aug 2017 17:09:51 +0200 Subject: [PATCH] usart: add CONFIG_USER_ECHO option --- source/platform/usart.c | 13 +++++++++++++ source/shell/mufs.c | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/source/platform/usart.c b/source/platform/usart.c index 382a544..527c864 100644 --- a/source/platform/usart.c +++ b/source/platform/usart.c @@ -107,21 +107,28 @@ int console_getline(struct console *console_, char *buf, size_t n) while (console_getc(&c, console_) == 0) { switch (c) { case '\r': +#if CONFIG_USER_ECHO usart_send_blocking(console->dev, '\r'); +#endif return 0; case 10: case 127: if (buf < p) { +#if CONFIG_USER_ECHO usart_send_blocking(console->dev, '\010'); usart_send_blocking(console->dev, ' '); usart_send_blocking(console->dev, '\010'); +#endif + --p; } break; default: *p = c; +#if CONFIG_USER_ECHO usart_send_blocking(console->dev, c); +#endif if (((size_t)p - (size_t)buf) < n) { ++p; @@ -156,9 +163,11 @@ ssize_t console_read(struct console *console_, char *buf, size_t n) case 10: case 127: if (buf < p) { +#if CONFIG_USER_ECHO usart_send_blocking(console->dev, '\010'); usart_send_blocking(console->dev, ' '); usart_send_blocking(console->dev, '\010'); +#endif --p; } @@ -170,7 +179,9 @@ ssize_t console_read(struct console *console_, char *buf, size_t n) goto out; *p++ = '\n'; +#if CONFIG_USER_ECHO usart_send_blocking(console->dev, '\r'); +#endif console_getc(&c, console_); goto out; default: @@ -178,7 +189,9 @@ ssize_t console_read(struct console *console_, char *buf, size_t n) goto out; *p++ = c; +#if CONFIG_USER_ECHO usart_send_blocking(console->dev, c); +#endif console_getc(&c, console_); break; } diff --git a/source/shell/mufs.c b/source/shell/mufs.c index cc00258..c66c9f1 100644 --- a/source/shell/mufs.c +++ b/source/shell/mufs.c @@ -204,11 +204,16 @@ int shell_write(struct console *con, size_t argc, const char **argv) return -1; } +#if CONFIG_USER_ECHO fprintf(con->fp, "> "); +#endif while ((ret = console_read(con, data, sizeof data)) > 0) { mufs_write(file, data, ret); + +#if CONFIG_USER_ECHO fprintf(con->fp, "\n> "); +#endif } mufs_close(file);