Skip to content

serial: add pty sink (mode = "pty")#147

Merged
LinuxJedi merged 2 commits into
LinuxJedi:mainfrom
codewiz:feat/serial-pty
Jul 7, 2026
Merged

serial: add pty sink (mode = "pty")#147
LinuxJedi merged 2 commits into
LinuxJedi:mainfrom
codewiz:feat/serial-pty

Conversation

@codewiz

@codewiz codewiz commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Adds a pseudo-terminal serial sink: [serial] mode = "pty" (or --serial pty).
The emulator allocates a host pty, logs the slave path (/dev/pts/N), and
bridges Paula's serial port to it, so a terminal program attaches directly with
no network in the loop -- with an AUX: shell on the Amiga side, a local
AmigaDOS console.

serial: pty at /dev/pts/7 (connect with e.g. "minicom -D /dev/pts/7", "screen /dev/pts/7" or "cu -l /dev/pts/7")

What's here

  • PtySerialSink (Unix only): posix_openpt/grantpt/unlockpt/ptsname,
    slave line discipline set raw (no echo, no CR/LF rewriting) so the Amiga gets
    bytes verbatim. Mirrors TcpSerialSink: a background reader thread stages
    input into a channel and a signed counter drives has_pending_input, so
    Paula's idle fast path polls a counter, never a syscall.
  • The sink holds its own slave fd open for its lifetime. That keeps the pty
    alive across terminal programs attaching/detaching, and stops the master read
    from returning EIO (the "no slave attached" error a naive blocking reader
    would hot-spin on) while nothing is attached.
  • Config/CLI: SerialMode::Pty, parse_serial_mode, launcher picker + label,
    build_serial_sink (errors clearly on non-Unix hosts). copperline.example.toml
    documents pty (and fills in the previously-undocumented tcp mode).

Testing

  • Unit test pty_sink_round_trips_input_and_output: opens the sink, attaches to
    the slave path, checks input staging and output delivery both directions.
  • Manual: booted an A1200/68040 image with --serial pty, ran an AUX: shell
    over the pty, drove it interactively from minicom/screen/picocom.

Not in this PR (follow-up): an opt-in output-cooking option (0x9B C1 CSI ->
7-bit ESC[, \n -> \r\n) so dumb/UTF-8 terminals render the Amiga console
without per-terminal termios tuning. Kept separate to keep this change small.

🤖 Generated with Claude Code

Allocate a host pseudo-terminal and bridge Paula's serial port to it, so a
terminal program (minicom/screen/picocom) attaches to the slave path directly,
with no TCP in the loop. Unix only; opt-in via [serial] mode = "pty" or
--serial pty. A background reader thread stages input, and the sink holds its
own slave fd open so the master never EIO-spins while nothing is attached.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a Unix pseudo-terminal (“pty”) serial sink so the emulator can bridge Paula’s serial port directly to a host /dev/pts/N, enabling local terminal attachment without TCP.

Changes:

  • Add PtySerialSink (Unix-only) with a background reader thread and has_pending_input counter, mirroring the existing TCP sink pattern.
  • Extend serial mode plumbing across config parsing, CLI/help text, emulator sink construction, and launcher UI labels to support pty.
  • Document tcp and pty serial modes in copperline.example.toml.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/serial.rs Implements the new PtySerialSink and adds a unit test for pty round-tripping.
src/config.rs Adds SerialMode::Pty, label support, and parsing/error-message updates.
src/emulator.rs Wires SerialMode::Pty into build_serial_sink with Unix/non-Unix handling.
src/main.rs Updates --serial CLI error/help text to include tcp/pty.
src/video/launcher.rs Adds Pty to the launcher’s serial-mode picker and label mapping.
copperline.example.toml Documents tcp and pty serial configuration options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/serial.rs
Comment thread src/serial.rs
Warn when tcgetattr/tcsetattr fail instead of silently dropping raw mode, so
a terminal that ends up echoing or rewriting CR/LF is diagnosable. Poll the
pty with a 5s deadline in the round-trip test so an output regression fails
instead of wedging CI on a blocking tty read.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@LinuxJedi LinuxJedi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Another great feature. Thanks again!

@LinuxJedi LinuxJedi merged commit cbd2756 into LinuxJedi:main Jul 7, 2026
8 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.

3 participants