Skip to content

Fix AX.25 terminal: mod-128 inbound decode and Ctrl-] menu#487

Merged
chrissnell merged 1 commit into
mainfrom
feature/terminal-mod128-rx-and-menu-shortcut
Jul 23, 2026
Merged

Fix AX.25 terminal: mod-128 inbound decode and Ctrl-] menu#487
chrissnell merged 1 commit into
mainfrom
feature/terminal-mod128-rx-and-menu-shortcut

Conversation

@chrissnell

Copy link
Copy Markdown
Owner

Fixes two connected-mode AX.25 terminal bugs reported on #456 (IC-705 over USB to a packet BBS).

1. mod-128 (SABME) sessions: no inbound frames after the handshake

pkg/app/rxfanout.go decoded every inbound connected-mode frame with the modulus hardcoded to mod-8 (ax25conn.Decode(rf.Data, false)). A mod-128 link's I/S frames carry a 2-octet control field, so decoding them as mod-8 corrupts N(S)/N(R) and the session drops every frame -- the operator sees the BBS welcome, then nothing.

  • New Manager.DispatchRaw resolves the owning session from the (modulus-independent) address header, reads its negotiated modulus race-free via a new Session.Mod128() atomic mirror, then decodes.
  • Decode now sizes the control field correctly under mod-128: U-frames (SABM/SABME/UA/DM/DISC/...) stay 1 octet, only I/S grow to 2. The old blanket 2-octet assumption rejected the UA that completes the handshake with "missing control field" -- caught while adding the regression test.

The web terminal exposes a "Negotiate modulo-128 (SABME)" toggle, so this path is reachable in production. (Not the specific failure jfbabb hit -- his mod-8 welcome arrived -- but a real correctness bug on the same feature.)

2. Ctrl-] / Cmd-] command bar never opens while the canvas has focus

The shortcut lived only on <svelte:window onkeydown>, but xterm maps Ctrl-] to the GS control code (0x1D) and calls stopPropagation() on that keydown, so the window handler never fires. Since the canvas auto-focuses, the shortcut was effectively dead -- browser-agnostic, matching both the Safari and Firefox reports.

Fix intercepts the chord via term.attachCustomKeyEventHandler, returning false so xterm leaves the key alone (no stray 0x1D down the link) and the command bar opens directly. The window handler stays as the out-of-focus fallback.

Still open (needs operator data, not in this PR)

The primary #456 symptom -- link falls to TIMER_RECOVERY after the first typed command while the BBS keeps sending -- points to the half-duplex soundcard RX turnaround, not the state machine. Awaiting a log capture + PTT/tail config before touching modem timing.

Verification

  • go build ./..., go vet ./pkg/ax25conn/... ./pkg/app/... -- clean.
  • go test -race ./pkg/ax25conn/... and go test ./pkg/app/... -- pass, including the new TestManager_DispatchRawMod128Delivers (end-to-end mod-128 handshake + I-frame delivery).
  • Web changes are lint/type-checked by CI (no node_modules in this environment to build locally).

Wiki: adds invariant #60 (modulus-aware inbound decode + variable mod-128 control width).

@chrissnell
chrissnell force-pushed the feature/terminal-mod128-rx-and-menu-shortcut branch 2 times, most recently from a01c022 to ef7d8f4 Compare July 23, 2026 05:32
Two connected-mode terminal bugs surfaced against a packet BBS (#456):

Inbound frames for a mod-128 (SABME) session were decoded with a fixed
mod-8 modulus in the RX fanout, corrupting N(S)/N(R) so no frame after
the handshake was delivered. Route inbound bytes through a new
Manager.DispatchRaw that resolves the session first and decodes with its
negotiated modulus (read race-free via an atomic mirror). Decode now
also sizes the control field correctly under mod-128, where U-frames
stay 1 octet while I/S frames are 2 -- the old blanket 2-octet
assumption rejected the UA that completes the handshake.

The Ctrl-] command-bar shortcut never fired while the terminal canvas
had focus: xterm maps Ctrl-] to the GS control code and calls
stopPropagation, so the window-level keydown handler never saw it.
Intercept the chord via attachCustomKeyEventHandler so xterm surrenders
the key (no stray 0x1D down the link) and the command bar opens; the
window handler stays as the out-of-focus fallback.

Adds a mod-128 delivery regression test and documents the
modulus-aware-decode invariant in the wiki.
@chrissnell
chrissnell force-pushed the feature/terminal-mod128-rx-and-menu-shortcut branch from ef7d8f4 to 7597a1f Compare July 23, 2026 05:57
@chrissnell
chrissnell merged commit c656053 into main Jul 23, 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.

1 participant