From 3dd347ca5585ab5ed410c9096c1692186c97960e Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Wed, 27 Dec 2017 13:54:05 +1100 Subject: [PATCH] sysparam editor: more stdout flushing. --- examples/sysparam_editor/sysparam_editor.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/sysparam_editor/sysparam_editor.c b/examples/sysparam_editor/sysparam_editor.c index 29bf78e..df31593 100644 --- a/examples/sysparam_editor/sysparam_editor.c +++ b/examples/sysparam_editor/sysparam_editor.c @@ -50,16 +50,25 @@ size_t tty_readline(char *buffer, size_t buf_size, bool echo) { break; } else if (c == '\b' || c == 0x7f) { if (i) { - if (echo) printf("\b \b"); + if (echo) { + printf("\b \b"); + fflush(stdout); + } i--; } } else if (c < 0x20) { /* Ignore other control characters */ } else if (i >= buf_size - 1) { - if (echo) putchar('\a'); + if (echo) { + putchar('\a'); + fflush(stdout); + } } else { buffer[i++] = c; - if (echo) putchar(c); + if (echo) { + putchar(c); + fflush(stdout); + } } } @@ -177,6 +186,7 @@ void sysparam_editor_task(void *pvParameters) { } while (true) { printf("==> "); + fflush(stdout); len = tty_readline(cmd_buffer, CMD_BUF_SIZE, echo); status = 0; if (!len) continue;