Merge pull request #530 from ourairquality/sysparam-editor-flushing
sysparam editor: more stdout flushing.
This commit is contained in:
commit
2d22be9bac
1 changed files with 13 additions and 3 deletions
|
@ -50,16 +50,25 @@ size_t tty_readline(char *buffer, size_t buf_size, bool echo) {
|
||||||
break;
|
break;
|
||||||
} else if (c == '\b' || c == 0x7f) {
|
} else if (c == '\b' || c == 0x7f) {
|
||||||
if (i) {
|
if (i) {
|
||||||
if (echo) printf("\b \b");
|
if (echo) {
|
||||||
|
printf("\b \b");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
} else if (c < 0x20) {
|
} else if (c < 0x20) {
|
||||||
/* Ignore other control characters */
|
/* Ignore other control characters */
|
||||||
} else if (i >= buf_size - 1) {
|
} else if (i >= buf_size - 1) {
|
||||||
if (echo) putchar('\a');
|
if (echo) {
|
||||||
|
putchar('\a');
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer[i++] = c;
|
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) {
|
while (true) {
|
||||||
printf("==> ");
|
printf("==> ");
|
||||||
|
fflush(stdout);
|
||||||
len = tty_readline(cmd_buffer, CMD_BUF_SIZE, echo);
|
len = tty_readline(cmd_buffer, CMD_BUF_SIZE, echo);
|
||||||
status = 0;
|
status = 0;
|
||||||
if (!len) continue;
|
if (!len) continue;
|
||||||
|
|
Loading…
Reference in a new issue