Conversation
The Linux console (SimSerial, the `Serial` global) was output-only:
available()/read()/peek() were stubbed, so a line-oriented CLI reading
`Serial` could never receive input, and write() used block-buffered
putchar(), so logs needed an external `stdbuf -oL` wrapper to reach
journald promptly.
begin() now opens a listening AF_UNIX socket. The path is
$ARDULINUX_CONSOLE_SOCKET when set, else $XDG_RUNTIME_DIR/ardulinux/
console.sock (fallback /tmp/ardulinux-<uid>/console.sock). A connected
client's bytes are delivered to read()/available()/peek() non-blocking,
and write() mirrors output to the client as well as stdout. Incoming
'\n' is mapped to '\r' (1:1, preserving available()/read() byte counts)
so CLIs that terminate on '\r' work with tools that send '\n'. The
socket is created mode 0600 in a 0700 directory: connecting grants the
privileged local console, gated by filesystem permissions. stdout is
line-buffered from construction, removing the need for `stdbuf -oL`.
Robustness for a consumer that only read()s when available()>0 (e.g. the
MeshCore repeater loop, which also logs continuously):
- write() uses send(MSG_NOSIGNAL) so logging to a hung-up peer cannot
raise SIGPIPE and terminate the daemon.
- available() reaps a closed peer via a MSG_PEEK probe (FIONREAD can't
distinguish "no data" from "closed"), then accepts the next client,
so the console keeps working across reconnects.
Adds unit tests for client I/O, newline mapping, peek, the no-client
default, socket permissions, no-SIGPIPE-on-write-after-disconnect, and
reconnect through the available()-gated consumer loop shape.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KzBaSxeXYbJBJ7EYyfR3Lb
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@l5yth As far as MeshCore goes, this now allows Previously, making changes to a Repeater involved editing the config file and restarting |
|
Made a big mistake here, the socket creation should have been abstracted into the Repeater code rather than SimSerial. I'll open a new PR for the stdout fix. |
|
Thank you, this is useful. I'll take a look at #38. |
The Linux console (SimSerial, the
Serialglobal) was output-only.begin()now opens a listeningAF_UNIXsocket. The path is$ARDULINUX_CONSOLE_SOCKETwhen set, else$XDG_RUNTIME_DIR/ardulinux/console.sockThe socket is created mode 0600 in a 0700 directory: connecting grants the privileged local console, gated by filesystem permissions. stdout is line-buffered from construction, removing the need forstdbuf -oL.Adds unit tests for client I/O, newline mapping, peek, the no-client default, socket permissions, no-SIGPIPE-on-write-after-disconnect, and reconnect through the available()-gated consumer loop shape.