Commit ef651028c16f4eed2317fc8703f261c3ac56d5e1
1 parent
af437b8f
Exists in
master
Moved serialselect away from using direct print statements
Showing
1 changed file
with
5 additions
and
4 deletions
Show diff stats
robots/little_john/telemetry/code/monitor/serialselect.py
| ... | ... | @@ -7,6 +7,7 @@ def selectserial(): |
| 7 | 7 | import serial |
| 8 | 8 | import os |
| 9 | 9 | import easygui |
| 10 | + import logging | |
| 10 | 11 | |
| 11 | 12 | devpatterns = ['ttyACM', 'ttyUSB', 'rfcomm'] |
| 12 | 13 | targetdevs = [] |
| ... | ... | @@ -32,16 +33,16 @@ def selectserial(): |
| 32 | 33 | if len(targetdevs) == 0: |
| 33 | 34 | return "Sorry, no serial devices found." |
| 34 | 35 | elif len(targetdevs) > 1: |
| 35 | - print("Found multiple serial devices: ") | |
| 36 | + logging.info("Found multiple serial devices: ") | |
| 36 | 37 | for i, dev in enumerate(targetdevs): |
| 37 | - print(" " + str(i) + ": " + dev) | |
| 38 | + logging.info(" " + str(i) + ": " + dev) | |
| 38 | 39 | message = "Please choose a serial port to recieve data through:" |
| 39 | 40 | title = "Found multiple serial ports!" |
| 40 | 41 | serialport = easygui.choicebox(message, title, targetdevs) |
| 41 | 42 | if serialport == None: |
| 42 | 43 | return "User cancelled selection dialogue" |
| 43 | 44 | else: |
| 44 | - print("Only found one likely serial device: " + targetdevs[0]) | |
| 45 | + logging.info("Only found one likely serial device: " + targetdevs[0]) | |
| 45 | 46 | serialport = targetdevs[0] |
| 46 | 47 | |
| 47 | 48 | |
| ... | ... | @@ -55,7 +56,7 @@ def selectserial(): |
| 55 | 56 | timeout=1 |
| 56 | 57 | ) |
| 57 | 58 | |
| 58 | - print("Sucessfully opened " + serialport + " as data source!") | |
| 59 | + logging.info("Sucessfully opened " + serialport + " as data source!") | |
| 59 | 60 | return datafeed |
| 60 | 61 | except Exception as e: |
| 61 | 62 | return str(e) | ... | ... |