Repository navigation
Description
runSingleTest reports rpUartStartAttempted, rpUartStartSucceeded, rpUartEncodedSize, rpUartActualBaud and rpUartLastError from the previous UART run whenever the engine declines the current channel. The values look like a report on the test just run; they are not.
Cause
channel_engine_rp_uart.cpp.hpp:73
void ChannelEngineRpUart::show() FL_NO_EXCEPT {
if (mActive || mPendingChannels.empty()) {
return; // <-- early return
}
...
mLastStartAttempted = false; // <-- resets live below it
mLastStartSucceeded = false;
mLastEncodedSize = 0;
mLastActualBaud = 0;
mLastError.clear();enqueue() only pushes a channel when canHandle() accepts it. When canHandle() rejects — wrong pin for the instance, timing needing a baud above the backend maximum — nothing is queued, mPendingChannels is empty, and show() returns at the guard without ever reaching the reset. The previous run's values are then what the harness reports.
Observed
Driving runSingleTest directly on an RP2350W. WS2812B-V5 has a 1225 ns period, so at P=5 it needs ~4.08 MHz — above the backend maximum, which is why it is documented to decline:
UART0 WS2812B-V5 attempted=True baud=2000000 err=''
2000000 baud is arithmetically impossible for a 1225 ns period. It is the WS2811-400KHZ value (5 / 2500 ns), left over from an earlier call in the same device session. A fresh flash reports the truth:
RP UART: attempted=False started=False encodedBytes=0 actualBaud=0
lastError='RP UART: chipset timing needs a baud above the UART backend maximum'
Same driver, same timing, opposite report — the difference is only what ran before it.
UART1 shows the other half of the same defect. It declines consistently, and because mLastError is never set on this path and never cleared, the reason is blank:
UART1 WS2811-400KHZ attempted=False baud=0 err=''
UART1 WS2812B-V5 attempted=False baud=0 err=''
A caller cannot distinguish "the engine declined and said why" from "the engine declined silently" from "these numbers describe a different test".
Why this matters
It is a diagnostic that reports confidently about a run that did not happen. It cost me several wrong readings today: I recorded UART1 as failing in a way I could not explain, and separately reported "a decline path that reports nothing" on #3899 without being able to locate it — this is that path. Anyone comparing UART configurations by varying one parameter at a time will get results contaminated by the previous iteration.
Suggested direction
Reset the diagnostics before the mPendingChannels.empty() guard rather than after it, so a declined channel reports zeros rather than history. Separately, the first canHandle() guard returns false without setting mLastError:
if (!data || !data->isClockless() || !isValidTxPin(data->getPin())) {
return false; // no mLastError set
}The three guards below it all set a message; this one does not, which is why a decline for an unsupported TX pin is indistinguishable from no decline at all.
Reproducing
No rebuild needed. Against flashed firmware, call runSingleTest with driver: "UART0", timing: "WS2811-400KHZ" (succeeds), then the same with timing: "WS2812B-V5" (must decline) and observe the 400 kHz baud reported back.
Environment: RP2350W 2DCB876B587EA334, master. Related: #3899.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 11, 2026
Fixed in #4376, verified on hardware.
One correction to this issue's framing. The report describes the
WS2812B-V5 -> baud=2000000observation as the symptom, which is right — but while fixing it I briefly wrote it up on the PR as evidence of a second defect in how per-calltimingreaches the engine. That was wrong and is withdrawn. 2000000 is simply the inheritedWS2811-400KHZfigure; a freshly flashed board reportsattempted=False baud=0on its first call, which is what identified the number as stale rather than computed. There is no known timing-propagation bug.Also worth recording for anyone reading the fix: the obvious clearing sites are both wrong, and I tried one of them first.
show()'s guard —show()runs every frame, so it would wipe a successful run's diagnostics before the caller read them. Trades a stale report for an empty one.enqueue()'s decline path — my first attempt. Hardware showed it only fixes half the cases:canHandle()is also called during driver selection with noenqueue()following, and that is the path that leaves the stale numbers visible. The giveaway was the error message updating correctly whileattempted/bauddid not, which provescanHandle()ran andenqueue()did not.The clearing belongs in
canHandle(), where a decline is decided regardless of who asked.zackees commentedon Sep 12, 2026
Fixed by #4376, merged as
1987a5782a. The PR body did not carry a closing keyword, so closing by hand.What landed, and where the clearing ended up.
show()resets the diagnostics below itsmActive || mPendingChannels.empty()guard — and an empty pending queue is exactly what a decline produces, so the reset was unreachable on the path that needed it. Moving it above that guard would have been worse:show()runs every frame, so it would wipe a successful run's numbers before the caller read them.The clearing is in
canHandle()instead, which is the call that actually evaluates the channel:Three corrections went into getting that right, each found by running it rather than reading it:
enqueue()'s decline path covered only half the cases —canHandle()is also reached during driver selection with noenqueue()following, which is the path that leftattempted=True baud=2000000visible on a channel the engine had just refused.enqueue()hadif (channelData && canHandle(channelData)), and that short-circuit skippedcanHandle()for a null channel — leaving the diagnostics stale in precisely the case the change exists to fix, and makingcanHandle()'s own null branch unreachable.mLastErroris cleared before the successful return rather than with the numerics at the top, so a failed DMA start recorded byshow()stays readable untilpoll()reports it.The decline also names its reason now. A refusal for a TX pin the instance cannot drive used to return a bare
false, indistinguishable from the engine never being consulted —attempted=falsewith an empty error either way.Verified on an RP2350W (
2DCB876B587EA334, UART0, GPIO0 → GPIO1), alternating a declining and an accepting geometry on the same engine:Stable in both directions. Before the fix the declining rows inherited the accepting run's
attempted=True baud=2000000.One residual, unrelated to this issue but visible in the same output: UART1 declines with an empty error on a build without this fix, and with the pin reason on one with it — so if you see a bare decline on the RP UART, check whether you are on a build predating
1987a5782a.fix(uart): stop 400 kHz picking a geometry whose '1' symbol nothing c…