Skip to content

feat: reset_device() wait_for_output option — poll for boot output instead of returning immediately #68

@zackees

Description

@zackees

Summary

SerialMonitor.reset_device() currently sends POST /api/reset and returns immediately. Add a wait_for_output option that watches for serial output after reset and returns as soon as the device starts producing data (= rebooted and running).

Current behavior

mon.reset_device(board="esp32s3")  # Returns True immediately after DTR toggle
time.sleep(3.0)  # Caller has to guess how long to wait

Proposed behavior

mon.reset_device(board="esp32s3", wait_for_output=True, timeout=5.0)
# Returns True as soon as any serial output is detected (device rebooted)
# Returns False if timeout expires with no output
# Typical ESP32-S3 USB-CDC: returns in <500ms instead of fixed 3s

Implementation

In crates/fbuild-python/src/lib.rs, after the HTTP reset call succeeds:

  1. If wait_for_output is false (default): return immediately (current behavior)
  2. If wait_for_output is true:
    • Attach a serial monitor to the port
    • Poll read_lines() in a tight loop (100ms intervals)
    • Return true as soon as any line is received
    • Return false if timeout expires

This is generic — no application-specific signatures needed. Any serial output = device booted.

API

#[pyo3(signature = (board=None, wait_for_output=false, timeout=5.0))]
fn reset_device(
    &self,
    board: Option<String>,
    wait_for_output: bool,
    timeout: f64,
) -> PyResult<bool>

Parent issue

FastLED/FastLED#2265 — replace sleep-based reset waits with spin-poll validation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions