Response from RCP
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user