diff --git a/hardware-testing/hardware_testing/drivers/__init__.py b/hardware-testing/hardware_testing/drivers/__init__.py index fde7e228d9b..f1b4c991e2c 100644 --- a/hardware-testing/hardware_testing/drivers/__init__.py +++ b/hardware-testing/hardware_testing/drivers/__init__.py @@ -15,28 +15,23 @@ def list_ports_and_select(device_name: str = "", port_substr: str = None) -> str idx_str = "" for i, p in enumerate(ports): print(f"\t{i + 1}) {p.device}") - if port_substr: - for i, p in enumerate(ports): - if port_substr in p.device: - idx = i + 1 - break - else: - idx_str = input( - f"\nenter number next to {device_name} port (or ENTER to re-scan): " - ) - if not idx_str: - return list_ports_and_select(device_name) - if not device_name: - device_name = "desired" - - try: + if port_substr: + for i, p in enumerate(ports): + if port_substr in p.device: + return p.device + + while True: + idx_str = input( + f"\nEnter number next to {device_name} port (or ENTER to re-scan): " + ) + if not idx_str: + return list_ports_and_select(device_name, port_substr) + try: idx = int(idx_str.strip()) - except TypeError: - pass - return ports[idx - 1].device - except (ValueError, IndexError): - return list_ports_and_select() + return ports[idx - 1].device + except (ValueError, IndexError): + print("Invalid selection. Please try again.") def find_port(vid: int, pid: int) -> str: diff --git a/hardware-testing/hardware_testing/scripts/abr_asair_sensor.py b/hardware-testing/hardware_testing/scripts/abr_asair_sensor.py index f2c00e015d3..1e8fca0358c 100644 --- a/hardware-testing/hardware_testing/scripts/abr_asair_sensor.py +++ b/hardware-testing/hardware_testing/scripts/abr_asair_sensor.py @@ -26,7 +26,7 @@ def __init__(self, robot: str, duration: int, frequency: int) -> None: test_name = "ABR-Environment-Monitoring" run_id = data.create_run_id() file_name = data.create_file_name(test_name, run_id, robot) - sensor = asair_sensor.BuildAsairSensor(False, False, "USB") + sensor = asair_sensor.BuildAsairSensor(False, False, "USB0") print(sensor) env_data = sensor.get_reading() header = [