add Node.js serial device simulator for protocol verification#66
Open
add Node.js serial device simulator for protocol verification#66
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
simple modules, device name, unique ID, button count, MCU type, extended
command list
custom protocol, 7-segment, TM1638, motors
Usage: node simulator/simulator.js [serialPort] [baudRate]
Virtual pair tip: socat -d -d pty,raw,echo=0 pty,raw,echo=0