Commit c0c9a4b1530ecac17a5dea542f18560233d3efb6
1 parent
51707558
Exists in
master
Migrated serial port selection to gui dialogue
Showing
1 changed file
with
6 additions
and
13 deletions
Show diff stats
robots/little_john/telemetry/code/monitor/serialselect.py
... | ... | @@ -6,6 +6,7 @@ def selectserial(): |
6 | 6 | import platform |
7 | 7 | import serial |
8 | 8 | import os |
9 | + import easygui | |
9 | 10 | |
10 | 11 | devpatterns = ['ttyACM', 'ttyUSB', 'rfcomm'] |
11 | 12 | targetdevs = [] |
... | ... | @@ -34,21 +35,13 @@ def selectserial(): |
34 | 35 | print("Found multiple serial devices: ") |
35 | 36 | for i, dev in enumerate(targetdevs): |
36 | 37 | print(" " + str(i) + ": " + dev) |
37 | - while True: | |
38 | - try: | |
39 | - selection = int(input("Please enter your selection (as a digit):\n > ")) | |
40 | - if selection >= 0 and selection < len(targetdevs): | |
41 | - break | |
42 | - except KeyboardInterrupt: | |
43 | - sys.exit() | |
44 | - except: | |
45 | - print("Choice unrecognised: please try again:") | |
38 | + message = "Please choose a serial port to recieve data through:" | |
39 | + title = "Found multiple serial ports!" | |
40 | + serialport = easygui.choicebox(message, title, targetdevs) | |
46 | 41 | else: |
47 | 42 | print("Only found one likely serial device: " + targetdevs[0]) |
48 | - selection = 0 | |
49 | - | |
50 | - serialport=targetdevs[selection] | |
51 | - | |
43 | + serialport = targetdevs[0] | |
44 | + | |
52 | 45 | |
53 | 46 | try: |
54 | 47 | datafeed = serial.Serial( | ... | ... |