Response from RCP

This commit is contained in:
Aiden
2026-05-13 13:10:25 +10:00
parent f99a60710e
commit f406bc12a2
21 changed files with 2073 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Summarize fixed-size hex frames from serial_sniff.py logs."""
"""Summarize fixed-size hex frames from serial helper logs."""
from __future__ import annotations
@@ -9,7 +9,11 @@ import re
from pathlib import Path
FRAME_RE = re.compile(r"\b(?:(RX|TX)\s+)?frame\s+\d+\s+((?:[0-9A-Fa-f]{2}\s*)+)$")
FRAME_RE = re.compile(
r"\b(?P<direction>RX|TX)(?:\s+cmd\s+0x[0-9A-Fa-f]{2})?"
r"(?:\s+fields\b.*?)?\s+"
r"frame\s+\d+\s+(?P<frame>(?:[0-9A-Fa-f]{2}\s*)+)(?:\s+\S.*)?$"
)
def frames_from_log(path: Path) -> list[tuple[str, str]]:
@@ -17,8 +21,8 @@ def frames_from_log(path: Path) -> list[tuple[str, str]]:
for line in path.read_text(encoding="utf-8").splitlines():
match = FRAME_RE.search(line.strip())
if match:
direction = match.group(1) or "RX"
frame = " ".join(match.group(2).upper().split())
direction = match.group("direction")
frame = " ".join(match.group("frame").upper().split())
frames.append((direction, frame))
return frames