Skip to content

fix(autoresearch): carry the encoder into the channel so UCS7604 tests the chipset (#4373) - #4377

Merged
zackees merged 1 commit into
masterfrom
fix/autoresearch-ucs7604-encoder
Sep 12, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/autoresearch-ucs7604-encoder

Conversation

@zackees

@zackees zackees commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

--chipset ucs7604 failed on the RP2350 PIO loopback at every LED count from 1 upward (#4373). Capture succeeded, the decoder reported success, and the comparison then disagreed on every byte — which reads as a driver or wiring fault.

What it actually was

autoResearchChipsetTiming() re-creates each clockless channel from the runtime timing:

fl::ChannelConfig channel_config(pin, config.timing, leds, rgb_order);

That constructor builds a ClocklessChipset(pin, timing), and that overload defaults the encoder to CLOCKLESS_ENCODER_WS2812. The encoder the timing resolved to — encoder_for<TIMING_UCS7604_800KHZ>() → UCS7604_16BIT — reached the comparison through config.encoder but never reached the transmitter.

So the wire carried raw 8-bit pixel bytes while the expectation was the full UCS7604 frame, which starts with six 0xFF sync bytes. Measured on the device before the fix, at 4 LEDs:

captured 12 bytes = 4 × 3 raw pixel bytes
expected 39 bytes = 15 preamble + 4 × 6
actual[0..2] F0 0F AA — the MSB_LSB_A pattern
expected[0..2] 255 255 255 — the sync pattern

Passing the encoder through makes both halves describe the same protocol.

The frame length is the other half

UCS7604 puts a 15-byte preamble and 16-bit channels on the wire, so its frame is more than twice the pixel byte count — and that count is what sizes the RX edge capacity in capture(). Deriving it from num_leds * 3 truncates the capture even once the encoder is right. runTest() and runMultiTest() now build the expected frame before the capture and use its length for the capacity, which also drops a per-run allocation from the multi-run loop.

Measured

RP2350W 2DCB876B587EA334, PIO0, GPIO0 → GPIO1, driven through runSingleTest:

UCS7604-800KHZ leds=  1 passed=True  4/4  bytes=84    (21 x 4 patterns)
UCS7604-800KHZ leds=  4 passed=True  4/4  bytes=156   (39 x 4)
UCS7604-800KHZ leds= 10 passed=True  4/4  bytes=300   (75 x 4)
UCS7604-800KHZ leds= 25 passed=True  4/4  bytes=660   (165 x 4)
UCS7604-800KHZ leds= 40 passed=True  4/4  bytes=1020  (255 x 4)
UCS7604-800KHZ leds= 45 passed=True  4/4  bytes=1140  (285 x 4)
UCS7604-800KHZ leds= 50 passed=False 0/4  bytes=0

Every passing row captures exactly 15 + 6*leds bytes per pattern — the encoded frame length, to the byte. Before the fix every one of these was 0/4.

50 LEDs (315 wire bytes) hits the capture ceiling tracked in #4371; that is a separate defect and is not addressed here.

Unchanged on the paths that already worked: WS2812B-V5 at 100 LEDs, WS2818 and WS2814 at 50, all 4/4, plus bash autoresearch rp2350w --flex-io at its default 100 LEDs.

Fixes #4373

🤖 Generated with Claude Code

https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51

Summary by CodeRabbit

  • New Features
    • Added UCS7604 encoder support to the autoresearch test harness.
    • Tests now validate encoded wire frames, including preamble, padding, and pixel data.
    • Timing tests now use the configured encoder when generating UCS7604 output.

…s the chipset (#4373)

`--chipset ucs7604` failed on the RP2350 PIO loopback at every LED count
from 1 upward. Capture succeeded, the decoder reported success, and the
comparison then disagreed on every byte -- a shape that reads as a driver
or wiring fault.

It was neither. `autoResearchChipsetTiming()` re-creates each clockless
channel from the runtime timing:

    fl::ChannelConfig channel_config(pin, config.timing, leds, rgb_order);

That constructor builds a `ClocklessChipset(pin, timing)`, whose encoder
defaults to `CLOCKLESS_ENCODER_WS2812`. The encoder the timing resolved to
-- `encoder_for<TIMING_UCS7604_800KHZ>()` -> `UCS7604_16BIT` -- reached the
comparison through `config.encoder` but never reached the transmitter. So
the wire carried raw 8-bit pixel bytes while the expectation was the full
UCS7604 frame, starting with its six 0xFF sync bytes. Measured on the
device before the fix, at 4 LEDs: 12 bytes captured (4 x 3 raw pixel
bytes) against a 39-byte expectation, with `actual` running F0 0F AA --
the MSB_LSB_A pattern -- where `expected` ran 255 255 255.

Pass the encoder through and both halves describe the same protocol.

The frame length is the second half of the fix. UCS7604 puts a 15-byte
preamble and 16-bit channels on the wire, so its frame is more than twice
the pixel byte count -- and that count is what sizes the RX edge capacity
in `capture()`. Deriving it from `num_leds * 3` truncates the capture even
once the encoder is right. Both `runTest()` and `runMultiTest()` now build
the expected frame before the capture and use its length for the capacity,
which also drops a per-run allocation from the multi-run loop.

Measured on RP2350W 2DCB876B587EA334, PIO0, GPIO0 -> GPIO1:

    UCS7604-800KHZ leds=  1 passed=True  4/4  bytes=84    (21 x 4 patterns)
    UCS7604-800KHZ leds= 10 passed=True  4/4  bytes=300   (75 x 4)
    UCS7604-800KHZ leds= 45 passed=True  4/4  bytes=1140  (285 x 4)
    UCS7604-800KHZ leds= 50 passed=False 0/4  bytes=0

Every passing row captures exactly `15 + 6*leds` bytes per pattern, the
encoded frame length. 50 LEDs (315 bytes) hits the capture ceiling tracked
in #4371 and is not addressed here.

Unchanged on the paths that already worked: WS2812B-V5 at 100 LEDs,
WS2818 and WS2814 at 50, all 4/4, plus `bash autoresearch rp2350w
--flex-io` at its default 100 LEDs.

Fixes #4373

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a5c10005-d259-4b85-812a-ceb748b7aa79

📥 Commits

Reviewing files that changed from the base of the PR and between 731fb6f and 33c511f.

📒 Files selected for processing (1)
  • examples/AutoResearch/AutoResearchTest.cpp

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The AutoResearch harness now supports UCS7604 encoded frames. It sizes captured data from the encoded frame, compares against a pre-built expectation, and passes the configured encoder to clockless timing channels.

Changes

UCS7604 AutoResearch support

Layer / File(s) Summary
Encoded frame construction and comparison
examples/AutoResearch/AutoResearchTest.cpp
runTest and runMultiTest pre-build UCS7604 encoded frames, size capture capacity from the encoded length, and reuse the frames for comparison.
Configured encoder channel wiring
examples/AutoResearch/AutoResearchTest.cpp
autoResearchChipsetTiming passes config.encoder through fl::ClocklessChipset and ChannelConfig.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant AutoResearchTest
  participant autoResearchChipsetTiming
  participant ClocklessChipset
  participant ChannelConfig
  participant Capture
  AutoResearchTest->>autoResearchChipsetTiming: run UCS7604 timing test
  autoResearchChipsetTiming->>ClocklessChipset: construct with config.encoder
  autoResearchChipsetTiming->>ChannelConfig: pass configured chipset
  ChannelConfig->>Capture: emit encoded wire frame
  Capture-->>AutoResearchTest: return captured bytes
  AutoResearchTest->>AutoResearchTest: compare with pre-built encoded frame
Loading

Merge Risk: ⚪ Minimal · up to 33c51

UCS7604 AutoResearch now transmits, captures, and compares the same encoded frame, including the preamble and 16-bit channel data. The change is ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: passing the resolved encoder into the recreated clockless channel so UCS7604 AutoResearch tests use the correct chipset encoding.
Linked Issues check ✅ Passed The PR satisfies #4373. autoResearchChipsetTiming now recreates clockless channels with config.encoder, so UCS7604 transmission uses the UCS7604 encoder instead of the default WS2812 encoder. `run…
Out of Scope Changes check ✅ Passed The reviewed changes are limited to examples/AutoResearch/AutoResearchTest.cpp. They configure the encoder used for recreated channels, size capture buffers from the encoded UCS7604 frame, reuse the…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/autoresearch-ucs7604-encoder

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit e0b793f into master Sep 12, 2026
21 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 12, 2026
zackees added a commit that referenced this pull request Sep 12, 2026
…tually hold (#4371)

`runSingleTest` bounded `laneSizes` with `mState->rx_buffer.size() / 32`.
That measures the wrong thing twice over: `rx_buffer` is the decode
*output* buffer, and 32 has no relation to the capture. It advertised 103
LEDs, and 101, 102 and 103 were all accepted and then failed in capture
with `bytes: 0` and no error -- the outcome a bounds check exists to
prevent.

There are two ceilings, and each is the binding one in its own regime,
which is why no constant fit both chipsets:

1. Edge pool. The capture appends one EdgeTime per signal phase into a
   fixed pool -- two phases per bit, eight bits per wire byte -- so
   `kRpPioRxEdgeCapacity / 16` = 300 wire bytes.

2. Sample-time budget. The sampler packs 32 samples per DMA word at
   20 MHz, and `mDmaWordCount` is pinned at `(4801 + 1) / 2 + 64` = 2465
   for every frame large enough to matter. That is a constant quantity of
   wall clock, not of data: 2465 x 32 x 50 ns = 3.944 ms, less the 100 us
   of trailing idle the capture must observe and the arm-to-first-edge gap.

At 1225 ns the pool binds first (300 bytes, 2.9 ms); at 2500 ns the clock
binds first (3.84 ms, 189 bytes). Measured apart on hardware: 192 wire
bytes and 3072 phases pass 3/3 at 800 kHz and fail 3/3 at 400 kHz, so
constraint 2 is about time and constraint 1 is about size.

The bound also has to be encoder-aware. A UCS7604 lane is more than twice
a WS2812 lane of the same length -- 15-byte preamble, 16-bit channels,
padding to a multiple of three -- so it tops out at 47 LEDs where WS2812
tops out at 100. A guard phrased in LEDs cannot be right for both.

`fl::validation::rpPioMaxWireBytes()` takes the smaller of the two, and
the check moves to just after the timing and encoder are resolved, since
it needs both. The old guard stays as a coarse pre-allocation backstop.

`kPioRxClockHz`, `kPioRxSamplesPerDmaWord` and `kPioRxDmaTailWords` move
into `rx_pio_channel.h` so the bound is computed from the sampler's own
constants rather than copies, and `collectDurations()` now uses the named
samples-per-word constant instead of a bare 32. `ucs7604FrameBytes()`
joins the encoder header for the same reason: `encodeUCS7604()` derives
its padding from it, so the length callers predict and the length written
cannot drift.

Measured on RP2350W 2DCB876B587EA334, PIO0, GPIO0 -> GPIO1. Every boundary
is now the hardware's:

    WS2812B-V5     100 accepted 4/4    101 rejected (303 B > 300)
    WS2818         100 accepted 4/4    101 rejected (303 B > 300)
    WS2814         100 accepted 4/4    101 rejected (303 B > 300)
    WS2811-400KHZ   63 accepted 4/4     64 rejected (192 B > 189)
    UCS7604-800KHZ  47 accepted         48 rejected (303 B > 300)

The silent band is empty for all five. The host tests assert the same
ceilings against the production function.

(UCS7604 still compares as failed here -- that is #4373, fixed separately
in #4377; this branch is off master. It captures 141 bytes at 47 LEDs,
47 x 3 raw pixel bytes, which is exactly that defect's signature.)

Fixes #4371

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
zackees added a commit that referenced this pull request Sep 12, 2026
…tually hold (#4371) (#4378)

* fix(autoresearch): bound RP PIO lane sizes by what the capture can actually hold (#4371)

`runSingleTest` bounded `laneSizes` with `mState->rx_buffer.size() / 32`.
That measures the wrong thing twice over: `rx_buffer` is the decode
*output* buffer, and 32 has no relation to the capture. It advertised 103
LEDs, and 101, 102 and 103 were all accepted and then failed in capture
with `bytes: 0` and no error -- the outcome a bounds check exists to
prevent.

There are two ceilings, and each is the binding one in its own regime,
which is why no constant fit both chipsets:

1. Edge pool. The capture appends one EdgeTime per signal phase into a
   fixed pool -- two phases per bit, eight bits per wire byte -- so
   `kRpPioRxEdgeCapacity / 16` = 300 wire bytes.

2. Sample-time budget. The sampler packs 32 samples per DMA word at
   20 MHz, and `mDmaWordCount` is pinned at `(4801 + 1) / 2 + 64` = 2465
   for every frame large enough to matter. That is a constant quantity of
   wall clock, not of data: 2465 x 32 x 50 ns = 3.944 ms, less the 100 us
   of trailing idle the capture must observe and the arm-to-first-edge gap.

At 1225 ns the pool binds first (300 bytes, 2.9 ms); at 2500 ns the clock
binds first (3.84 ms, 189 bytes). Measured apart on hardware: 192 wire
bytes and 3072 phases pass 3/3 at 800 kHz and fail 3/3 at 400 kHz, so
constraint 2 is about time and constraint 1 is about size.

The bound also has to be encoder-aware. A UCS7604 lane is more than twice
a WS2812 lane of the same length -- 15-byte preamble, 16-bit channels,
padding to a multiple of three -- so it tops out at 47 LEDs where WS2812
tops out at 100. A guard phrased in LEDs cannot be right for both.

`fl::validation::rpPioMaxWireBytes()` takes the smaller of the two, and
the check moves to just after the timing and encoder are resolved, since
it needs both. The old guard stays as a coarse pre-allocation backstop.

`kPioRxClockHz`, `kPioRxSamplesPerDmaWord` and `kPioRxDmaTailWords` move
into `rx_pio_channel.h` so the bound is computed from the sampler's own
constants rather than copies, and `collectDurations()` now uses the named
samples-per-word constant instead of a bare 32. `ucs7604FrameBytes()`
joins the encoder header for the same reason: `encodeUCS7604()` derives
its padding from it, so the length callers predict and the length written
cannot drift.

Measured on RP2350W 2DCB876B587EA334, PIO0, GPIO0 -> GPIO1. Every boundary
is now the hardware's:

    WS2812B-V5     100 accepted 4/4    101 rejected (303 B > 300)
    WS2818         100 accepted 4/4    101 rejected (303 B > 300)
    WS2814         100 accepted 4/4    101 rejected (303 B > 300)
    WS2811-400KHZ   63 accepted 4/4     64 rejected (192 B > 189)
    UCS7604-800KHZ  47 accepted         48 rejected (303 B > 300)

The silent band is empty for all five. The host tests assert the same
ceilings against the production function.

(UCS7604 still compares as failed here -- that is #4373, fixed separately
in #4377; this branch is off master. It captures 141 bytes at 47 LEDs,
47 x 3 raw pixel bytes, which is exactly that defect's signature.)

Fixes #4371

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51

* fixup: gate the capture bound on the RX backend and share the sampler constants

Review found the bound keyed off `driver_name`, i.e. the transmitter. The
ceiling belongs to whatever captures. On RP, PLATFORM_DEFAULT resolves to
PIO RX whatever the TX driver is, so a UART0 request -- captured by the
same pool, subject to the same ceiling -- skipped the check entirely, and
a PIO TX pointed at another backend would have received a PIO-only
rejection.

Confirmed on hardware: UART0 at 64 and 100 LEDs went straight through into
the silent capture failure the guard exists to prevent. It now follows the
RX channel and tests the backend, and both are rejected with the same
message PIO0 gets.

The sampler constants move to fl/channels/rx/pio_geometry.h, portable and
outside the RP build guard, so the device, the bound and the host test read
one set of definitions instead of copies -- the tests previously restated
4801/64/32/50 and could have passed while production computed something
else. Renamed with the kRpPioRx prefix on the way, since they are no longer
file-local.

Measured after the change (RP2350W 2DCB876B587EA334, GPIO0 -> GPIO1):

    PIO0  WS2812B-V5      100 accepted 4/4   101 rejected
    PIO0  WS2811-400KHZ    63 accepted 4/4    64 rejected
    PIO0  UCS7604-800KHZ   47 accepted        48 rejected
    UART0 WS2811-400KHZ    63 accepted        64 rejected, 100 rejected

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51

* fixup: an RGBW lane is four bytes per LED, so its capture ceiling is lower

Review caught the WS2812 branch of rpPioWireFrameBytes() returning
`leds * 3` unconditionally. With legacyRgbw, or a chipset with automatic
RGBW, LegacyClocklessProxy emits four bytes per LED -- so a 100-LED RGBW
frame is 400 wire bytes and the guard accepted it against a 300-byte
ceiling, which is the silent failure this check exists to remove.

Both wire-byte helpers now take the effective width, computed with the
same predicate the comparison uses (`legacyLaneUsesRgbw`): the request's
legacyRgbw flag, or legacyClocklessChipsetHasAutomaticRgbw() for the
lane's chipset.

Measured on RP2350W 2DCB876B587EA334, PIO0, GPIO0 -> GPIO1:

    legacy WS2812B (RGB)        100 accepted 4/4   101 rejected (303 B)
    legacy WS2814  (auto RGBW)   75 accepted 8/8    76 rejected (304 B)
    legacy WS2812B + legacyRgbw  75 accepted 4/4    76 rejected (304 B)

75 x 4 = 300 bytes = 4800 phases, one under the 4801-slot pool; 76 x 4 =
304 bytes = 4864, over it. Predicted and measured boundaries agree to the
LED on all three.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@zackees
zackees deleted the fix/autoresearch-ucs7604-encoder branch November 5, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

AutoResearch: --chipset ucs7604 fails at every length — capture decodes, but the comparison reads 16-bit data as 8-bit

1 participant