From d9e1b29504df75ed7bbc0f0a6e6853b90c60eb31 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 10 Sep 2024 13:53:59 +0100 Subject: [PATCH] ci/bare-metal: Truncate printed times and prefixes The date isn't interesting, since you can tell if it wraps around anyway. Just print the time down to the millisecond, which should be plenty enough. We also don't need to print 'R SERIAL_CPU> ' when almost every line is reading from the CPU serial buffer, so make that the default. Signed-off-by: Daniel Stone Part-of: --- .gitlab-ci/bare-metal/cros_servo_run.py | 8 ++++---- .gitlab-ci/bare-metal/poe_run.py | 2 +- .gitlab-ci/bare-metal/serial_buffer.py | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci/bare-metal/cros_servo_run.py b/.gitlab-ci/bare-metal/cros_servo_run.py index dd251c2dbce..95fed60c473 100755 --- a/.gitlab-ci/bare-metal/cros_servo_run.py +++ b/.gitlab-ci/bare-metal/cros_servo_run.py @@ -22,11 +22,11 @@ SECTION_END="end" class CrosServoRun: def __init__(self, cpu, ec, test_timeout, logger): self.cpu_ser = SerialBuffer( - cpu, "results/serial.txt", "R SERIAL-CPU> ") + cpu, "results/serial.txt", ": ") # Merge the EC serial into the cpu_ser's line stream so that we can # effectively poll on both at the same time and not have to worry about self.ec_ser = SerialBuffer( - ec, "results/serial-ec.txt", "R SERIAL-EC> ", line_queue=self.cpu_ser.line_queue) + ec, "results/serial-ec.txt", " EC: ", line_queue=self.cpu_ser.line_queue) self.test_timeout = test_timeout self.logger = logger @@ -35,11 +35,11 @@ class CrosServoRun: self.cpu_ser.close() def ec_write(self, s): - print("W SERIAL-EC> %s" % s) + print("EC> %s" % s) self.ec_ser.serial.write(s.encode()) def cpu_write(self, s): - print("W SERIAL-CPU> %s" % s) + print("> %s" % s) self.cpu_ser.serial.write(s.encode()) def print_error(self, message): diff --git a/.gitlab-ci/bare-metal/poe_run.py b/.gitlab-ci/bare-metal/poe_run.py index 1a617e18aa3..c987c39d965 100755 --- a/.gitlab-ci/bare-metal/poe_run.py +++ b/.gitlab-ci/bare-metal/poe_run.py @@ -35,7 +35,7 @@ class PoERun: self.powerup = args.powerup self.powerdown = args.powerdown self.ser = SerialBuffer( - args.dev, "results/serial-output.txt", "") + args.dev, "results/serial-output.txt", ": ") self.boot_timeout = boot_timeout self.test_timeout = test_timeout self.logger = logger diff --git a/.gitlab-ci/bare-metal/serial_buffer.py b/.gitlab-ci/bare-metal/serial_buffer.py index b21ce6e6ef1..f57060e1865 100755 --- a/.gitlab-ci/bare-metal/serial_buffer.py +++ b/.gitlab-ci/bare-metal/serial_buffer.py @@ -22,7 +22,7 @@ # IN THE SOFTWARE. import argparse -from datetime import datetime, timezone +from datetime import datetime, UTC import queue import serial import threading @@ -130,9 +130,10 @@ class SerialBuffer: if b == b'\n'[0]: line = line.decode(errors="replace") - time = datetime.now().strftime('%y-%m-%d %H:%M:%S') - print("{endc}{time} {prefix}{line}".format( - time=time, prefix=self.prefix, line=line, endc='\033[0m'), flush=True, end='') + ts = datetime.now(tz=UTC) + ts_str = f"{ts.hour:02}:{ts.minute:02}:{ts.second:02}.{int(ts.microsecond / 1000):03}" + print("{endc}{time}{prefix}{line}".format( + time=ts_str, prefix=self.prefix, line=line, endc='\033[0m'), flush=True, end='') self.line_queue.put(line) line = bytearray()