Skip to content

Fix terminal line endings in the TTY output discipline - #7

Merged
JohnAmadis merged 1 commit into
mainfrom
fix/tty-output-crlf
Oct 18, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
fix/tty-output-crlf

Conversation

@JaxCalder

Copy link
Copy Markdown
Contributor

Serial terminal output on STM32F746G-DISCO contains bare LF bytes, so minicom advances the row without returning to column zero. Add default LF-to-CRLF output processing in dmtty's line discipline, shared by application writes and input echo, before forwarding to the backing stream or kernel fallback.

Output processing is independent of echo/canonical input flags: dmell temporarily clears both while editing commands, and Enter still needs CRLF. Existing CRLF is preserved across calls and handles. Per-node serialization and short-write accounting prevent duplicate CR on retries. The new onlcr configuration key and appended get/set ioctls allow byte-exact output when needed; previous ioctl numbers are unchanged. UART drivers and ordinary file writes retain their existing behavior.

Validation:

  • Created the branch from freshly fetched origin/main (e8d09f5).
  • Native module build and Cortex-M7 module build pass.
  • Host regression harness passes using both native and ARM build headers; added it to CI. Covers LF/CRLF, split handles, partial writes (including failure after inserted CR), input flags independent of output, all 256 byte values with output processing disabled, output ioctls, kernel fallback, and canonical echo.
  • Built dmod-boot for BOARD=stm32f746g-disco with the local module and flashed via ST-Link (Verified OK). Raw UART capture at 921600 baud: before the fix, echo produced three bare LFs; after the fix, echo, multiline help, and ls /dev contain only CRLF, including the shell's Enter echo, with no CRCRLF.
  • On the board, YMODEM received two files totaling 5130 bytes, including every byte value, with zero retransmissions. Read back a 1034-byte NUL-free binary file and matched the exact expected terminal CRLF conversion. Console output remains correct after the transfer.

Compatibility: clients sending arbitrary binary output through a TTY must explicitly disable onlcr (or use the backing device directly). Disabling canonical input alone intentionally keeps terminal output processing enabled. The YMODEM receiver's binary input and LF-free output protocol bytes are unaffected.

@JohnAmadis
JohnAmadis merged commit ddca2a0 into main Oct 18, 2026
1 check 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