Browse Source

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

master
Daniel Agar 3 years ago
parent
commit
247b975675
  1. 2
      Tools/HIL/monitor_firmware_upload.py
  2. 4
      Tools/HIL/nsh_param_set.py
  3. 11
      Tools/HIL/reboot.py
  4. 5
      Tools/HIL/run_nsh_cmd.py
  5. 5
      Tools/HIL/run_tests.py

2
Tools/HIL/monitor_firmware_upload.py

@ -37,7 +37,7 @@ def print_line(line): @@ -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()

4
Tools/HIL/nsh_param_set.py

@ -32,7 +32,7 @@ def print_line(line): @@ -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): @@ -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()

11
Tools/HIL/reboot.py

@ -37,14 +37,14 @@ def print_line(line): @@ -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): @@ -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')

5
Tools/HIL/run_nsh_cmd.py

@ -38,7 +38,7 @@ def print_line(line): @@ -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): @@ -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): @@ -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()

5
Tools/HIL/run_tests.py

@ -39,7 +39,7 @@ def print_line(line): @@ -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): @@ -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): @@ -62,7 +61,7 @@ def do_test(port, baudrate, test_name):
return False
# clear
ser.readlines()
ser.reset_input_buffer()
success = False

Loading…
Cancel
Save