Skip to content

feat: raw serial-over-TCP passthrough mode (exclusive-lease), so LAN clients like SPE Expert Controller can share the Pi's existing serial link #43

Description

@w9fyi

Summary

Feature request: a raw serial-over-TCP passthrough mode in expert-amp-server, so a native vendor/third-party client — specifically SPE Expert Controller for macOS, which supports connecting over TCP/IP to a "network/serial adapter" — can talk to the amp over the LAN through the Pi that's already running expert-amp-server, without needing a second physical connection or a separate device like the SPE-LAN-UNIT.

Motivation

My station setup has expert-amp-server on a Pi wired to the amp. Direct USB is my preferred physical transport (see PR #34's A/B thread — it's the reliable one; the SPE-LAN-UNIT introduces the 0x90 STATUS bug we already isolated there). The only reason I've used the LAN-unit at all is that it gets me a LAN-reachable connection to the amp, which matters because:

  1. My USB-serial run to the Pi has shown RF susceptibility during TX (mentioned in my last comment on feat: promote Expert 2K-FA Third Series fan profile #34) — a LAN hop at the amp side avoids that.
  2. I sometimes want to drive the amp from a proper native macOS client with real accessibility support (I'm a blind ham) instead of expert-amp-server's browser UI. SPE Expert Controller advertises full VoiceOver support (descriptive labels/hints, a spoken "Announce" status report) and connects over USB, RS-232, or TCP/IP.

Right now those two things are in tension: expert-amp-server's own API (:8088, HTTP/WebSocket) doesn't speak the amp's native serial protocol, so SPE Expert Controller can't point at it. The only way to get Expert Controller onto the LAN today is the SPE-LAN-UNIT's own TCP 7388 virtual-COM — which reintroduces the 0x90 bug and is a second piece of hardware in the chain.

Proposed feature

A raw TCP listener in expert-amp-server that exposes the amp's actual serial link over the LAN — effectively hosting the same kind of "virtual COM over TCP" the SPE-LAN-UNIT provides, but from the Pi against whatever physical transport expert-amp-server is already using (USB in my case).

The one thing this has to get right: the amp only tolerates one serial master at a time. We proved this directly on the LAN-unit's own TCP 7388 port — a second raw client connected concurrently with expert-amp-server's own bridge desynced/corrupted expert-amp-server's decoder (documented in my SPE-LAN-UNIT notes, happy to write up the repro if useful). A naive "always-on TCP relay running alongside the normal polling loop" would hit the exact same failure mode internally.

So I'd suggest an exclusive-lease passthrough, not true simultaneous multiplexing:

  • While no raw client is connected, expert-amp-server behaves exactly as it does today (its own polling/API, normal decoding).
  • The moment a client connects to the new raw TCP port, expert-amp-server pauses its own polling/writes for the duration of that connection and just pipes bytes bidirectionally between the socket and the physical serial port — a dumb pipe, safe specifically because only one side is ever actually talking to the amp at a time.
  • On disconnect, internal polling resumes automatically.

This sidesteps building a real command-origin-tracking multiplexer (which would be a much bigger change) and matches what I actually need in practice — I'd never want the browser UI and Expert Controller both actively driving the amp at once anyway, I just want to choose which one, from the LAN, without swapping cables or SSHing in to stop/start services.

Why this over just running ser2net/socat alongside expert-amp-server

Same single-master problem applies to any external tool run concurrently against the same device node — it'd need expert-amp-server to fully release the port first anyway. Building the lease logic into expert-amp-server itself means it can coordinate that hand-off cleanly (stop polling, flush, hand over; resume cleanly on disconnect) rather than requiring me to manually stop/start systemctl units every time I want to switch clients.

Happy to test against real hardware once there's something to try, the same way I did for #32/#34/#36/#21 — I have both a direct-USB and an SPE-LAN-UNIT setup on hand to compare against.

73,
Justin — AI5OS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions