Skip to content

Reuse fbuild serial proxy in autoresearch recovery - #3245

Merged
zackees merged 1 commit into
masterfrom
fix/fbuild-serial-workarounds
Jun 18, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/fbuild-serial-workarounds

Conversation

@zackees

@zackees zackees commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

Refs FastLED/fbuild#592.\n\n## Summary\n- stop driver_sweep from forcing direct pyserial because of old fbuild daemon locking behavior\n- reuse the existing proxy-backed RpcClient after GPIO reset recovery instead of closing and recreating it\n- add host-only tests proving GPIO retry paths keep the supplied serial proxy open\n\n## Tests\n- uv run ruff format ci/autoresearch/driver_sweep.py ci/autoresearch/gpio.py ci/tests/test_gpio_serial_proxy_retry.py\n- uv run ruff check ci/autoresearch/driver_sweep.py ci/autoresearch/gpio.py ci/tests/test_gpio_serial_proxy_retry.py\n- uv run pytest ci/tests/test_gpio_serial_proxy_retry.py\n- uv run pytest ci/tests/test_autoresearch_phases.py ci/tests/test_serial_interface_reset.py

Summary by CodeRabbit

  • Bug Fixes

    • Improved serial interface recovery behavior during device resets and connection failures.
  • Tests

    • Added test coverage for GPIO workflows to ensure serial proxy sessions remain stable across device reset and retry scenarios.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c2a24dda-03c9-4986-b9eb-f85de758c928

📥 Commits

Reviewing files that changed from the base of the PR and between 1bb6a08 and de0d5a0.

📒 Files selected for processing (3)
  • ci/autoresearch/driver_sweep.py
  • ci/autoresearch/gpio.py
  • ci/tests/test_gpio_serial_proxy_retry.py

📝 Walkthrough

Walkthrough

run_gpio_pretest and run_pin_discovery in gpio.py now conditionally handle RpcClient lifecycle after a DTR reset: they recreate and reconnect only when no serial_interface is provided, and drain boot output on the existing client otherwise. The unconditional early close/reset is removed. driver_sweep.py drops use_pyserial=True. New tests verify both paths.

Changes

GPIO serial proxy reuse on reset

Layer / File(s) Summary
Conditional RpcClient lifecycle after DTR reset
ci/autoresearch/gpio.py
Removes the unconditional client.close() / client = None steps from both run_gpio_pretest and run_pin_discovery. After a ping failure and DTR reset, each function now branches on serial_interface: recreates and reconnects RpcClient when it is None, or calls drain_boot_output on the existing client when an interface is provided.
Remove use_pyserial=True from driver sweep
ci/autoresearch/driver_sweep.py
run_sweep calls create_serial_interface(port) without use_pyserial=True, removing explicit pyserial selection and the associated comment.
Fake serial/RPC client tests for proxy reuse
ci/tests/test_gpio_serial_proxy_retry.py
Adds _FakeSerialInterface (tracks reset_device count) and _FakeRpcClient (tracks connect/close/drain, simulates first-ping failure). Two tests verify run_gpio_pretest reuses the client via drain and run_pin_discovery does not close the client after reset.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant run_gpio_pretest
    participant RpcClient
    participant serial_interface

    Caller->>run_gpio_pretest: call with serial_interface
    run_gpio_pretest->>RpcClient: ping() [fails]
    run_gpio_pretest->>serial_interface: reset_device()
    alt serial_interface is None
        run_gpio_pretest->>RpcClient: close()
        run_gpio_pretest->>RpcClient: new RpcClient + connect(boot_wait)
    else serial_interface provided
        run_gpio_pretest->>RpcClient: drain_boot_output()
    end
    run_gpio_pretest->>RpcClient: ping() [succeeds]
    run_gpio_pretest-->>Caller: result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • FastLED/FastLED#2274: Overlaps at the same run_gpio_pretest and run_pin_discovery DTR-reset recovery control-flow points in ci/autoresearch/gpio.py.
  • FastLED/FastLED#3058: The conditional client reuse introduced here depends on serial_interface close/reuse behavior addressed in ci/util/serial_interface.py.

Poem

🐇 Hop, hop — the serial line stays alive,
No close-and-reopen, we let it survive.
After a reset, just drain what came through,
The proxy keeps running — no need to renew!
One client, one port, one tidy clean path,
The rabbit approves this efficient aftermath. ✨

✨ 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/fbuild-serial-workarounds

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 and usage tips.

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.

1 participant