Tools/HIL: console print timestamps

This commit is contained in:
Daniel Agar
2021-07-17 10:57:09 -04:00
parent 847b3b5b64
commit 209fde9ff3
3 changed files with 15 additions and 9 deletions
+4 -2
View File
@@ -6,6 +6,7 @@ from subprocess import call, Popen
from argparse import ArgumentParser
import re
import sys
import datetime
COLOR_RED = "\x1b[31m"
COLOR_GREEN = "\x1b[32m"
@@ -29,7 +30,8 @@ def print_line(line):
if "FAILED" in line:
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
print(line, end='')
current_time = datetime.datetime.now()
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
def do_nsh_cmd(port, baudrate, cmd):
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.1, xonxoff=True, rtscts=False, dsrdtr=False)
@@ -59,7 +61,7 @@ def do_nsh_cmd(port, baudrate, cmd):
# run command
timeout_start = time.time()
timeout = 10 # 10 seconds
timeout = 2 # 2 seconds
success_cmd = "cmd succeeded!"