Skip to content

bump ArduinoLibs + WLED: pack the RS485 socket header (7B on every target) - #24

Merged
aphelps-claude-bot merged 3 commits into
mainfrom
pack-socket-headers
Jul 30, 2026
Merged

aphelps-claude-bot merged 3 commits into
mainfrom
pack-socket-headers

Conversation

@aphelps-claude-bot

Copy link
Copy Markdown
Collaborator

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.

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) 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_t becomes a packed 7 bytes 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 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 host c++ 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_SUPPORTED preprocesses the struct away unless RS485_HARDWARE_SERIAL is defined). Plus: the bridge's 19 host test groups pass on both ABIs, pio run -e ampworks fails at 8 and succeeds at 7, and pio run -e usermods still builds.

One trap found while verifying, now documented in the usermod readme: PlatformIO copies path-based lib_deps into .pio/libdeps/<env>/ and builds the copy without reliably re-syncing it, so pio run -e ampworks initially reported SUCCESS against a deliberately wrong constant. Clear .pio/libdeps/<env>/RS485Utils after editing ArduinoLibs — especially before flashing a board you intend to test.

🤖 Generated with Claude Code

https://claude.ai/code/session_013HqzdRdTRnreSvevaQGQSJ

aphelps-claude-bot and others added 3 commits July 29, 2026 18:47
…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
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