Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/shell: ensure character is flushed when echoing. #10630

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions sys/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ static void _putchar(int c) {
#endif
#endif

static void flush_if_needed(void)
{
#ifdef MODULE_NEWLIB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not defining this in the _putchar function if it is only needed with newlib?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we don't need to flush after every character. I do think, however, that it would be better if stdio was in unbuffered mode: it fits better with the HW.

fflush(stdout);
#endif
}

static shell_command_handler_t find_handler(const shell_command_t *command_list, char *command)
{
const shell_command_t *command_lists[] = {
Expand Down Expand Up @@ -265,6 +272,7 @@ static int readline(char *buf, size_t size)
_putchar(c);
#endif
}
flush_if_needed();
}
}

Expand All @@ -275,9 +283,7 @@ static inline void print_prompt(void)
_putchar(' ');
#endif

#ifdef MODULE_NEWLIB
fflush(stdout);
#endif
flush_if_needed();
}

void shell_run(const shell_command_t *shell_commands, char *line_buf, int len)
Expand Down