diff --git a/__pycache__/device_commands.cpython-312.pyc b/__pycache__/device_commands.cpython-312.pyc index 0bf43c8..160d46c 100644 Binary files a/__pycache__/device_commands.cpython-312.pyc and b/__pycache__/device_commands.cpython-312.pyc differ diff --git a/__pycache__/device_interaction.cpython-312.pyc b/__pycache__/device_interaction.cpython-312.pyc index 96e7ec4..f77ecac 100644 Binary files a/__pycache__/device_interaction.cpython-312.pyc and b/__pycache__/device_interaction.cpython-312.pyc differ diff --git a/device_interaction.py b/device_interaction.py index dc013b4..92084c6 100644 --- a/device_interaction.py +++ b/device_interaction.py @@ -15,8 +15,26 @@ WAIT_AFTER_SEND = 0.15 # Wait after sending command, before requesting input (in def create_port_connection(): prt = None - for port, _, _ in sorted(cmd.list_ports.comports()): + print() + ports = [] + for port, _,_ in sorted(cmd.list_ports.comports()): + ports.append(port) + +#ONLY FOR LINUX!!! + have_ttyUSB = False + USB_ports = [] + for port in ports: + if "USB" in port: + USB_ports.append(port) + if len(USB_ports): + ports = USB_ports +# print("ports:", ports) + + +# for port, _, _ in sorted(cmd.list_ports.comports()): + for port in ports: try: + print("PORT:", port) prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1) cmd.open_port(prt) reset_port_settings(prt) @@ -107,4 +125,4 @@ def print_data(data): "V 5V2: "+shorten(data['MON_5V2'])+"V 7V0: "+shorten(data['MON_7V0'])+"V.") def close_connection(prt): - cmd.close_port(prt) \ No newline at end of file + cmd.close_port(prt)