Skip to content

feat(autoresearch): replace RpcClient boot_wait sleep with signature polling #2271

Closed

Description

@zackees

Summary

Replace fixed sleep(3.0) waits in the autoresearch RPC flow with fast polling that watches for FastLED-specific boot signatures and breaks early.

Current behavior

# RpcClient.connect() — fixed 3s sleep
await asyncio.sleep(boot_wait)  # Always waits 3s regardless of device speed

# gpio.py DTR reset — fixed 3s sleep  
await asyncio.sleep(3.0)  # Always waits 3s after reset

Proposed behavior

RpcClient.connect() — poll for boot signature

# Instead of sleeping, read serial output and watch for known boot strings
deadline = time.time() + boot_wait
while time.time() < deadline:
    lines = await read_lines(timeout=0.1)
    if any(sig in line for line in lines for sig in BOOT_SIGNATURES):
        break

gpio.py — use reset_device(wait_for_output=True)

# fbuild handles the low-level "wait for any output" (fbuild#68)
await serial_interface.reset_device(board=None, wait_for_output=True)
# Then poll for RPC-ready signature

Boot signatures (FastLED-specific)

Signal Meaning Phase
"entry 0x" ROM bootloader started Post-reset
"Before Setup Start" Arduino setup() starting Post-boot
"RESULT:" JSON-RPC server ready Pre-RPC
"AutoResearch" AutoResearch sketch running Firmware alive

Expected improvement

ESP32-S3 with USB-CDC boots in <500ms. Current flow wastes 3s on fixed sleep. With polling:

  • Post-reset wait: ~500ms (down from 3s)
  • Boot drain: ~200ms (down from 1s)
  • Total autoresearch cycle: ~5s faster per run

Depends on

Parent issue

#2265

Activity

  1. added a commit that references this issue on Apr 17, 2026
    6a84fd6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions