Files

39 lines
1.5 KiB
Python
Raw Permalink Normal View History

"""Explicit USB-only smoke test: request a fixed sentence, then hang up."""
import argparse
import time
import serial
p = argparse.ArgumentParser()
p.add_argument("--port", default="COM6")
p.add_argument("--seconds", type=int, default=60)
args = p.parse_args()
port = serial.Serial()
port.port, port.baudrate, port.timeout = args.port, 115200, 0.2
port.dtr = port.rts = False
port.open()
markers = ("PLATFORM_HTTP", "Platform error code:", "call_client:", "USB diagnostic:",
"RTC", "rtc", "volc_start", "PLAYBACK", "DOWNLINK", "AUDIO conversation", "on_volc", "rst:",
"panic", "Rebooting", "assert failed", "Guru Meditation", "conv_ai_service", "ERR|", "volc_conv.c",
"Backtrace", "PC :", "EXCVADDR", "A0 :", "Core 1 register")
try:
print("Starting explicit USB test conversation", flush=True)
port.write(b"diag-say\n")
started = time.monotonic()
stopped = False
diagnosed = False
while time.monotonic() - started < args.seconds:
if not diagnosed and time.monotonic() - started >= 10:
port.write(b"diag-state\n")
diagnosed = True
if not stopped and time.monotonic() - started >= args.seconds - 15:
port.write(b"diag-stop\n")
stopped = True
print("Requested hangup", flush=True)
line = port.readline().decode(errors="replace").strip()
if line and any(m in line for m in markers):
print(line, flush=True)
finally:
if not stopped:
port.write(b"diag-stop\n")
port.close()