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>
This commit is contained in:
committed by
GitHub
parent
e6e2217b76
commit
8901894b6c
@@ -94,9 +94,12 @@ def list_ports():
|
|||||||
"""Print available serial ports."""
|
"""Print available serial ports."""
|
||||||
ports = serial.tools.list_ports.comports()
|
ports = serial.tools.list_ports.comports()
|
||||||
if not ports:
|
if not ports:
|
||||||
|
print("No serial ports found.")
|
||||||
return
|
return
|
||||||
for _p in sorted(ports, key=lambda x: x.device):
|
print(f"{'Port':<30} {'Description':<40} {'HWID'}")
|
||||||
pass
|
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():
|
def auto_detect_port():
|
||||||
@@ -224,7 +227,7 @@ class CaptureStats:
|
|||||||
# Main capture loop
|
# 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."""
|
"""Open serial port and capture DIAG output."""
|
||||||
stats = CaptureStats()
|
stats = CaptureStats()
|
||||||
running = True
|
running = True
|
||||||
@@ -248,12 +251,14 @@ def capture(port, baud, log_file, filter_subsys, errors_only, _use_color):
|
|||||||
except serial.SerialException:
|
except serial.SerialException:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
print(f"Connected to {port} at {baud} baud")
|
||||||
if log_file:
|
if log_file:
|
||||||
pass
|
print(f"Logging to {log_file}")
|
||||||
if filter_subsys:
|
if filter_subsys:
|
||||||
pass
|
print(f"Filter: {', '.join(sorted(filter_subsys))}")
|
||||||
if errors_only:
|
if errors_only:
|
||||||
pass
|
print("Mode: errors/warnings only")
|
||||||
|
print("Press Ctrl-C to stop.\n")
|
||||||
|
|
||||||
if log_file:
|
if log_file:
|
||||||
os.makedirs(os.path.dirname(log_file), exist_ok=True)
|
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
|
# Terminal display respects filters
|
||||||
if should_display(line, filter_subsys, errors_only):
|
if should_display(line, filter_subsys, errors_only):
|
||||||
pass
|
sys.stdout.write(colorize(line, use_color) + "\n")
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
if flog:
|
if flog:
|
||||||
flog.write(f"\n{stats.summary()}\n")
|
flog.write(f"\n{stats.summary()}\n")
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
ser.close()
|
ser.close()
|
||||||
|
print(stats.summary())
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -49,3 +49,5 @@ select = [
|
|||||||
"**/test_*.py" = ["ARG", "T20", "ERA"]
|
"**/test_*.py" = ["ARG", "T20", "ERA"]
|
||||||
# Re-export modules: unused imports are intentional
|
# Re-export modules: unused imports are intentional
|
||||||
"**/v7/hardware.py" = ["F401"]
|
"**/v7/hardware.py" = ["F401"]
|
||||||
|
# CLI tool: print() is the intentional output mechanism
|
||||||
|
"**/uart_capture.py" = ["T20"]
|
||||||
|
|||||||
Reference in New Issue
Block a user