diff --git a/utils/pod_bridge/listen_pod.py b/utils/pod_bridge/listen_pod.py index f8332bf..70d9773 100644 --- a/utils/pod_bridge/listen_pod.py +++ b/utils/pod_bridge/listen_pod.py @@ -45,8 +45,15 @@ def main() -> int: t0 = time.monotonic() n_tele, n_tgt, n_other = 0, 0, 0 + link_error = None while time.monotonic() - t0 < args.seconds: - for frame in pod.poll(): + try: + frames = pod.poll() + except OSError as exc: + # Pi 板载 UART 典型故障(errno 5 EIO):控制台抢占 / mini-UART 不稳 + link_error = exc + break + for frame in frames: if isinstance(frame, Telemetry): n_tele += 1 if n_tele == 1: @@ -65,7 +72,19 @@ def main() -> int: else: n_other += 1 time.sleep(0.005) - pod.close() + try: + pod.close() + except OSError: + pass + + if link_error is not None: + print(f"[listen] 链路中途断开: {link_error}") + print("[listen] 排查: ① 串口控制台是否仍占用 " + "(systemctl disable --now serial-getty@ttyS0/ttyAMA0) → 重启; " + "② /dev/serial0 是否指向 mini-UART(ttyS0 不稳定) → 加 " + "dtoverlay=disable-bt 换到 PL011(ttyAMA0),或改用 USB 转串口(" + "/dev/ttyUSB0,推荐)") + return 1 expected = _TELEMETRY_NOMINAL_HZ * args.seconds rate = n_tele / args.seconds if args.seconds > 0 else 0.0