From 1b631a288ae2c654e94600ff0568c0a247591e40 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 3 Sep 2026 19:31:56 +0200 Subject: [PATCH] text output --- tools/pm3_edit_trace.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) mode change 100644 => 100755 tools/pm3_edit_trace.py diff --git a/tools/pm3_edit_trace.py b/tools/pm3_edit_trace.py old mode 100644 new mode 100755 index 7d5c53495..299aedeaf --- a/tools/pm3_edit_trace.py +++ b/tools/pm3_edit_trace.py @@ -150,14 +150,20 @@ def serialise_trace(frames: list[Frame]) -> bytes: HEADER = ( f"{'#':>5} {'Timestamp':>10} {'Dur':>6} {'Src':>3} " - f"{'Data (hex)':<50} {'Par':>3}" + f"{'Data (hex)':<50}" ) SEP = '-' * len(HEADER) +# reader lines in yellow, when stdout is a terminal +YELLOW = '\033[33m' if sys.stdout.isatty() else '' +RESET = '\033[0m' if sys.stdout.isatty() else '' + def print_frame(idx: int, f: Frame) -> None: - print(f'{idx:>5} {f.timestamp:>10} {f.duration:>6} {f.src:>3} ' - f'{f.data_hex():<50} {f.parity_status:>3}') + colour = '' if f.is_response else YELLOW + reset = '' if f.is_response else RESET + print(f'{colour}{idx:>5} {f.timestamp:>10} {f.duration:>6} {f.src:>3} ' + f'{f.data_hex():<50}{reset}') def cmd_list(frames: list[Frame], args: list[str]) -> None: