Skip to content

Commit 2bba26f

Browse files
committed
flashgordon: try to fix error in detectport
1 parent cadb1ce commit 2bba26f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Station/FlashBoard/flashgordon.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,24 +416,26 @@ def inplace_change(filename, old_string, new_string):
416416

417417

418418
def detectport(self): # Detect Board Port
419-
boardlist = self.arduino.board.list()
420419
self.Port = None
421420

421+
boardlist = self.arduino.board.list()
422+
boards = boardlist['result']
423+
422424
if sys.platform == 'linux':
423-
for i in range(len(boardlist['result'])):
424-
p = boardlist['result'][i]['port']['address']
425+
for board in boards:
426+
p = board['port']['address']
425427
if p.find("tty") != -1:
426428
self.Port = p
427429

428-
if sys.platform == 'win32':
429-
for i in range(len(boardlist['result'])):
430-
p = boardlist['result'][i]['port']['address']
430+
elif sys.platform == 'win32':
431+
for board in boards:
432+
p = board['port']['address']
431433
if p.find("COM") != -1:
432434
self.Port = p
433435

434-
if sys.platform == 'darwin':
435-
for i in range(len(boardlist['result'])):
436-
p = boardlist['result'][i]['port']['address']
436+
elif sys.platform == 'darwin':
437+
for board in boards:
438+
p = board['port']['address']
437439
if p.find("usbserial") != -1:
438440
self.Port = p
439441

0 commit comments

Comments
 (0)