Added fflush for terminal echo (#455)
This commit is contained in:
parent
e24b6579ff
commit
e3403eb5db
1 changed files with 5 additions and 0 deletions
|
@ -94,18 +94,23 @@ static void gpiomon()
|
||||||
int i = 0;
|
int i = 0;
|
||||||
printf("\n\n\nWelcome to gpiomon. Type 'help<enter>' for, well, help\n");
|
printf("\n\n\nWelcome to gpiomon. Type 'help<enter>' for, well, help\n");
|
||||||
printf("%% ");
|
printf("%% ");
|
||||||
|
fflush(stdout); // stdout is line buffered
|
||||||
while(1) {
|
while(1) {
|
||||||
if (read(0, (void*)&ch, 1)) { // 0 is stdin
|
if (read(0, (void*)&ch, 1)) { // 0 is stdin
|
||||||
printf("%c", ch);
|
printf("%c", ch);
|
||||||
|
fflush(stdout);
|
||||||
if (ch == '\n' || ch == '\r') {
|
if (ch == '\n' || ch == '\r') {
|
||||||
cmd[i] = 0;
|
cmd[i] = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
handle_command((char*) cmd);
|
handle_command((char*) cmd);
|
||||||
printf("%% ");
|
printf("%% ");
|
||||||
|
fflush(stdout);
|
||||||
} else {
|
} else {
|
||||||
if (i < sizeof(cmd)) cmd[i++] = ch;
|
if (i < sizeof(cmd)) cmd[i++] = ch;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
printf("You will never see this print as read(...) is blocking\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue