@@ -109,10 +109,13 @@ def update(self):
109
109
print (sentence )
110
110
data_type , args = sentence
111
111
data_type = bytes (data_type .upper (), "ascii" )
112
+ #return sentence
112
113
if data_type == b'GPGGA' : # GGA, 3d location fix
113
114
self ._parse_gpgga (args )
114
115
elif data_type == b'GPRMC' : # RMC, minimum location info
115
116
self ._parse_gprmc (args )
117
+ elif data_type == b'GPGSV' :
118
+ self ._parse_gpgsv (args )
116
119
return True
117
120
118
121
def send_command (self , command , add_checksum = True ):
@@ -171,6 +174,7 @@ def _parse_sentence(self):
171
174
data_type = sentence [1 :delineator ]
172
175
return (data_type , sentence [delineator + 1 :])
173
176
177
+
174
178
def _parse_gpgga (self , args ):
175
179
# Parse the arguments (everything after data type) for NMEA GPGGA
176
180
# 3D location fix sentence.
@@ -265,3 +269,32 @@ def _parse_gprmc(self, args):
265
269
# Time hasn't been set so create it.
266
270
self .timestamp_utc = time .struct_time ((year , month , day , 0 , 0 ,
267
271
0 , 0 , 0 , - 1 ))
272
+
273
+ def _parse_gpgsv (self , args ):
274
+ # Parse the arguments (everything after data type) for NMEA GPGGA
275
+ # 3D location fix sentence.
276
+ data = args .split (',' )
277
+ if data is None :
278
+ return # Unexpected number of params.
279
+ # Parse number of messages
280
+ self .total_mess_num = _parse_int (data [0 ])
281
+ # Parse message number
282
+ self .mess_num = _parse_int (data [1 ])
283
+ # Parse number of satellites in view
284
+ self .satellites = _parse_int (data [2 ])
285
+
286
+ sats = data [3 :]
287
+ satdict = {}
288
+ for i in range (len (sats ) / 4 ):
289
+ j = i * 4
290
+
291
+ key = "self.gps{}" .format (i )
292
+ satnum = self ._parse_int (sats [0 + j ]) # Satellite number
293
+ satdeg = self ._parse_int (sats [1 + j ]) # Elevation in degrees
294
+ satazim = self ._parse_int (sats [2 + j ]) # Azimuth in degrees
295
+ satsnr = self ._parse_int (sats [3 + j ]) # SNR (signal-to-noise ratio) in dB
296
+ value = (satnum , satdeg , satazim , satsnr )
297
+ satdict [key ] = value
298
+
299
+ for k ,v in satdict .items ()
300
+ exec ("%s=%s" % (k ,v ))
0 commit comments