kopia lustrzana https://github.com/projecthorus/chasemapper
Merge branch 'master' of github.com:projecthorus/chasemapper
commit
17c2f3f844
|
@ -31,8 +31,8 @@ class SerialGPS(object):
|
||||||
"""
|
"""
|
||||||
Initialise a SerialGPS object.
|
Initialise a SerialGPS object.
|
||||||
|
|
||||||
This class assumes the serial-connected GPS outputs GPRMC and GPGGA NMEA strings
|
This class assumes the serial-connected GPS outputs GPRMC or GNRMC and GPGGA or GNGGA NMEA strings
|
||||||
using 8N1 RS232 framing. It also assumes the GPGGA string is send after GPRMC. If this
|
using 8N1 RS232 framing. It also assumes the GPGGA or GNGGA string is send after GPRMC or GNRMC. If this
|
||||||
is not the case, position data may be up to 1 second out.
|
is not the case, position data may be up to 1 second out.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -173,14 +173,14 @@ class SerialGPS(object):
|
||||||
def parse_nmea(self, data):
|
def parse_nmea(self, data):
|
||||||
"""
|
"""
|
||||||
Attempt to parse a line of NMEA 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.
|
send the data on to the callback function.
|
||||||
"""
|
"""
|
||||||
if self.uberdebug:
|
if self.uberdebug:
|
||||||
print(data.strip())
|
print(data.strip())
|
||||||
|
|
||||||
if "$GPRMC" in data:
|
if ("$GPRMC" in data) or ("$GNRMC" in data):
|
||||||
logging.debug("SerialGPS - Got GPRMC.")
|
logging.debug("SerialGPS - Got GPRMC or GNRMC.")
|
||||||
gprmc = data.split(",")
|
gprmc = data.split(",")
|
||||||
gprmc_lat = self.dm_to_sd(gprmc[3])
|
gprmc_lat = self.dm_to_sd(gprmc[3])
|
||||||
gprmc_latns = gprmc[4]
|
gprmc_latns = gprmc[4]
|
||||||
|
@ -200,8 +200,8 @@ class SerialGPS(object):
|
||||||
|
|
||||||
self.gps_state["speed"] = gprmc_speed * 0.51444 * 3.6
|
self.gps_state["speed"] = gprmc_speed * 0.51444 * 3.6
|
||||||
|
|
||||||
elif "$GPGGA" in data:
|
elif ("$GPGGA" in data) or ("$GNGGA" in data):
|
||||||
logging.debug("SerialGPS - Got GPGGA.")
|
logging.debug("SerialGPS - Got GPGGA or GNGGA.")
|
||||||
gpgga = data.split(",")
|
gpgga = data.split(",")
|
||||||
gpgga_lat = self.dm_to_sd(gpgga[2])
|
gpgga_lat = self.dm_to_sd(gpgga[2])
|
||||||
gpgga_latns = gpgga[3]
|
gpgga_latns = gpgga[3]
|
||||||
|
@ -225,7 +225,7 @@ class SerialGPS(object):
|
||||||
else:
|
else:
|
||||||
self.gps_state["valid"] = True
|
self.gps_state["valid"] = True
|
||||||
self.send_to_callback()
|
self.send_to_callback()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Discard all other lines
|
# Discard all other lines
|
||||||
pass
|
pass
|
||||||
|
|
Ładowanie…
Reference in New Issue