@@ -173,19 +173,15 @@ def _parse_sentence(self):
173
173
# This needs to be refactored when it can be tested.
174
174
175
175
# Only continue if we have at least 64 bytes in the input buffer
176
- """
177
176
if self ._uart .in_waiting < 64 :
178
177
return None
179
- """
180
178
181
179
sentence = self ._uart .readline ()
182
180
if sentence is None or sentence == b'' or len (sentence ) < 1 :
183
- print ("Sentence is none" )
184
181
return None
185
182
try :
186
183
sentence = str (sentence , 'ascii' ).strip ()
187
184
except UnicodeError :
188
- print ("UnicodeError" )
189
185
return None
190
186
# Look for a checksum and validate it if present.
191
187
if len (sentence ) > 7 and sentence [- 3 ] == '*' :
@@ -195,15 +191,13 @@ def _parse_sentence(self):
195
191
for i in range (1 , len (sentence )- 3 ):
196
192
actual ^= ord (sentence [i ])
197
193
if actual != expected :
198
- print ("Actual != expected" )
199
194
return None # Failed to validate checksum.
200
195
# Remove checksum once validated.
201
196
sentence = sentence [:- 3 ]
202
197
# Parse out the type of sentence (first string after $ up to comma)
203
198
# and then grab the rest as data within the sentence.
204
199
delineator = sentence .find (',' )
205
200
if delineator == - 1 :
206
- print ("Bad delineator" )
207
201
return None # Invalid sentence, no comma after data type.
208
202
data_type = sentence [1 :delineator ]
209
203
return (data_type , sentence [delineator + 1 :])
@@ -230,8 +224,7 @@ def _parse_gpgll(self, args):
230
224
# Set or update time to a friendly python time struct.
231
225
if self .timestamp_utc is not None :
232
226
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 ))
235
228
else :
236
229
self .timestamp_utc = time .struct_time ((0 , 0 , 0 , hours , mins ,
237
230
secs , 0 , 0 , - 1 ))
@@ -298,17 +291,8 @@ def _parse_gprmc(self, args):
298
291
0 , 0 , 0 , - 1 ))
299
292
300
293
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
312
296
313
297
def _parse_gpgga (self , args ):
314
298
# Parse the arguments (everything after data type) for NMEA GPGGA
@@ -347,62 +331,9 @@ def _parse_gpgga(self, args):
347
331
self .height_geoid = _parse_float (data [10 ])
348
332
349
333
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
371
336
372
337
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