Skip to content

SimSerial: line-buffer stdout so log lines flush promptly - #38

Merged
l5yth merged 1 commit into
l5yth:mainfrom
rgrizzell:line-buffered-stdout
Aug 31, 2026
Merged

l5yth merged 1 commit into
l5yth:mainfrom
rgrizzell:line-buffered-stdout

Conversation

@rgrizzell

Copy link
Copy Markdown
Contributor

SimSerial routes Serial output to stdout via putchar(). When stdout is not a TTY (a pipe, a file, or under a service manager), C stdio defaults to full buffering, so log lines don't appear until a ~4 KB buffer fills — forcing callers to wrap the process in stdbuf -oL.

SimSerial routes Serial output to stdout via putchar(). When stdout is not
a TTY (a pipe, a file, or under a service manager), C stdio defaults to full
buffering, so log lines don't appear until a ~4 KB buffer fills — forcing
callers to wrap the process in `stdbuf -oL`.

Set stdout to line-buffered once, at the first SimSerial construction (the
global `Serial` is built at static-init, before any output), so each
Serial.print line is flushed on its newline and reaches the terminal /
journald promptly. Guarded to run once: setvbuf() is undefined after I/O has
begun, and extra SimSerial instances may be constructed later (e.g. tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzBaSxeXYbJBJ7EYyfR3Lb
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@l5yth
l5yth merged commit d686d71 into l5yth:main Aug 31, 2026
4 checks passed
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