Compare View
Commits (4)
Showing
2 changed files
Show diff stats
robots/little_john/telemetry/code/monitor/graph_plotter_rewrite.py
... | ... | @@ -14,14 +14,19 @@ import numpy |
14 | 14 | import os |
15 | 15 | import platform |
16 | 16 | import sys |
17 | +import easygui | |
17 | 18 | from serialselect import selectserial |
18 | 19 | |
19 | 20 | from colours import * |
20 | 21 | |
21 | 22 | datafeed = selectserial() |
22 | 23 | |
23 | -if datafeed == None: | |
24 | - print("Exiting...") | |
24 | + | |
25 | +if type(datafeed) is str: | |
26 | + easygui.msgbox("Failed to open serial port:\n" + datafeed, "Fatal error") | |
27 | + sys.exit() | |
28 | +elif datafeed == None: | |
29 | + easygui.msgbox("Failed to open serial port for unknown reason!", "Fatal error") | |
25 | 30 | sys.exit() |
26 | 31 | |
27 | 32 | if platform.system()=='Windows': #easier than passing vars | ... | ... |
robots/little_john/telemetry/code/monitor/serialselect.py
... | ... | @@ -29,9 +29,7 @@ def selectserial(): |
29 | 29 | os='Other' #may be useful |
30 | 30 | |
31 | 31 | if len(targetdevs) == 0: |
32 | - print("Sorry, no serial devices found.") | |
33 | - print("Exiting...") | |
34 | - return None | |
32 | + return "Sorry, no serial devices found." | |
35 | 33 | elif len(targetdevs) > 1: |
36 | 34 | print("Found multiple serial devices: ") |
37 | 35 | for i, dev in enumerate(targetdevs): |
... | ... | @@ -46,10 +44,7 @@ def selectserial(): |
46 | 44 | except: |
47 | 45 | print("Choice unrecognised: please try again:") |
48 | 46 | else: |
49 | - if os=='Windows': | |
50 | - print("Only found one likely serial device: " + targetdevs[0]) | |
51 | - else: | |
52 | - print("Only found one likely serial device: " + targetdevs[0]) | |
47 | + print("Only found one likely serial device: " + targetdevs[0]) | |
53 | 48 | selection = 0 |
54 | 49 | |
55 | 50 | serialport=targetdevs[selection] |
... | ... | @@ -68,6 +63,4 @@ def selectserial(): |
68 | 63 | print("Sucessfully opened " + serialport + " as data source!") |
69 | 64 | return datafeed |
70 | 65 | except Exception as e: |
71 | - print("Failed to access " + serialport + " because:") | |
72 | - print(e) | |
73 | - return None | |
66 | + return str(e) | ... | ... |