Skip to content

add Node.js serial device simulator for protocol verification#66

Open
ecoreng wants to merge 4 commits intomainfrom
claude/serial-device-simulator-5aEts
Open

add Node.js serial device simulator for protocol verification#66
ecoreng wants to merge 4 commits intomainfrom
claude/serial-device-simulator-5aEts

Conversation

@ecoreng
Copy link
Copy Markdown
Contributor

@ecoreng ecoreng commented Apr 1, 2026

Implements the full ESP-SimHub ARQ transport + SimHub application-layer
handshake and feature enumeration so the host (SimHub) side can be tested
without a physical ESP device.

  • CRC-8 table matches firmware (ArqSerial.h)
  • Parses ARQ framing: header, sequence validation, CRC check, ACK/NACK
  • Handles all enumeration commands: Hello, Features, RGB count, TM1638,
    simple modules, device name, unique ID, button count, MCU type, extended
    command list
  • Handles streaming commands silently: keepalive, gear, RGB data, RGB matrix,
    custom protocol, 7-segment, TM1638, motors
  • Verbose, levelled debug output with hex dumps for every in/out frame

Usage: node simulator/simulator.js [serialPort] [baudRate]
Virtual pair tip: socat -d -d pty,raw,echo=0 pty,raw,echo=0

claude added 4 commits April 1, 2026 15:18
Implements the full ESP-SimHub ARQ transport + SimHub application-layer
handshake and feature enumeration so the host (SimHub) side can be tested
without a physical ESP device.

- CRC-8 table matches firmware (ArqSerial.h)
- Parses ARQ framing: header, sequence validation, CRC check, ACK/NACK
- Handles all enumeration commands: Hello, Features, RGB count, TM1638,
  simple modules, device name, unique ID, button count, MCU type, extended
  command list
- Handles streaming commands silently: keepalive, gear, RGB data, RGB matrix,
  custom protocol, 7-segment, TM1638, motors
- Verbose, levelled debug output with hex dumps for every in/out frame

Usage: node simulator/simulator.js [serialPort] [baudRate]
Virtual pair tip: socat -d -d pty,raw,echo=0 pty,raw,echo=0

https://claude.ai/code/session_01BJ7RNdXqRxFxGbH86xZPx5
Flips the role: instead of simulating the device, it now acts as the
SimHub host, driving the full ARQ handshake and feature enumeration
against a real ESP device on a physical serial port.

- Builds correctly CRC'd ARQ packets and sends them sequentially
- Decodes all device response frame types (ACK, NACK, BYTE, STRING,
  DEBUG, CUSTOM/device-initiated)
- Phase 1: Hello – checks firmware version matches 0x6A ('j')
- Phase 2: full enumeration – features, RGB count, TM1638 count, simple
  modules, extended command list, device name, unique ID, button count,
  MCU signature (verified against ATmega2560 0x1E 0x98 0x01)
- Phase 3: continuous keepalive heartbeats + logs any device-initiated
  events (buttons, encoders) until Ctrl-C
- Prints a summary table after enumeration

https://claude.ai/code/session_01BJ7RNdXqRxFxGbH86xZPx5
After feature enumeration, if an upgradeBaud argument is supplied the
simulator sends the ARQ '8' command with the appropriate baud code, waits
350 ms for the device to apply Serial.begin(), then calls port.update()
to switch the host port to match.  Keepalive then runs at the new rate.

Usage: node simulator.js /dev/ttyUSB0 19200 115200

https://claude.ai/code/session_01BJ7RNdXqRxFxGbH86xZPx5
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