@@ -393,34 +393,36 @@ def _parse_gpgsv(self, args):
393
393
# Parse number of satellites in view
394
394
self .satellites = _parse_int (data [2 ]) # Number of satellites
395
395
396
- if len (data ) > 3 :
397
- sat_tup = data [3 :]
398
-
399
- satdict = {}
400
- for i in range (len (sat_tup )/ 4 ):
401
- j = i * 4
402
- key = "gps{}" .format (i + (4 * (self .mess_num - 1 )))
403
- satnum = _parse_int (sat_tup [0 + j ]) # Satellite number
404
- satdeg = _parse_int (sat_tup [1 + j ]) # Elevation in degrees
405
- satazim = _parse_int (sat_tup [2 + j ]) # Azimuth in degrees
406
- satsnr = _parse_int (sat_tup [3 + j ]) # signal-to-noise ratio in dB
407
- value = (satnum , satdeg , satazim , satsnr )
408
- satdict [key ] = value
409
-
410
- if self .sats is None :
411
- self .sats = {}
412
- for satnum in satdict :
413
- self .sats [satnum ] = satdict [satnum ]
396
+ if len (data ) < 3 :
397
+ return
414
398
415
- try :
416
- if self .satellites < self .satellites_prev :
417
- for i in self .sats :
418
- try :
419
- if int (i [- 2 ]) >= self .satellites :
420
- del self .sats [i ]
421
- except ValueError :
422
- if int (i [- 1 ]) >= self .satellites :
423
- del self .sats [i ]
424
- except TypeError :
425
- pass
426
- self .satellites_prev = self .satellites
399
+ sat_tup = data [3 :]
400
+
401
+ satdict = {}
402
+ for i in range (len (sat_tup )/ 4 ):
403
+ j = i * 4
404
+ key = "gps{}" .format (i + (4 * (self .mess_num - 1 )))
405
+ satnum = _parse_int (sat_tup [0 + j ]) # Satellite number
406
+ satdeg = _parse_int (sat_tup [1 + j ]) # Elevation in degrees
407
+ satazim = _parse_int (sat_tup [2 + j ]) # Azimuth in degrees
408
+ satsnr = _parse_int (sat_tup [3 + j ]) # signal-to-noise ratio in dB
409
+ value = (satnum , satdeg , satazim , satsnr )
410
+ satdict [key ] = value
411
+
412
+ if self .sats is None :
413
+ self .sats = {}
414
+ for satnum in satdict :
415
+ self .sats [satnum ] = satdict [satnum ]
416
+
417
+ try :
418
+ if self .satellites < self .satellites_prev :
419
+ for i in self .sats :
420
+ try :
421
+ if int (i [- 2 ]) >= self .satellites :
422
+ del self .sats [i ]
423
+ except ValueError :
424
+ if int (i [- 1 ]) >= self .satellites :
425
+ del self .sats [i ]
426
+ except TypeError :
427
+ pass
428
+ self .satellites_prev = self .satellites
0 commit comments