kopia lustrzana https://github.com/projecthorus/chasemapper
Added GNGGA support to gps.py
Several GPS mouses (like Beitan BN-808 with U-blox chip) send GNGGA instead of GPGGA NMEA strings and causing GPS not to work with Chasemapper. This change made those gps-mouses work. See http://navspark.mybigcommerce.com/content/NMEA_Format_v0.1.pdf table2 and 3 for equal function for GPGGA/GNGGA "Time, position, and fix related data of the receiver. "pull/37/head
rodzic
9258120a52
commit
c55a2f3f49
|
@ -31,8 +31,8 @@ class SerialGPS(object):
|
|||
"""
|
||||
Initialise a SerialGPS object.
|
||||
|
||||
This class assumes the serial-connected GPS outputs GPRMC and GPGGA NMEA strings
|
||||
using 8N1 RS232 framing. It also assumes the GPGGA string is send after GPRMC. If this
|
||||
This class assumes the serial-connected GPS outputs GPRMC and GPGGA or GNGGA NMEA strings
|
||||
using 8N1 RS232 framing. It also assumes the GPGGA or GNGGA string is send after GPRMC. If this
|
||||
is not the case, position data may be up to 1 second out.
|
||||
|
||||
Args:
|
||||
|
@ -173,7 +173,7 @@ class SerialGPS(object):
|
|||
def parse_nmea(self, data):
|
||||
"""
|
||||
Attempt to parse a line of NMEA data.
|
||||
If we have received a GPGGA string containing a position valid flag,
|
||||
If we have received a GPGGA or GNGGA string containing a position valid flag,
|
||||
send the data on to the callback function.
|
||||
"""
|
||||
if self.uberdebug:
|
||||
|
@ -226,6 +226,32 @@ class SerialGPS(object):
|
|||
self.gps_state["valid"] = True
|
||||
self.send_to_callback()
|
||||
|
||||
elif "$GNGGA" in data:
|
||||
logging.debug("SerialGPS - Got GNGGA.")
|
||||
gngga = data.split(",")
|
||||
gngga_lat = self.dm_to_sd(gngga[2])
|
||||
gngga_latns = gngga[3]
|
||||
gngga_lon = self.dm_to_sd(gngga[4])
|
||||
gngga_lonew = gngga[5]
|
||||
gngga_fixstatus = gngga[6]
|
||||
self.gps_state["altitude"] = float(gngga[9])
|
||||
|
||||
if gngga_latns == "S":
|
||||
self.gps_state["latitude"] = gngga_lat * -1.0
|
||||
else:
|
||||
self.gps_state["latitude"] = gngga_lat
|
||||
|
||||
if gngga_lonew == "W":
|
||||
self.gps_state["longitude"] = gngga_lon * -1.0
|
||||
else:
|
||||
self.gps_state["longitude"] = gngga_lon
|
||||
|
||||
if gngga_fixstatus == 0:
|
||||
self.gps_state["valid"] = False
|
||||
else:
|
||||
self.gps_state["valid"] = True
|
||||
self.send_to_callback()
|
||||
|
||||
else:
|
||||
# Discard all other lines
|
||||
pass
|
||||
|
|
Ładowanie…
Reference in New Issue