gps: add support for GLL sentence type, add original sentence to gps errors

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2023-01-14 12:32:45 +01:00
parent c1637d0b79
commit da791bf9f4
2 changed files with 29 additions and 9 deletions
+17 -1
View File
@@ -54,6 +54,7 @@ func (parser *Parser) Parse(sentence string) (Fix, error) {
typ := sentence[3:6]
switch typ {
case "GGA":
// https://docs.novatel.com/OEM7/Content/Logs/GPGGA.htm
fields := strings.Split(sentence, ",")
if len(fields) != 15 {
return fix, errInvalidGGASentence
@@ -66,8 +67,23 @@ func (parser *Parser) Parse(sentence string) (Fix, error) {
fix.Time = findTime(fields[1])
fix.Valid = (fix.Altitude != -99999) && (fix.Satellites > 0)
return fix, nil
case "GLL":
// https://docs.novatel.com/OEM7/Content/Logs/GPGLL.htm
fields := strings.Split(sentence, ",")
if len(fields) != 8 {
return fix, errInvalidGLLSentence
}
fix.Latitude = findLatitude(fields[2], fields[3])
fix.Longitude = findLongitude(fields[4], fields[5])
fix.Time = findTime(fields[6])
fix.Valid = (fields[7] == "A")
return fix, nil
case "RMC":
// https://docs.novatel.com/OEM7/Content/Logs/GPRMC.htm
fields := strings.Split(sentence, ",")
if len(fields) != 13 {
return fix, errInvalidRMCSentence
@@ -83,7 +99,7 @@ func (parser *Parser) Parse(sentence string) (Fix, error) {
return fix, nil
}
return fix, newGPSError(errUnknownNMEASentence, typ)
return fix, newGPSError(errUnknownNMEASentence, sentence, typ)
}
// findTime returns the time from an NMEA sentence: