Repository navigation
feat(parlio): land c6 streaming diagnostics - #2682
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR enhances AutoResearch CI capabilities with environment-aware port detection, extends PARLIO driver debugging infrastructure with underrun tracking and PSRAM-aware memory allocation, integrates advanced benchmarking into AutoResearch examples, and refines serial communication backends for ESP32 variants. ChangesPARLIO Benchmarking, Debugging, and Port Detection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hpp (1)
302-320:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift
available()no longer reports the buffered byte count.Both
src/platforms/esp/32/drivers/usb_serial_jtag_esp32.handsrc/fl/system/serial.hdocumentavailable()as a byte count, but this implementation can only return0or1. That breaks the serial contract for any caller that gates onavailable() >= nand underreports queued RX data once more than one byte is buffered.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hpp` around lines 302 - 320, UsbSerialJtagEsp32::available currently returns only 0/1 because it only checks mHasPeek or reads one byte with usb_serial_jtag_read_bytes; change it to return the full buffered RX byte count per the serial contract: query the driver's buffered byte count API (e.g., a function like usb_serial_jtag_get_buffered_data_len or usb_serial_jtag_get_buffered_bytes) and return that count plus (mHasPeek ? 1 : 0) while preserving mPeekByte/mHasPeek, and if no such driver API exists, read all currently-available bytes non-blocking into the class RX buffer (or stash them starting with mPeekByte) and return the total buffered length; update UsbSerialJtagEsp32::available, keeping references to mBuffered, mHasPeek, mPeekByte and usb_serial_jtag_read_bytes to locate the logic to modify.src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp (1)
611-618:⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy liftUnderruns currently drop the engine into a false READY state.
Line 613 clears
mTransmittingbefore any buffer is re-submitted.workerIsrCallback()only refills the ring, andpoll()later short-circuits toREADYon Line 2144 whenmTransmittingis false. That means the first underrun can make chunked frames larger than the ring stop draining with buffered data still pending.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp` around lines 611 - 618, Underrun handling clears ctx->mTransmitting too early (before workerIsrCallback repopulates the ring), causing poll() to treat the engine as READY while buffered data remains; to fix, do not clear ctx->mTransmitting before attempting to refill—either move the ctx->mTransmitting = false assignment to after workerIsrCallback returns and only clear it if the worker did not re-submit any buffers (or check the ring/queue emptiness), or call workerIsrCallback first and then update ctx->mTransmitting based on whether new buffers were queued; keep the underrun counter (ctx->mUnderrunCount) and mHardwareIdle update as-is but ensure mTransmitting reflects actual pending work so poll() won’t short-circuit.
🧹 Nitpick comments (1)
ci/tests/test_autoresearch_phases.py (1)
332-373: ⚡ Quick winAdd a regression case for an inconclusive probe.
These assertions cover the happy path, but not the case where
auto_detect_upload_port(expected_environment=...)gets only probe failures and should still keep the port usable via fallback selection. A test for that path would catch the current hard-fail regression before it reaches the hardware loop.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/tests/test_autoresearch_phases.py` around lines 332 - 373, Add a regression test that mocks auto_detect_upload_port to return an inconclusive probe (e.g., MagicMock(ok=False, selected_port="COMx")) and verifies _resolve_port_and_environment still accepts the selected_port as a usable fallback; patch f"{_PATCH_MOD}.auto_detect_upload_port" and f"{_PATCH_MOD}.select_build_driver" and keep get_default_environment patched as in the existing tests, then assert rc is None, ctx.upload_port equals the mocked selected_port and auto_detect_upload_port was called with the expected_environment (use _resolve_port_and_environment, select_build_driver and expected_environment strings like "esp32s3"/"esp32c6" to locate the code paths).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/util/port_utils.py`:
- Line 69: The public helper auto_detect_upload_port currently defines a
defaulted parameter expected_environment: str | None = None which violates the
repo rule forbidding default parameter values; change the function signature to
expected_environment: str | None (no default) in auto_detect_upload_port and
update every call site to pass an explicit value (use None where callers relied
on the old default). Ensure the type annotation remains and adjust any tests or
usages that call auto_detect_upload_port() with no arguments to call
auto_detect_upload_port(None) instead.
- Around line 134-165: The code currently aborts port resolution if every
detect_attached_chip() call fails; instead only produce a
ComportResult(ok=False, ...) when you have positive detection evidence that none
match the expected environment. Modify the loop in
_resolve_port_and_environment: collect probe_notes as before but track whether
any detect_attached_chip() returned ok (e.g., saw_positive_detection) and
whether any detected_env was present but different; if at least one probe
succeeded but none matched expected_env, return the ComportResult failure (use
environment_to_chip(expected_env) or expected_environment in the message); if no
probes succeeded at all, do not return here — allow the function to fall through
to the existing USB descriptor-based selection heuristic.
In `@examples/AutoResearch/AutoResearchRemote.cpp`:
- Around line 1762-1779: The txPins parsing currently silently skips
non-integers and compacts entries; instead validate strictly in the txPins
handling: if config["txPins"] is an array, ensure its size equals numLanes (or
reject if numLanes not provided) and verify every element is an integer within
allowed range (and within autoresearch::parlio_stream::kMaxLanes); on any
invalid element or length mismatch, return InvalidArgs rather than compacting
(do not modify tx_pins, parsed_lanes, has_tx_pins, num_lanes, or base_tx_pin);
apply the same strict validation and rejection logic to the rxPins parsing block
(the code around the rx_pins parsing at lines 1783-1794) so malformed arrays are
refused instead of being truncated or packed.
In `@src/platforms/esp/32/drivers/parlio/parlio_debug.h`:
- Around line 26-32: The public debug contract is out of sync: extend the
exported ParlioDebugMetrics struct and its getParlioDebugMetrics() mapper to
include the new fields (mTxDoneCount, mWorkerIsrCount, mUnderrunCount,
mRingCount, mErrorCode, mRingError, mHardwareIdle) so callers can observe the
new counters and flags; update the ParlioDebugMetrics definition and the
function that assembles/returns it (getParlioDebugMetrics) to map the new
members from the driver-side representation to the public struct and adjust any
serialization or consumers that assume the old shape.
---
Outside diff comments:
In `@src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp`:
- Around line 611-618: Underrun handling clears ctx->mTransmitting too early
(before workerIsrCallback repopulates the ring), causing poll() to treat the
engine as READY while buffered data remains; to fix, do not clear
ctx->mTransmitting before attempting to refill—either move the
ctx->mTransmitting = false assignment to after workerIsrCallback returns and
only clear it if the worker did not re-submit any buffers (or check the
ring/queue emptiness), or call workerIsrCallback first and then update
ctx->mTransmitting based on whether new buffers were queued; keep the underrun
counter (ctx->mUnderrunCount) and mHardwareIdle update as-is but ensure
mTransmitting reflects actual pending work so poll() won’t short-circuit.
In `@src/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hpp`:
- Around line 302-320: UsbSerialJtagEsp32::available currently returns only 0/1
because it only checks mHasPeek or reads one byte with
usb_serial_jtag_read_bytes; change it to return the full buffered RX byte count
per the serial contract: query the driver's buffered byte count API (e.g., a
function like usb_serial_jtag_get_buffered_data_len or
usb_serial_jtag_get_buffered_bytes) and return that count plus (mHasPeek ? 1 :
0) while preserving mPeekByte/mHasPeek, and if no such driver API exists, read
all currently-available bytes non-blocking into the class RX buffer (or stash
them starting with mPeekByte) and return the total buffered length; update
UsbSerialJtagEsp32::available, keeping references to mBuffered, mHasPeek,
mPeekByte and usb_serial_jtag_read_bytes to locate the logic to modify.
---
Nitpick comments:
In `@ci/tests/test_autoresearch_phases.py`:
- Around line 332-373: Add a regression test that mocks auto_detect_upload_port
to return an inconclusive probe (e.g., MagicMock(ok=False,
selected_port="COMx")) and verifies _resolve_port_and_environment still accepts
the selected_port as a usable fallback; patch
f"{_PATCH_MOD}.auto_detect_upload_port" and f"{_PATCH_MOD}.select_build_driver"
and keep get_default_environment patched as in the existing tests, then assert
rc is None, ctx.upload_port equals the mocked selected_port and
auto_detect_upload_port was called with the expected_environment (use
_resolve_port_and_environment, select_build_driver and expected_environment
strings like "esp32s3"/"esp32c6" to locate the code paths).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d30d4331-1060-4be2-8705-7bd4a4a36021
📒 Files selected for processing (17)
ci/autoresearch/phases.pyci/boards/esp32-c6-devkitc-1.jsonci/tests/test_autoresearch_phases.pyci/util/port_utils.pyexamples/AutoResearch/AutoResearch.inoexamples/AutoResearch/AutoResearchParlioEncode.hexamples/AutoResearch/AutoResearchParlioStream.hexamples/AutoResearch/AutoResearchRemote.cppsrc/platforms/esp/32/drivers/_build.cpp.hppsrc/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hppsrc/platforms/esp/32/drivers/lcd_spi/lcd_spi_peripheral_esp.cpp.hppsrc/platforms/esp/32/drivers/parlio/parlio_debug.hsrc/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hppsrc/platforms/esp/32/drivers/parlio/parlio_isr_context.hsrc/platforms/esp/32/drivers/usb_serial_jtag_esp32.hsrc/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hppsrc/platforms/esp/32/io_esp.cpp.hpp
💤 Files with no reviewable changes (2)
- src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_clockless.cpp.hpp
- src/platforms/esp/32/drivers/lcd_spi/lcd_spi_peripheral_esp.cpp.hpp
| if (config.contains("txPins") && config["txPins"].is_array()) { | ||
| int parsed_lanes = 0; | ||
| const fl::json pins = config["txPins"]; | ||
| for (size_t i = 0; | ||
| i < pins.size() && i < autoresearch::parlio_stream::kMaxLanes; | ||
| ++i) { | ||
| if (!pins[i].is_int()) { | ||
| continue; | ||
| } | ||
| tx_pins[parsed_lanes++] = static_cast<int>(pins[i].as_int().value()); | ||
| } | ||
| if (parsed_lanes > 0) { | ||
| has_tx_pins = true; | ||
| if (!(config.contains("numLanes") && config["numLanes"].is_int())) { | ||
| num_lanes = parsed_lanes; | ||
| } | ||
| base_tx_pin = tx_pins[0]; | ||
| } |
There was a problem hiding this comment.
Reject malformed txPins instead of compacting them.
This parser silently skips non-integer entries and packs later pins leftward, so a request like [0, "bad", 2] is executed as a different lane map while the RPC still reports success. For a hardware-diagnostics command, that makes the result misleading. Return InvalidArgs when any txPins[i] is invalid, and reject arrays whose length does not match numLanes instead of truncating/clamping.
Also applies to: 1783-1794
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@examples/AutoResearch/AutoResearchRemote.cpp` around lines 1762 - 1779, The
txPins parsing currently silently skips non-integers and compacts entries;
instead validate strictly in the txPins handling: if config["txPins"] is an
array, ensure its size equals numLanes (or reject if numLanes not provided) and
verify every element is an integer within allowed range (and within
autoresearch::parlio_stream::kMaxLanes); on any invalid element or length
mismatch, return InvalidArgs rather than compacting (do not modify tx_pins,
parsed_lanes, has_tx_pins, num_lanes, or base_tx_pin); apply the same strict
validation and rejection logic to the rxPins parsing block (the code around the
rx_pins parsing at lines 1783-1794) so malformed arrays are refused instead of
being truncated or packed.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
ci/autoresearch/runner.py (1)
99-104:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse
final_environmentwhen resolving the decode port.This branch already knows the expected environment, but Line 103 passes
Noneand skips the new chip probe. If several boards are connected, decode mode can attach to the wrong device.Suggested fix
- port_result = auto_detect_upload_port(None) + port_result = auto_detect_upload_port(final_environment)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/autoresearch/runner.py` around lines 99 - 104, The code is passing None to auto_detect_upload_port when resolving the decode/upload port, which ignores the known ctx.final_environment and can attach to the wrong board; change the call in the final_environment branch to pass final_environment (or ctx.final_environment) instead of None so auto_detect_upload_port receives the expected environment and can probe the correct chip when upload_port is not provided.ci/autoresearch/driver_sweep.py (1)
518-523:⚠️ Potential issue | 🟠 Major | ⚡ Quick winPass the target environment into port auto-detection.
This path builds/uploads
esp32c6, but Line 522 passesNoneand disables the new environment-aware probe. With more than one board attached, the sweep can bind to the wrong device.Suggested fix
- result = auto_detect_upload_port(None) + result = auto_detect_upload_port("esp32c6")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/autoresearch/driver_sweep.py` around lines 518 - 523, The port auto-detection call currently passes None to auto_detect_upload_port, which disables environment-aware probing; update the call in driver_sweep.py (where port is set and auto_detect_upload_port is invoked) to pass the target environment (e.g., args.env or the variable holding the build target like "esp32c6") instead of None so the probe filters by board type; ensure the argument you pass matches the auto_detect_upload_port signature used elsewhere (adjust the call to auto_detect_upload_port(args.env) or the appropriate target variable).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ci/debug_attached.py`:
- Around line 1255-1259: The upload port auto-detection is being called with
None which bypasses the environment-aware ESP probe; change the call to
auto_detect_upload_port to pass the resolved environment (args.environment)
instead of None so auto_detect_upload_port(args.environment) uses the correct
target environment when selecting among multiple USB devices (refer to
args.upload_port, args.environment, and auto_detect_upload_port).
---
Outside diff comments:
In `@ci/autoresearch/driver_sweep.py`:
- Around line 518-523: The port auto-detection call currently passes None to
auto_detect_upload_port, which disables environment-aware probing; update the
call in driver_sweep.py (where port is set and auto_detect_upload_port is
invoked) to pass the target environment (e.g., args.env or the variable holding
the build target like "esp32c6") instead of None so the probe filters by board
type; ensure the argument you pass matches the auto_detect_upload_port signature
used elsewhere (adjust the call to auto_detect_upload_port(args.env) or the
appropriate target variable).
In `@ci/autoresearch/runner.py`:
- Around line 99-104: The code is passing None to auto_detect_upload_port when
resolving the decode/upload port, which ignores the known ctx.final_environment
and can attach to the wrong board; change the call in the final_environment
branch to pass final_environment (or ctx.final_environment) instead of None so
auto_detect_upload_port receives the expected environment and can probe the
correct chip when upload_port is not provided.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ee465d98-7aa8-42c3-82f2-330695807708
📒 Files selected for processing (12)
ci/autoresearch/driver_sweep.pyci/autoresearch/runner.pyci/debug/validate_port_kill.pyci/debug_attached.pyci/tests/test_autoresearch_phases.pyci/util/port_utils.pyexamples/AutoResearch/AutoResearchRemote.cppsrc/platforms/esp/32/drivers/parlio/channel_driver_parlio.cpp.hppsrc/platforms/esp/32/drivers/parlio/channel_driver_parlio.hsrc/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hppsrc/platforms/esp/32/drivers/usb_serial_jtag_esp32.hsrc/platforms/esp/32/drivers/usb_serial_jtag_esp32_idf.hpp
🚧 Files skipped from review as they are similar to previous changes (2)
- src/platforms/esp/32/drivers/parlio/parlio_engine.cpp.hpp
- examples/AutoResearch/AutoResearchRemote.cpp
Summary
origin/mastertxPinshandling and encode benchmark PSRAM availability fieldsValidation
git diff --checkuv run pytest ci/tests/test_autoresearch_phases.py(44 passed)PLATFORMIO_SRC_DIR=$PWD\examples\AutoResearch pio run -e esp32c6pio run -e esp32c6 -t upload --upload-port COM9parlioStreamValidate, 8 LEDs/lane: all completed; 16-lane case returnedbytesTotal=24,bytesTransmitted=24,txDoneCount=1,ringError=false,hardwareIdle=falsebytesTotal=384,bytesTransmitted=384,ringError=falsebytesTotal=768,bytesTransmitted=768,txDoneCount=3,workerIsrCount=2,underrunCount=2,ringError=false,hardwareIdle=falsepingRPC succeeded after every large-frame stream testSummary by CodeRabbit
New Features
Bug Fixes
Tests
Chores