diff --git a/Python/tx_loop.py b/Python/tx_loop.py index 1cd5931..7c8cf61 100644 --- a/Python/tx_loop.py +++ b/Python/tx_loop.py @@ -2,6 +2,7 @@ import GPUtil import time from pySerialTransfer import pySerialTransfer as txfer from subprocess import getoutput +from glob import glob try: # --- @@ -13,13 +14,12 @@ try: port = 'ttyACM' while True: - ports = getoutput(f'ls /dev | grep {port}').split('\n') - if ports != ['']: - ports.sort() - port = ports[len(ports) - 1] + try: + port = glob(f'ls /dev/{port}*')[-] break - print('Waiting for Arduino...') - time.sleep(3) + except IndexError: + print('Waiting for Arduino...') + time.sleep(3) link = txfer.SerialTransfer(port, 115200, timeout=.1)