mothercup/tools/uart_cap.py
evan.liu 8a7cebcf77 V1.00.26: UART baud 115200 -> 460800
- firmware BSP_USART_BAUDRATE 460800 (divider error +0.03%); uartrst/
  uartinfo follow the macro
- RX DMA ring 2KB -> 3KB: at 460800 2KB only covers 44ms, less than the
  ~45ms flash-erase interrupt-off window; stack top now 0x2000BDE8
  (guard warns <1KB from the 0x2000C000 cliff, by design)
- tools: ble_ota_update.py UartTransport and uart_cap.py default baud
- Verified: stream OTA 55832B in 2.6s @23kB/s (one lost frame recovered
  by go-back-N), PASS after reboot; text CLI fine at 460800
- docs: ble_protocol.md, design spec, AGENTS.md, dev log section 48
2026-09-05 10:01:23 +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, 460800, 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)