Files
julian b2a0471b08 Rongta 80mm printer: driver, role-based failover, live status monitoring
Add the rongta PrinterDevice driver (ESC/POS over raw TCP 9100) and the
device-agnostic pieces around it:

- Roles + failover: each printer declares a role (entry-dispenser/booth-
  receipt) and failoverRank; printer-routing.ts picks the best healthy printer
  and falls back outside->booth for entry tickets (never the reverse).
- Live status: MonitorableDevice.readStatus()/PrinterStatus capability. The
  Rongta driver scrapes the device's own /prn_stat.htm (Cover/Cutter/Paper
  End/Near End/Off-Line) rather than hand-decoding DLE EOT, whose reply bytes
  on this clone don't match the canonical ESC/POS bit layout (verified on
  hardware) -- avoids a false-healthy. Maps to ready/degraded/offline, fail
  safe on an unreachable or unexpected page.
- Server PrinterMonitor polls enabled printers (PRINTER_POLL_MS, default 5s),
  caches latest, emits "printer-status" on change. Exposed via
  GET /api/printers/status and an SSE stream for the booth UI.

Verified against 10.0.10.6: ready when healthy, offline when unreachable
(no throw), bus emits on change and suppresses unchanged reads.

Wiki: new rongta-printer entity, printer-roles-failover and
printer-status-monitoring concepts; BOM/index/log updated.
2026-06-14 20:26:45 +02:00

2.5 KiB

type, tags, sources, updated
type tags sources updated
entity
parking
hardware
printer
device
2026-06-14

Rongta 80mm thermal printer

The chosen ticket/receipt printer: a Rongta RP-series 80mm network thermal printer (and the many ESC/POS-compatible OEM clones that share its firmware). Driver rongta in packages/devices implements device-adapter-pattern.

Transport & protocol

  • ESC/POS over a raw TCP socket on port 9100 (the JetDirect/RAW convention). The driver opens the socket, writes the ESC/POS byte stream, waits for flush, closes.
  • No authentication on the print socket — anyone who can reach port 9100 can print. Like every other field device it must sit on the isolated device VLAN (network-isolation). There is no real HTTP/control boundary on the device (same posture as dingtian-relay).
  • Health check is a TCP connect probe to 9100. The print socket exposes no status protocol we rely on; the print itself is the real reachability test (failover attempts the print).
  • Live status comes from the device's own web page http://<host>/prn_stat.htm (port 80), which decodes Cover Open / Cutter Error / Paper End / Paper Near End / Off-Line into Yes/No. We scrape that rather than hand-decode DLE EOT — this clone's DLE EOT reply bytes do not match the canonical ESC/POS bit layout (verified on hardware), so trusting the device's own decode avoids a false-healthy. Implemented as readStatus(); see printer-status-monitoring.

Deployment (this site)

  • First printer verified reachable at 10.0.10.6:9100 from the host (TCP connect OK, 2026-06-14).
  • At least two printers, by role — see printer-roles-failover:
    • entry-dispenser — outside, at the lane; the driver takes the entry ticket.
    • booth-receipt — inside the booth; receipts, AND the backup that prints the entry ticket if the outside dispenser is offline.

Ticket rendering

printTicket(TicketData) builds ESC/POS: ESC @ init, centered/bold/double-size header, lane, ticket id, issued-at, feed + partial cut (GS V B). CP437/ASCII subset.

Status

Driver written and compiles; entry-ticket layout is a first pass; live status monitoring is implemented and verified (printer-status-monitoring). The receipt/exit layout and the cash-drawer kick (ESC/POS ESC p) are not yet implemented — they arrive with the exit/payment flow. Replaces the generic "Epson TM / Citizen" booth-printer line in bom.