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

Fix text output in stm8flash to display immediately #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bp-dl
Copy link
Contributor

@bp-dl bp-dl commented Oct 5, 2022

When running stm8flash from within another IDE (such as Code::Blocks), any text that is output does not get displayed in the IDE until stm8flash exits (due to a lack of a flush). This commit fixes this by wrapping the text output calls in a macro that flushes the output stream each time. With this fix, the text output is displayed as stm8flash is running, and you are able to see it's progress in real time.

When running stm8flash from within another IDE (such as Code::Blocks), any text that is output does not get displayed in the IDE until stm8flash exits (due to a lack of a flush). This commit fixes this by wrapping the text output calls in a macro that flushes the output stream each time. With this fix, the text output is displayed as stm8flash is running, and you are able to see it's progress in real time.
@schneidersoft
Copy link
Contributor

Rather than using a macro please use a dedicated function to wrap text output. I've never looked into this, but I suspect that there might be a simpler way to make the stdout automatically flush

@schneidersoft
Copy link
Contributor

A little googling shows that setvbuf(stdout, NULL, _IONBF, 0) can be used to make stdout unbuffered... just like stderr.

The stream stderr is unbuffered. The stream stdout is line-buffered when it points to a terminal. Partial lines will not appear until fflush(3) or exit(3) is called, or a newline is printed. This can produce unexpected results, especially with debugging output. The buffering mode of the standard streams (or any other stream) can be changed using the setbuf(3) or setvbuf(3) call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants