Skip to content

bump submodules: RS485 receive-path fixes + first ArduinoLibs tests - #25

Merged
aphelps-claude-bot merged 3 commits into
mainfrom
rs485-receive-path-fixes
Jul 30, 2026
Merged

aphelps-claude-bot merged 3 commits into
mainfrom
rs485-receive-path-fixes

Conversation

@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator

Submodule pointer bump for the receive-path fixes, plus a make test change that belongs in this repo. Merge the two submodule PRs first.

The four defects

All found by reading Nick Gammon's vendored RS485_non_blocking after the ArduinoLibs#5 self-review turned out to have verified byte-identity and packaging but never the logic. Full detail in the submodule PR; in brief:

# defect why it matters
1 a completed packet is never reset, so a later valid-form byte is tested as a CRC over the previous packet's buffer and can re-deliver it ~1-in-4 to 1-in-10 per dropped STX, and the bridge persists SET_ADDRESS to flash on receipt
2 begin()'s malloc is unchecked a receiver silently dead for a whole boot while /json/info says healthy
3 no packet timeout — upstream leaves it to the caller and nobody picked it up a truncated frame holds the receiver open unbounded
4 getMsg()'s length checks live inside #if DEBUG_LEVEL >= DEBUG_TRACE release builds return a sender-declared length up to 255 into a 64-byte buffer

The vendored library is untouched — every fix is in RS485Utils, so it stays byte-identical to upstream.

make test now runs what it claimed to

Two suites were being silently skipped:

  • the new ArduinoLibs receive-path tests (there was no ArduinoLibs test target at all — the Makefile header even said so)
  • the rs485_bridge wire-format tests, which had to be run by hand. They now run on both ABIs — native and -fpack-struct=1 — since the point of most of those assertions is that an ESP32 and an ATMega328 agree, and running only one ABI cannot show that.
make test  ->  ampworks sensor-sync + rs485_bridge (x2 ABIs) + ArduinoLibs + router

That is not a cosmetic change: the socket-header packing bug merged earlier today was invisible partly because every automated check ran on one ABI at a time.

Verification

make test green across all four suites; pio run -e ampworks and -e usermods both SUCCESS; 28 receive-path assertions each paired with a negative control confirming that disabling the fix turns them red.

🤖 Generated with Claude Code

https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ

aphelps-claude-bot and others added 3 commits July 29, 2026 19:26
ArduinoLibs 6d1de81 -- fixes the four receive-path defects found auditing the
vendored RS485_non_blocking (stale-packet re-delivery, unchecked malloc, no packet
timeout, length checks compiled out of release builds) and adds test/, the first test
infrastructure in that repo: an Arduino.h shim plus 28 assertions, each paired with a
negative control that confirms disabling the fix turns them red.
WLED 0cf79a01 -- bridge side: refuse to run on a failed socket alloc, and keep
rejected frames counted now that a NULL from getMsg() no longer means "bus empty".

Also extends `make test` to cover two suites it silently skipped: the new ArduinoLibs
receive-path tests, and the rs485_bridge wire-format tests, which had to be run by
hand and are now run on BOTH ABIs (native and -fpack-struct=1) since the point of most
of those assertions is that the two agree.

  make test  ->  ampworks sensor-sync + rs485_bridge (x2 ABIs) + ArduinoLibs + router

  aphelps/ArduinoLibs#10
  aphelps/WLED#15

Submodule PRs merge first; these pointers are re-pointed at the merged shas before
this lands.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
ArduinoLibs 538a01b -- the packet timeout measured poll latency rather than wire
time, so with the check running before update() it could discard a frame whose
remaining bytes were already in the FIFO: a regression against pre-timeout behaviour,
not a pre-existing bug. Now checked after update(), plus a baud-derived timeout
(fixed 250 ms killed every full-size frame at 4800 baud), reachable NULL guards, and
uint16_t counters to keep the ATmega328 footprint down. Two of the new tests turned
out to pass with their fix disabled and are now deterministic; three uncovered paths
added. 45 assertions, up from 28.
WLED 2b5baa2c -- scale the timeout to the configured baud, surface timeouts on the
info page (the counter existed but nothing read it), and correct two comments that
still said the library's length checks are compiled out of release builds.

Makefile: test-bridge guards HMTL and ArduinoLibs too, not just WLED. It compiles
against headers from all three, so on a fresh clone with uninitialised submodules a
bare `make` failed with a confusing missing-header error from the compiler instead of
the "run ./setup.sh" message require_submodule exists to print.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
ArduinoLibs bceedb3 (#10) -- four receive-path defects fixed, plus test/: the first
test infrastructure in that repo (45 assertions, each with a verified negative
control).
WLED cdfef9c0 (#15) -- bridge side: refuse to run on a failed socket alloc, scale the
receive timeout to the configured baud, surface timeouts on the info page, keep
rejected frames counted.

Both squash-merged, so this replaces the branch-tip pointers this PR opened with.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
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