8000 tools/hci_trace_to_pcap.py: Support colour input. · micropython/micropython@1591446 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1591446

Browse files
committed
tools/hci_trace_to_pcap.py: Support colour input.
Filter out escape sequences to set the color. Also allow the "TX:" and "RX:" used in some places. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent 3c87c74 commit 1591446

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/hci_trace_to_pcap.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,15 @@
6565

6666
with open(sys.argv[1], "r") as f:
6767
for line in f:
68-
line = line.strip()
69-
m = re.match("([<>]) \\[ *([0-9]+)\\] ([A-Fa-f0-9:]+)", line)
68+
# Remove color formatting.
69+
line = line.strip().encode()
70+
if line[0] == ord("\x1b"):
71+
line = line[7:]
72+
if len(line) >= 4 and line[-4] == ord("\x1b"):
73+
line = line[:-4]
74+
line = line.decode()
75+
76+
m = re.match("([<>]) \\[ *([0-9]+)\\] (?:[TR]X: )?([A-Fa-f0-9:]+)", line)
7077
if not m:
7178
continue
7279

0 commit comments

Comments
 (0)
0