summaryrefslogtreecommitdiff
path: root/contrib/gpsData.py
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2018-06-20 14:32:13 -0700
committerGary E. Miller <gem@rellim.com>2018-06-20 14:32:13 -0700
commit1066f6bd9784c11e35fcaf529b199c55ad9f1c39 (patch)
tree350e8ae956b51c2d24628b5bf6f151fee729ac9a /contrib/gpsData.py
parent2a44a756e23f1c74dd40ec609d6175fe811f7bc4 (diff)
downloadgpsd-1066f6bd9784c11e35fcaf529b199c55ad9f1c39.tar.gz
gpsData.py: Fix for PEP8
Diffstat (limited to 'contrib/gpsData.py')
-rwxr-xr-xcontrib/gpsData.py96
1 files changed, 51 insertions, 45 deletions
diff --git a/contrib/gpsData.py b/contrib/gpsData.py
index a4769615..cb52c7aa 100755
--- a/contrib/gpsData.py
+++ b/contrib/gpsData.py
@@ -1,7 +1,7 @@
#! /usr/bin/python
# Written by Dan Mandle http://dan.mandle.me September 2012
# http://www.danmandle.com/blog/getting-gpsd-to-work-with-python/
-# License: GPL 2.0
+# License: GPL 2.0
# This code runs compatibly under Python 2 and 3.x for x >= 2.
# Preserve this property!
@@ -13,57 +13,63 @@ from time import *
import time
import threading
-gpsd = None #seting the global variable
+gpsd = None # setting the global variable
+
+os.system('clear') # clear the terminal (optional)
-os.system('clear') #clear the terminal (optional)
class GpsPoller(threading.Thread):
- def __init__(self):
- threading.Thread.__init__(self)
- global gpsd #bring it in scope
- gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
- self.current_value = None
- self.running = True #setting the thread running to true
+ def __init__(self):
+ threading.Thread.__init__(self)
+ global gpsd # bring it in scope
+ gpsd = gps(mode=WATCH_ENABLE) # starting the stream of info
+ self.current_value = None
+ self.running = True # setting the thread running to true
- def run(self):
- global gpsd
- while gpsp.running:
- next(gpsd) #this will continue to loop and grab EACH set of gpsd info to clear the buffer
+ def run(self):
+ global gpsd
+ while gpsp.running:
+ # this will continue to loop and grab EACH set of
+ # gpsd info to clear the buffer
+ next(gpsd)
if __name__ == '__main__':
- gpsp = GpsPoller() # create the thread
- try:
- gpsp.start() # start it up
- while True:
- #It may take a second or two to get good data
- #print gpsd.fix.latitude,', ',gpsd.fix.longitude,' Time: ',gpsd.utc
+ gpsp = GpsPoller() # create the thread
+ try:
+ gpsp.start() # start it up
+ while True:
+ # It may take a second or two to get good data
+ # print(gpsd.fix.latitude,', ',gpsd.fix.longitude,'
+ # Time: ',gpsd.utc
+
+ os.system('clear')
- os.system('clear')
+ print()
+ print(' GPS reading')
+ print('----------------------------------------')
+ print('latitude ', gpsd.fix.latitude)
+ print('longitude ', gpsd.fix.longitude)
+ print('time utc ', gpsd.utc, ' + ', gpsd.fix.time)
+ print('altitude (m)', gpsd.fix.altitude)
+ print('eps ', gpsd.fix.eps)
+ print('epx ', gpsd.fix.epx)
+ print('epv ', gpsd.fix.epv)
+ print('ept ', gpsd.fix.ept)
+ print('speed (m/s) ', gpsd.fix.speed)
+ print('climb ', gpsd.fix.climb)
+ print('track ', gpsd.fix.track)
+ print('mode ', gpsd.fix.mode)
+ print()
+ print("%s satellites in view:" % len(gpsd.satellites))
+ for sat in gpsd.satellites:
+ print(" %r" % sat)
- print()
- print(' GPS reading')
- print('----------------------------------------')
- print('latitude ' , gpsd.fix.latitude)
- print('longitude ' , gpsd.fix.longitude)
- print('time utc ' , gpsd.utc,' + ', gpsd.fix.time)
- print('altitude (m)' , gpsd.fix.altitude)
- print('eps ' , gpsd.fix.eps)
- print('epx ' , gpsd.fix.epx)
- print('epv ' , gpsd.fix.epv)
- print('ept ' , gpsd.fix.ept)
- print('speed (m/s) ' , gpsd.fix.speed)
- print('climb ' , gpsd.fix.climb)
- print('track ' , gpsd.fix.track)
- print('mode ' , gpsd.fix.mode)
- print()
- print("%s satellites in view:" % len(gpsd.satellites))
- for sat in gpsd.satellites:
- print(" %r" % sat)
+ time.sleep(5) # set to whatever
- time.sleep(5) #set to whatever
+ except (KeyboardInterrupt, SystemExit):
+ # when you press ctrl+c
+ print("\nKilling Thread...")
+ gpsp.running = False
+ gpsp.join() # wait for the thread to finish what it's doing
- except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
- print("\nKilling Thread...")
- gpsp.running = False
- gpsp.join() # wait for the thread to finish what it's doing
- print("Done.\nExiting.")
+ print("Done.\nExiting.")