Skip to content

Commit fb034fb

Browse files
committed
Cleaned it up. Removed code from unfinished functions
1 parent 3b79116 commit fb034fb

File tree

1 file changed

+7
-76
lines changed

1 file changed

+7
-76
lines changed

adafruit_gps.py

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,15 @@ def _parse_sentence(self):
173173
# This needs to be refactored when it can be tested.
174174

175175
# Only continue if we have at least 64 bytes in the input buffer
176-
"""
177176
if self._uart.in_waiting < 64:
178177
return None
179-
"""
180178

181179
sentence = self._uart.readline()
182180
if sentence is None or sentence == b'' or len(sentence) < 1:
183-
print("Sentence is none")
184181
return None
185182
try:
186183
sentence = str(sentence, 'ascii').strip()
187184
except UnicodeError:
188-
print("UnicodeError")
189185
return None
190186
# Look for a checksum and validate it if present.
191187
if len(sentence) > 7 and sentence[-3] == '*':
@@ -195,15 +191,13 @@ def _parse_sentence(self):
195191
for i in range(1, len(sentence)-3):
196192
actual ^= ord(sentence[i])
197193
if actual != expected:
198-
print("Actual != expected")
199194
return None # Failed to validate checksum.
200195
# Remove checksum once validated.
201196
sentence = sentence[:-3]
202197
# Parse out the type of sentence (first string after $ up to comma)
203198
# and then grab the rest as data within the sentence.
204199
delineator = sentence.find(',')
205200
if delineator == -1:
206-
print("Bad delineator")
207201
return None # Invalid sentence, no comma after data type.
208202
data_type = sentence[1:delineator]
209203
return (data_type, sentence[delineator+1:])
@@ -230,8 +224,7 @@ def _parse_gpgll(self, args):
230224
# Set or update time to a friendly python time struct.
231225
if self.timestamp_utc is not None:
232226
self.timestamp_utc = time.struct_time((
233-
self.timestamp_utc.tm_year, self.timestamp_utc.tm_mon,
234-
self.timestamp_utc.tm_mday, hours, mins, secs, 0, 0, -1))
227+
0, 0, 0, hours, mins, secs, 0, 0, -1))
235228
else:
236229
self.timestamp_utc = time.struct_time((0, 0, 0, hours, mins,
237230
secs, 0, 0, -1))
@@ -298,17 +291,8 @@ def _parse_gprmc(self, args):
298291
0, 0, 0, -1))
299292

300293
def _parse_gpvtg(self, args):
301-
data = args.split(',')
302-
303-
# Parse true track made good (degrees)
304-
self.true_track = _parse_float(data[0])
305-
306-
# Parse magnetic track made good
307-
self.mag_track = _parse_float(data[2])
308-
309-
# Parse speed
310-
self.speed_knots = _parse_float(data[4])
311-
self.speed_kmh = _parse_float(data[6])
294+
# Not implemented yet
295+
return None
312296

313297
def _parse_gpgga(self, args):
314298
# Parse the arguments (everything after data type) for NMEA GPGGA
@@ -347,62 +331,9 @@ def _parse_gpgga(self, args):
347331
self.height_geoid = _parse_float(data[10])
348332

349333
def _parse_gpgsa(self, args):
350-
data = args.split(',')
351-
if data is None:
352-
return # Unexpected number of params
353-
354-
# Parse selection mode
355-
self.sel_mode = _parse_str(data[0])
356-
# Parse 3d fix
357-
self.fix_quality_3d = _parse_int(data[1])
358-
sats = list(filter(None, data[2:-4]))
359-
satdict = {}
360-
for i in range(len(sats)):
361-
satdict["self.gps{}".format(i)] = _parse_int(sats[i])
362-
363-
globals().update(satdict)
364-
365-
# Parse PDOP, dilution of precision
366-
self.pdop = _parse_float(data[-3])
367-
# Parse HDOP, horizontal dilution of precision
368-
self.hdop = _parse_float(data[-2])
369-
# Parse VDOP, vertical dilution of precision
370-
self.vdop = _parse_float(data[-1])
334+
# Not implemented yet
335+
return None
371336

372337
def _parse_gpgsv(self, args):
373-
# Parse the arguments (everything after data type) for NMEA GPGGA
374-
# 3D location fix sentence.
375-
data = args.split(',')
376-
if data is None:
377-
return # Unexpected number of params.
378-
379-
# Parse number of messages
380-
self.total_mess_num = _parse_int(data[0]) # Total number of messages
381-
# Parse message number
382-
self.mess_num = _parse_int(data[1]) # Message number
383-
# Parse number of satellites in view
384-
self.satellites = _parse_int(data[2]) # Number of satellites
385-
try:
386-
satlist
387-
except NameError:
388-
satlist = [None] * self.total_mess_num
389-
390-
sat_tup = data[3:]
391-
392-
satdict = {}
393-
for i in range(len(sat_tup)/4):
394-
j = i*4
395-
key = "gps{}".format(i+(4*(self.mess_num-1)))
396-
satnum = _parse_int(sat_tup[0+j]) # Satellite number
397-
satdeg = _parse_int(sat_tup[1+j]) # Elevation in degrees
398-
satazim = _parse_int(sat_tup[2+j]) # Azimuth in degrees
399-
satsnr = _parse_int(sat_tup[3+j]) # SNR (signal-to-noise ratio) in dB
400-
value = (satnum, satdeg, satazim, satsnr)
401-
satdict[key] = value
402-
403-
satlist[self.mess_num-1] = satdict
404-
satlist = list(filter(None, satlist))
405-
self.sats = {}
406-
for satdict in satlist:
407-
self.sats.update(satdict)
408-
print(self.sats)
338+
# Not implemented yet
339+
return None

0 commit comments

Comments
 (0)