Added supported sentences for Beitian GPS-module

The Beitian BN-880 appears to use slightly different NEMA sentences. By
adding these sentences and calling the methods which already exist
everything seems to work as expected. This was tested on an ESP32.

The extra exception catching was needed to prevent the program from
crashing in case a "list index out of range" exception was thrown.
pull/12/head
cintom00 2018-01-31 17:19:26 +01:00
rodzic 1a111f6359
commit 3f593e6649
1 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -497,21 +497,29 @@ class MicropyGPS(object):
sat_id = int(self.gps_segments[sats]) sat_id = int(self.gps_segments[sats])
except ValueError: except ValueError:
return False return False
except Exception:
return False
try: # elevation can be null (no value) when not tracking try: # elevation can be null (no value) when not tracking
elevation = int(self.gps_segments[sats+1]) elevation = int(self.gps_segments[sats+1])
except ValueError: except ValueError:
elevation = None elevation = None
except Exception:
elevation = None
try: # azimuth can be null (no value) when not tracking try: # azimuth can be null (no value) when not tracking
azimuth = int(self.gps_segments[sats+2]) azimuth = int(self.gps_segments[sats+2])
except ValueError: except ValueError:
azimuth = None azimuth = None
except Exception:
azimuth = None
try: # SNR can be null (no value) when not tracking try: # SNR can be null (no value) when not tracking
snr = int(self.gps_segments[sats+3]) snr = int(self.gps_segments[sats+3])
except ValueError: except ValueError:
snr = None snr = None
except Exception:
snr = None
# If no PRN is found, then the sentence has no more satellites to read # If no PRN is found, then the sentence has no more satellites to read
else: else:
@ -809,6 +817,8 @@ class MicropyGPS(object):
'GPGSA': gpgsa, 'GLGSA': gpgsa, 'GPGSA': gpgsa, 'GLGSA': gpgsa,
'GPGSV': gpgsv, 'GLGSV': gpgsv, 'GPGSV': gpgsv, 'GLGSV': gpgsv,
'GPGLL': gpgll, 'GLGLL': gpgll, 'GPGLL': gpgll, 'GLGLL': gpgll,
'GNGGA': gpgga, 'GNRMC': gprmc,
'GNVTG': gpvtg,
} }
if __name__ == "__main__": if __name__ == "__main__":