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;
|
||||
printf("\n\n\nWelcome to gpiomon. Type 'help<enter>' for, well, help\n");
|
||||
printf("%% ");
|
||||
fflush(stdout); // stdout is line buffered
|
||||
while(1) {
|
||||
if (read(0, (void*)&ch, 1)) { // 0 is stdin
|
||||
printf("%c", ch);
|
||||
fflush(stdout);
|
||||
if (ch == '\n' || ch == '\r') {
|
||||
cmd[i] = 0;
|
||||
i = 0;
|
||||
printf("\n");
|
||||
handle_command((char*) cmd);
|
||||
printf("%% ");
|
||||
fflush(stdout);
|
||||
} else {
|
||||
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