Repository navigation
feat(channels): expose the wire timing the UART encoder actually produces - #4227
Conversation
…uces The UART encoder quantises T0H/T1H onto a grid of period/pulses_per_bit, so what reaches the wire is not the chipset's nominal timing. Any receiver decoding a UART-encoded frame has to classify against the quantised values; AutoResearch currently hardcodes one chipset's worth of them, which is why a 400 kHz frame decodes every symbol wrongly (#3899). uartWireTiming() derives them through the same fitUartWave() rules that built the LUT, so decode windows cannot drift from the encoding -- the alternative, recomputing the rounding at the decode site, is exactly the drift the encoder's own comment warns against. Correcting a claim I made on #3899 while working this out: I asserted deriving would reproduce AutoResearch's hardcoded {250, 500, 500} exactly for WS2812. It does not. WS2812B-V5 is T1=225 T2=355 T3=645, a 1225 ns period, and the derived wire timing is {245, 490, 490}. The constants correspond to a nominal 1250 ns part. The deltas are 5 and 10 ns against a +/-250 ns classification tolerance, so no symbol can change class -- but "well inside tolerance" is a weaker claim than "identical", and I had asserted the stronger one from an assumed period rather than the real values. Tests assert the derived values exactly, the tolerance property that makes substitution safe, and that an unreachable baud ceiling reports infeasible rather than guessing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe UART encoder now exposes ChangesUART wire timing
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This adds UART wire-timing reporting aligned with encoder quantization, with infeasible configurations reported explicitly. The documented timing behavior and size change are covered, with no concrete current-head merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…adds The bloat gate reports: esp32s3-bloat-regression: FAIL -- total_flash=342,407 B exceeds baseline=342,393 B by 14 B That 14 B is this PR's helper, and the gate's own message asks for the baseline to move in the same PR when the growth is intended. It is intended, though worth being explicit that this PR alone adds a function nothing calls yet: the caller lands in #4228, which is what turns UART loopback on RP from 40/40 LEDs wrong into a pass. The helper cannot be header-inlined to let the linker drop it -- it calls fitUartWave(), which is internal to the encoder translation unit, and sharing those rules is the entire point of the change. 14 B against a 342 KB image, in exchange for a decoder that classifies against the waveform actually transmitted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
|
Two CI failures, one real and now fixed, one infrastructure. Bloat regression — real, and mine. 14 bytes, from this PR's helper. The gate's message asks for the baseline to move in the same PR when the growth is intended, so Worth being explicit about what is being paid for: this PR alone adds a function nothing calls yet. The caller is #4228, which turns UART loopback on RP from 40/40 LEDs wrong into a pass. If #4227 landed without #4228 following, those 14 bytes would buy nothing. I looked at avoiding them rather than just moving the number. The helper cannot be header-inlined so the linker drops it when unused — it calls
An external package fetch, nothing to do with this diff. Re-running it. |
…4234) The gate is red on master itself, so every open PR fails it -- including #4232, which touches only test files and CI Python. Master's own run measures total_flash=342,409 B against a pinned 342,407 B. No single PR regressed; the drift is the sum of six changes merged in one burst on 2026-09-09 16:57-16:59Z, each measured against a base that predated the others: #4204 342,393 B (baseline 342,393, headroom 0) #4206 342,391 B (baseline 342,393, headroom 2) #4213 342,391 B #4220 342,391 B #4221 342,391 B #4227 342,407 B (baseline 342,407 -- raised in that PR, headroom 0) Every one of them passed. Their combination is 2 B over. That is the known limit of measuring each PR against its own merge base, not a regression anyone shipped, so re-pinning to the measured value records what master is rather than hiding anything: a PR that adds flash on top of 342,409 B still fails. Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Groundwork for the last unfixed UART defect on #3899. This PR adds only the encoder-side helper; it does not yet change any decoder.
The problem it addresses
The UART encoder quantises T0H/T1H onto a grid of
period / pulses_per_bit, so what reaches the wire is not the chipset's nominal timing. A receiver decoding a UART-encoded frame must classify against the quantised values.AutoResearchTest.cppinstead hardcodes one chipset's worth of them:fl::ChipsetTiming uart_timing{250, 500, 500, 50, "UART_4Mbps"};Measured consequence on RP2350W at 400 kHz (the only rate the RP PL011 can clock — see #4224):
{250, 500, 500}What this adds
It runs the same
fitUartWave()the LUT was built from, so decode windows cannot drift from the encoding. Recomputing the rounding at the decode site would duplicate that logic — which the encoder's own comment warns against: "Shared by buildWave10Lut() and canRepresentTiming() so the LUT that gets built is always judged by the same rules that admitted it."Correcting a claim I made on #3899
I asserted that deriving reproduces the hardcoded constants exactly for WS2812, and used that as the argument the change is risk-free on platforms I cannot test. That was wrong, and the test caught it:
The constants correspond to a nominal 1250 ns part; V5 is 1225 ns. I had computed the "proof" from an assumed period instead of reading the actual timing macros.
The safety argument survives in weaker form — 5-10 ns against a ±250 ns classification tolerance cannot move any symbol across a boundary — but "well inside tolerance" is not "identical", and I had asserted the stronger claim. The test now pins the real derived values so a future timing change cannot drift silently.
Scope
Encoder-side only. Switching the AutoResearch decoder over is a separate change, deliberately, so the helper and its ESP32-visible consequences can be reviewed on their own.
Tests cover the derived values exactly, the tolerance property that makes substitution safe, and infeasible-ceiling handling.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
Summary by CodeRabbit
New Features
Tests