From 11131e26c5c01c7239ab1b6c0e9bd8da58be33f2 Mon Sep 17 00:00:00 2001 From: keita <16924591+keita_sakura@user.noreply.gitee.com> Date: Thu, 24 Sep 2026 15:42:04 +0800 Subject: [PATCH] =?UTF-8?q?listen=5Fpod.py=20=E4=B8=B2=E5=8F=A3EIO?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E4=B8=8D=E5=86=8D=E5=B4=A9=E6=A0=88=E5=B9=B6?= =?UTF-8?q?=E7=BB=99=E5=87=BA=E6=8E=92=E6=9F=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pi板载UART典型故障(errno 5): 捕获后打印串口控制台占用/mini-UART不稳的 排查指引与改用USB转串口建议, 退出码1; 打桩复现验证通过 --- utils/pod_bridge/listen_pod.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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