Tools/HIL: disable XON/XOFF, consistent timeouts, proper input buffer clear

This commit is contained in:
Daniel Agar 2021-12-31 18:55:59 -05:00
parent 03371f8522
commit 247b975675
5 changed files with 12 additions and 15 deletions

View File

@ -37,7 +37,7 @@ def print_line(line):
print('{0}'.format(line), end='')
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=False, rtscts=False, dsrdtr=False)
timeout = 180 # 3 minutes
timeout_start = time.monotonic()

View File

@ -32,7 +32,7 @@ def print_line(line):
print(line, end='')
def do_param_set_cmd(port, baudrate, param_name, param_value):
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)
ser = serial.Serial(port, baudrate, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=1, xonxoff=False, rtscts=False, dsrdtr=False)
timeout_start = time.monotonic()
timeout = 30 # 30 seconds
@ -55,7 +55,7 @@ def do_param_set_cmd(port, baudrate, param_name, param_value):
sys.exit(1)
# clear
ser.readlines()
ser.reset_input_buffer()
# run command
timeout_start = time.monotonic()

View File

@ -37,14 +37,14 @@ def print_line(line):
print('{0}'.format(line), end='')
def reboot(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=False, rtscts=False, dsrdtr=False)
# clear
ser.readlines()
ser.reset_input_buffer()
time_start = time.monotonic()
ser.write("\nreboot\n".encode("ascii"))
ser.flush()
ser.write("\n".encode("ascii"))
ser.write("reboot\n".encode("ascii"))
time_reboot_cmd = time_start
timeout_reboot_cmd = 90
@ -57,8 +57,7 @@ def reboot(port, baudrate):
time_reboot_cmd = time.monotonic()
print("sending reboot cmd again")
ser.write("reboot\n".encode("ascii"))
ser.flush()
time.sleep(0.2)
time.sleep(0.5)
serial_line = ser.readline().decode("ascii", errors='ignore')

View File

@ -38,7 +38,7 @@ def print_line(line):
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=1, xonxoff=False, rtscts=False, dsrdtr=False)
timeout_start = time.monotonic()
timeout = 30 # 30 seconds
@ -46,7 +46,6 @@ def do_nsh_cmd(port, baudrate, cmd):
# wait for nsh prompt
while True:
ser.write("\n".encode("ascii"))
ser.flush()
serial_line = ser.readline().decode("ascii", errors='ignore')
@ -61,7 +60,7 @@ def do_nsh_cmd(port, baudrate, cmd):
sys.exit(1)
# clear
ser.readlines()
ser.reset_input_buffer()
# run command
timeout_start = time.monotonic()

View File

@ -39,7 +39,7 @@ def print_line(line):
print('{0}'.format(line), end='')
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=1, xonxoff=False, rtscts=False, dsrdtr=False)
timeout_start = time.monotonic()
timeout = 30 # 30 seconds
@ -47,7 +47,6 @@ def do_test(port, baudrate, test_name):
# wait for nsh prompt
while True:
ser.write("\n".encode("ascii"))
ser.flush()
serial_line = ser.readline().decode("ascii", errors='ignore')
@ -62,7 +61,7 @@ def do_test(port, baudrate, test_name):
return False
# clear
ser.readlines()
ser.reset_input_buffer()
success = False