Repository navigation
Description
Context
FastLED AutoResearch on ESP32-S3 can flash successfully with fbuild==2.3.12, and fbuild.api.SerialMonitor can receive device output, but host-to-device writes do not reach the board after the monitor has been used for reads.
Observed command:
bash autoresearch esp32s3 --all --skip-lint --timeout 240Environment:
- Windows
- fbuild 2.3.12
- ESP32-S3 on COM22
- FastLED AutoResearch uses
fbuild.api.SerialMonitorthroughci.util.serial_interface.FbuildSerialAdapter
AutoResearch deploy succeeds, then fbuild serial receives boot/status lines from the device:
DEPLOYING (fbuild)
Running: ... fbuild.exe ... deploy -e esp32s3 -p COM22
deploy succeeded (full flash)
[RPC] Using FbuildSerialAdapter backend
[boot-poll] entry 0x403c8898
[boot] RESULT: {"chip":"ESP32-S3 (Xtensa)","type":"ready",...}
[RPC] Sending: {"method":"ping","params":[{}],"id":1}
[async-serial] RESULT: {"type":"status","ready":true,"uptimeMs":5093}
[RPC] Timeout: No response with ID 1 within 10.0s
The device continues to emit RESULT: status lines, but every ping request times out. This points at host-to-device serial writes, not board boot, flashing, or RX from device to host.
A direct fbuild API probe shows the same class of failure:
from fbuild.api import SerialMonitor
import json
port = "COM22"
req = json.dumps({"method": "ping", "params": [{}], "id": 99}, separators=(",", ":")) + "\n"
with SerialMonitor(port=port, baud_rate=115200, auto_reconnect=True, verbose=True) as mon:
for line in mon.read_lines(timeout=3.0):
print("DRAIN", line)
print("write", req.strip())
print("write result", mon.write(req))
for line in mon.read_lines(timeout=8.0):
print("READ", line)Observed output:
write {"method":"ping","params":[{}],"id":99}
write result 0
The SerialMonitor docstring advertises string writes (mon.write("hello\n")), and bytes are rejected with TypeError: argument 'data': 'bytes' object cannot be converted to 'PyString', so this is not a caller-side bytes/string mismatch.
The daemon log shows the underlying failure. A serial session opens, but the background reader later stops and the manager closes the port. Subsequent WebSocket writes for the same client hit a closed port:
fbuild_serial::manager: port opened successfully port="COM22" client_id="54f31db7-6536-4e0a-aa96-05ddaae4320b" attempt=0
fbuild_daemon: Daemon staying alive: 1 open serial session, 1 pending serial attach
fbuild_serial::manager: background reader stopped port="COM22"
fbuild_serial::manager: port closed port="COM22" client_id="deploy_preemption"
fbuild_daemon::handlers::websockets: write error: serial error: port COM22 not open client_id=54f31db7-6536-4e0a-aa96-05ddaae4320b port=COM22
After the failed AutoResearch run, a second FbuildSerialAdapter connect also failed with:
failed to connect to daemon WebSocket at ws://127.0.0.1:8765/ws/serial-monitor: IO error: No connection could be made because the target machine actively refused it. (os error 10061)
Proposal
SerialMonitor should keep the shared serial port open for the lifetime of the monitor session, or transparently reopen it before writes when auto_reconnect=True.
At minimum, SerialMonitor.write() should not silently return 0 when the daemon knows the target port is closed. It should either reopen and write successfully, or raise a structured error that lets callers retry/reconnect.
The daemon-side close path also looks suspicious: the log reports the port closed by client_id="deploy_preemption" after the user serial client is already attached, then later logs write failures for the user client ID. That suggests deploy-preemption cleanup can still close the port after monitor attach.
Acceptance criteria
- A Python
SerialMonitorsession canread_lines(), thenwrite("...\n"), then receive the device's response without the port being closed underneath it. SerialMonitor.write()either writes the full string or raises a clear exception; it must not silently return0while the daemon logsport COM22 not open.- Post-deploy serial attach does not leave a stale
deploy_preemptionclose path that can close the active monitor session's port. bash autoresearch esp32s3 --all --skip-lint --timeout 240can send JSON-RPCpingover fbuild serial after deploy, assuming the flashed firmware is running.
Related issues
- fbuild: absorb post-deploy serial wedge recovery into SerialMonitor; deprecate client pyserial #605 is related background on SerialMonitor owning post-deploy serial recovery, but this issue is a distinct
SerialMonitor.write()/ active-session port-lifetime failure on fbuild 2.3.12.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
chore: bump fbuild to 2.3.13 (#3442)