From c0c9a4b1530ecac17a5dea542f18560233d3efb6 Mon Sep 17 00:00:00 2001 From: Christopher Stone Date: Thu, 8 Mar 2018 18:36:29 +0000 Subject: [PATCH] Migrated serial port selection to gui dialogue --- robots/little_john/telemetry/code/monitor/serialselect.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/robots/little_john/telemetry/code/monitor/serialselect.py b/robots/little_john/telemetry/code/monitor/serialselect.py index ccc18ca..0825de4 100644 --- a/robots/little_john/telemetry/code/monitor/serialselect.py +++ b/robots/little_john/telemetry/code/monitor/serialselect.py @@ -6,6 +6,7 @@ def selectserial(): import platform import serial import os + import easygui devpatterns = ['ttyACM', 'ttyUSB', 'rfcomm'] targetdevs = [] @@ -34,21 +35,13 @@ def selectserial(): print("Found multiple serial devices: ") for i, dev in enumerate(targetdevs): print(" " + str(i) + ": " + dev) - while True: - try: - selection = int(input("Please enter your selection (as a digit):\n > ")) - if selection >= 0 and selection < len(targetdevs): - break - except KeyboardInterrupt: - sys.exit() - except: - print("Choice unrecognised: please try again:") + message = "Please choose a serial port to recieve data through:" + title = "Found multiple serial ports!" + serialport = easygui.choicebox(message, title, targetdevs) else: print("Only found one likely serial device: " + targetdevs[0]) - selection = 0 - - serialport=targetdevs[selection] - + serialport = targetdevs[0] + try: datafeed = serial.Serial( -- libgit2 0.21.2