Repository navigation
bump ArduinoLibs + WLED: pack the RS485 socket header (7B on every target) - #24
Merged
Merged
Conversation
…rget) Both pointers move in ONE commit deliberately. rs485_socket_hdr_t goes from an unpacked struct (7 bytes on AVR, 8 on ESP32) to a packed 7 everywhere, and RS485B_SOCKET_HDR_LEN follows it from 8 to 7. Any intermediate state with one side advanced fails `pio run -e ampworks` at the static_assert in usermod_rs485_bridge.cpp:19 -- which is the build the hardware bring-up depends on. What this unblocks: until now the rs485_bridge usermod could not exchange a single frame with a real HMTL module. sizeof(rs485_socket_hdr_t) positions the payload at both ends, so the ESP32 emitted [7 header][1 pad][payload] while an ATMega328 read the payload from offset 7, and vice versa -- every frame misparsed by one byte, in both directions. The bench session for the bridge was blocked on this and nothing else. aphelps/ArduinoLibs#9 -- pack rs485/xbee/rfm69 socket headers + static_assert sweep aphelps/WLED#14 -- RS485B_SOCKET_HDR_LEN 8 -> 7, host-test coverage, readme Submodule PRs merge first; this pointer pair is re-pointed at the merged shas before this PR lands. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
ArduinoLibs f4afaab -- README scopes the packing guarantee and names TCPSocket as not covered. WLED 40d4ecdf -- the new host-test assert was tautological (7 == 7, green even with the packing attribute removed); replaced with a packed replica plus offsetof checks that actually fail, and the three comments that overclaimed cross-ABI coverage now say what the check can and cannot see. Also documents a pre-existing sizing bug the review surfaced: a full 64-byte TX slot goes on the wire as 71 bytes and overflows a default 64-byte receive buffer, so the real payload ceiling is 57. Filed separately rather than fixed here. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ
ArduinoLibs d047ce2 (#9) -- pack rs485/xbee/rfm69 socket headers + assertion sweep WLED 3c11ec16 (#14) -- RS485B_SOCKET_HDR_LEN 8 -> 7, host-test coverage, readme 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
This was referenced Jul 30, 2026
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.
Submodule pointer bump for the socket-header packing fix. Merge the two submodule PRs first, then this pointer pair gets re-pointed at their merged shas.
rs485_socket_hdr_t/xbee_socket_hdr_t/rfm69_socket_hdr_t+ astatic_assertsweepRS485B_SOCKET_HDR_LEN8 → 7, host-test coverage on both ABIs, readmeWhat this unblocks
Until now the
rs485_bridgeusermod could not exchange a single frame with a real HMTL module.sizeof(rs485_socket_hdr_t)is what positions the payload at both ends of the link, and unpacked it was 7 bytes on an ATMega328 (alignment 1) but 8 on the ESP32 (2-byte alignment rounds 7 up to a trailing pad). So the bridge emitted[7 header][1 pad][payload]while the module read the payload from offset 7 — the pad byte — and in the other direction the bridge read one byte late, past the real start code. Every frame misparsed by one, both ways.The hardware bring-up bench session for the bridge was blocked on this and nothing else: steps 5 through 9 of its runbook would all have failed for this single reason, and the session would have taught nothing.
Why both pointers move in one commit
rs485_socket_hdr_tbecomes a packed 7 bytes andRS485B_SOCKET_HDR_LENfollows it from 8 to 7. Any intermediate state with one side advanced failspio run -e ampworksat thestatic_assertinusermod_rs485_bridge.cpp:19— which is exactly the build the bring-up depends on, and the only place that assert is ever compiled.Worth noting for other open WLED PRs: WLED's own CI clones ArduinoLibs' default branch unpinned (
build.yml:83,usermods.yml:79—--depth 1, no ref), so once ArduinoLibs#9 merges those workflows build against the packed header regardless of pointer state. Harmless here only because no CI env compiles the bridge.Verification
Full detail in the two submodule PRs. Summary: 12 positive checks across
avr-g++ -mmcu=atmega328p,xtensa-esp32-elf-g++, and hostc++both natively and under-fpack-struct=1, each paired with a negative control proving the assertion actually fires (without which the non-AVR checks pass vacuously —RS485UTILS_SUPPORTEDpreprocesses the struct away unlessRS485_HARDWARE_SERIALis defined). Plus: the bridge's 19 host test groups pass on both ABIs,pio run -e ampworksfails at 8 and succeeds at 7, andpio run -e usermodsstill builds.One trap found while verifying, now documented in the usermod readme: PlatformIO copies path-based
lib_depsinto.pio/libdeps/<env>/and builds the copy without reliably re-syncing it, sopio run -e ampworksinitially reported SUCCESS against a deliberately wrong constant. Clear.pio/libdeps/<env>/RS485Utilsafter editing ArduinoLibs — especially before flashing a board you intend to test.🤖 Generated with Claude Code
https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ