From 8901894b6cea85edd8e540763b118f4819b1cfc2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 14:11:23 +0000 Subject: [PATCH] fix: restore uart_capture.py terminal output; add T20 per-file ignore for CLI tool Agent-Logs-Url: https://github.com/NawfalMotii79/PLFM_RADAR/sessions/671cf948-60b5-47c3-af69-7e1d26366728 Co-authored-by: JJassonn69 <83615043+JJassonn69@users.noreply.github.com> --- 9_Firmware/tools/uart_capture.py | 21 ++++++++++++++------- pyproject.toml | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/9_Firmware/tools/uart_capture.py b/9_Firmware/tools/uart_capture.py index e257b54..c03796b 100755 --- a/9_Firmware/tools/uart_capture.py +++ b/9_Firmware/tools/uart_capture.py @@ -94,9 +94,12 @@ def list_ports(): """Print available serial ports.""" ports = serial.tools.list_ports.comports() if not ports: + print("No serial ports found.") return - for _p in sorted(ports, key=lambda x: x.device): - pass + print(f"{'Port':<30} {'Description':<40} {'HWID'}") + print("-" * 100) + for p in sorted(ports, key=lambda x: x.device): + print(f"{p.device:<30} {p.description:<40} {p.hwid}") def auto_detect_port(): @@ -224,7 +227,7 @@ class CaptureStats: # Main capture loop # --------------------------------------------------------------------------- -def capture(port, baud, log_file, filter_subsys, errors_only, _use_color): +def capture(port, baud, log_file, filter_subsys, errors_only, use_color): """Open serial port and capture DIAG output.""" stats = CaptureStats() running = True @@ -248,12 +251,14 @@ def capture(port, baud, log_file, filter_subsys, errors_only, _use_color): except serial.SerialException: sys.exit(1) + print(f"Connected to {port} at {baud} baud") if log_file: - pass + print(f"Logging to {log_file}") if filter_subsys: - pass + print(f"Filter: {', '.join(sorted(filter_subsys))}") if errors_only: - pass + print("Mode: errors/warnings only") + print("Press Ctrl-C to stop.\n") if log_file: os.makedirs(os.path.dirname(log_file), exist_ok=True) @@ -300,13 +305,15 @@ def capture(port, baud, log_file, filter_subsys, errors_only, _use_color): # Terminal display respects filters if should_display(line, filter_subsys, errors_only): - pass + sys.stdout.write(colorize(line, use_color) + "\n") + sys.stdout.flush() if flog: flog.write(f"\n{stats.summary()}\n") finally: ser.close() + print(stats.summary()) # --------------------------------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index e71b2d9..9790436 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,3 +49,5 @@ select = [ "**/test_*.py" = ["ARG", "T20", "ERA"] # Re-export modules: unused imports are intentional "**/v7/hardware.py" = ["F401"] +# CLI tool: print() is the intentional output mechanism +"**/uart_capture.py" = ["T20"]