-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReadGPS.py
76 lines (68 loc) · 1.71 KB
/
ReadGPS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import gps
import time
class ReadGPS(object):
def __init__(self):
print("ReadGPS is starting")
self.session = gps.gps("localhost", "2947")
self.session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
report = self.session.next()
report = self.session.next()
report = self.session.next()
report = self.session.next()
self.lastLat = 0.0
self.lastLon = 0.0
#self.lastClimb = 0.0
#self.lastAlt = 0.0
#self.lastSpeed = 0.0
#self.lastTrack = 0.0
self.data = {}
self.data["lat"] = self.lastLat
self.data["lon"] = self.lastLon
#self.data["climb"] = self.lastClimb
#self.data["alt"] = self.lastAlt
#self.data["speed"] = self.lastSpeed
#self.data["track"] = self.lastTrack
#self.data["errs"] = 0
#self.data["time"] = time.time()
def Update(self):
errs = 0
report = self.session.next()
if report["class"] == "TPV":
if hasattr(report, "lat"):
self.lastLat = report.lat
else:
errs += 1
if hasattr(report, "lon"):
self.lastLon = report.lon
else:
errs += 1
#if hasattr(report, "climb"):
# self.lastClimb = report.climb
#else:
# errs += 1
#
#if hasattr(report, "alt"):
# self.lastAlt = report.alt
#else:
# errs += 1
#
#if hasattr(report, "speed"):
# self.lastSpeed = report.speed
#else:
# errs += 1
#
#if hasattr(report, "track"):
# self.lastTrack = report.track
#else:
# errs += 1
#
self.data["lat"] = self.lastLat
self.data["lon"] = self.lastLon
#self.data["climb"] = self.lastClimb
#self.data["alt"] = self.lastAlt
#self.data["speed"] = self.lastSpeed
#self.data["track"] = self.lastTrack
#self.data["errs"] = errs
#self.data["time"] = time.time()
def End(self):
print("ReadGPS is ending")