Skip to content

Commit 9d4beb8

Browse files
committed
Added function to parse GPGLL data. It FINALLY works
1 parent f5376ae commit 9d4beb8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

adafruit_gps.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def update(self):
114114
try:
115115
sentence = self._parse_sentence()
116116
except UnicodeError:
117+
print("UnicodeError")
117118
return None
118119
if sentence is None:
119120
return False
@@ -122,7 +123,6 @@ def update(self):
122123
data_type, args = sentence
123124
data_type = bytes(data_type.upper(), "ascii")
124125
#return sentence
125-
126126
if data_type == b'GPGLL': # GLL, Geographic Position – Latitude/Longitude
127127
self._parse_gpgll(args)
128128
elif data_type == b'GPRMC': # RMC, minimum location info
@@ -210,7 +210,7 @@ def _parse_sentence(self):
210210

211211
def _parse_gpgll(self, args):
212212
data = args.split(',')
213-
if data is None or len(data) < 11 or data[0] is None:
213+
if data is None or data[0] is None:
214214
return # Unexpected number of params.
215215

216216
# Parse latitude and longitude.
@@ -222,8 +222,7 @@ def _parse_gpgll(self, args):
222222
if self.longitude is not None and \
223223
data[3] is not None and data[3].lower() == 'w':
224224
self.longitude *= -1.0
225-
226-
time_utc = int(_parse_int(data[4]))
225+
time_utc = int(_parse_int(float(data[4])))
227226
if time_utc is not None:
228227
hours = time_utc // 10000
229228
mins = (time_utc // 100) % 100

0 commit comments

Comments
 (0)