mothercup/tools/uart_cap.py
evan.liu 520838ce65 V1.00.20: OTA_END ack guaranteed delivery via deferred reset
- app_ota.c: after END ok, wait until the RSP is consumed by the host
  (BLE e0005 read-out / UART TX done) plus 300ms grace before resetting,
  2s timeout fallback; polled from the BLE schedule task (rwip_schedule
  must keep running for the ATT read to be processed)
- main.c: app_ota_reset_poll() in the BLE schedule task loop
- docs: ble_protocol.md 6.6 note, dev log section 43, AGENTS.md sync
2026-09-04 17:35:01 +08:00

21 lines
509 B
Python

# -*- coding: utf-8 -*-
"""Capture UART to a file for N seconds (OTA/BLE debug sessions)."""
import sys
import time
import serial
port = sys.argv[1] if len(sys.argv) > 1 else r"\\.\COM4"
out = sys.argv[2]
dur = float(sys.argv[3]) if len(sys.argv) > 3 else 120
ser = serial.Serial(port, 115200, timeout=0.2)
t0 = time.time()
with open(out, "wb") as f:
while time.time() - t0 < dur:
data = ser.read(4096)
if data:
f.write(data)
f.flush()
print("captured to", out)