fixed port issues on Linux systems. Now ttySx are ignored

This commit is contained in:
2025-10-22 17:43:00 +03:00
parent f921bec1c3
commit 8b0c99ab96
3 changed files with 20 additions and 2 deletions

View File

@ -15,8 +15,26 @@ WAIT_AFTER_SEND = 0.15 # Wait after sending command, before requesting input (in
def create_port_connection(): def create_port_connection():
prt = None prt = None
print()
ports = []
for port, _,_ in sorted(cmd.list_ports.comports()): 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: try:
print("PORT:", port)
prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1) prt = cmd.setup_port_connection(port=port, baudrate=115200, timeout_sec=1)
cmd.open_port(prt) cmd.open_port(prt)
reset_port_settings(prt) reset_port_settings(prt)