Added fflush for terminal echo (#455)

This commit is contained in:
Johan Kanflo 2017-10-10 15:37:43 +02:00 committed by GitHub
parent e24b6579ff
commit e3403eb5db

View file

@ -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");
}
}
}