mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 16:13:34 +08:00
Tools/HIL: only print timestamp if newline in output
This commit is contained in:
@@ -30,8 +30,11 @@ def print_line(line):
|
|||||||
if "FAILED" in line:
|
if "FAILED" in line:
|
||||||
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
|
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
|
||||||
|
|
||||||
current_time = datetime.datetime.now()
|
if "\n" in line:
|
||||||
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
|
current_time = datetime.datetime.now()
|
||||||
|
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
|
||||||
|
else:
|
||||||
|
print('{0}'.format(line), end='')
|
||||||
|
|
||||||
def monitor_firmware_upload(port, baudrate):
|
def monitor_firmware_upload(port, baudrate):
|
||||||
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1, xonxoff=True, rtscts=False, dsrdtr=False)
|
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1, xonxoff=True, rtscts=False, dsrdtr=False)
|
||||||
|
|||||||
@@ -30,8 +30,12 @@ def print_line(line):
|
|||||||
if "FAILED" in line:
|
if "FAILED" in line:
|
||||||
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
|
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
|
||||||
|
|
||||||
current_time = datetime.datetime.now()
|
if "\n" in line:
|
||||||
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
|
current_time = datetime.datetime.now()
|
||||||
|
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
|
||||||
|
else:
|
||||||
|
print('{0}'.format(line), end='')
|
||||||
|
|
||||||
|
|
||||||
def do_nsh_cmd(port, baudrate, cmd):
|
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.2, xonxoff=True, rtscts=False, dsrdtr=False)
|
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.2, xonxoff=True, rtscts=False, dsrdtr=False)
|
||||||
|
|||||||
@@ -32,8 +32,11 @@ def print_line(line):
|
|||||||
if "FAILED" in line:
|
if "FAILED" in line:
|
||||||
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
|
line = line.replace("FAILED", f"{COLOR_RED}FAILED{COLOR_RESET}", 1)
|
||||||
|
|
||||||
current_time = datetime.datetime.now()
|
if "\n" in line:
|
||||||
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
|
current_time = datetime.datetime.now()
|
||||||
|
print('[{0}] {1}'.format(current_time.isoformat(timespec='milliseconds'), line), end='')
|
||||||
|
else:
|
||||||
|
print('{0}'.format(line), end='')
|
||||||
|
|
||||||
def do_test(port, baudrate, test_name):
|
def do_test(port, baudrate, test_name):
|
||||||
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.2, xonxoff=True, rtscts=False, dsrdtr=False)
|
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.2, xonxoff=True, rtscts=False, dsrdtr=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user