make the code slightly less terrible
This commit is contained in:
parent
36f999b402
commit
431f665cf2
1 changed files with 6 additions and 6 deletions
|
@ -2,6 +2,7 @@ import GPUtil
|
||||||
import time
|
import time
|
||||||
from pySerialTransfer import pySerialTransfer as txfer
|
from pySerialTransfer import pySerialTransfer as txfer
|
||||||
from subprocess import getoutput
|
from subprocess import getoutput
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# ---
|
# ---
|
||||||
|
@ -13,13 +14,12 @@ try:
|
||||||
|
|
||||||
port = 'ttyACM'
|
port = 'ttyACM'
|
||||||
while True:
|
while True:
|
||||||
ports = getoutput(f'ls /dev | grep {port}').split('\n')
|
try:
|
||||||
if ports != ['']:
|
port = glob(f'ls /dev/{port}*')[-]
|
||||||
ports.sort()
|
|
||||||
port = ports[len(ports) - 1]
|
|
||||||
break
|
break
|
||||||
print('Waiting for Arduino...')
|
except IndexError:
|
||||||
time.sleep(3)
|
print('Waiting for Arduino...')
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
link = txfer.SerialTransfer(port, 115200, timeout=.1)
|
link = txfer.SerialTransfer(port, 115200, timeout=.1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue