Skip to content

Commit

Permalink
feat: add MLA parser
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Apr 9, 2024
1 parent 06850a4 commit 096d90e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
44 changes: 44 additions & 0 deletions standard/mla.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package standard

import "github.com/twpayne/go-nmea"

type MLA struct {
nmea.Address
NumMsg int
MsgNum int
PRN int
GPSWeek int
SVHealth int
Eccentricity int
AlmanacReferenceTime int
InclinationAngle int
OmegaDot int
RootAxis int
Omega int
AscensionNodeLongitude int
MeanAnomaly int
AF0 int
AF1 int
}

func ParseMLA(addr string, tok *nmea.Tokenizer) (*MLA, error) {
var mla MLA
mla.Address = nmea.NewAddress(addr)
mla.NumMsg = tok.CommaUnsignedInt()
mla.MsgNum = tok.CommaUnsignedInt()
mla.PRN = tok.CommaUnsignedInt()
mla.GPSWeek = tok.CommaUnsignedInt()
mla.SVHealth = tok.CommaHex()
mla.Eccentricity = tok.CommaHex()
mla.AlmanacReferenceTime = tok.CommaHex()
mla.InclinationAngle = tok.CommaHex()
mla.OmegaDot = tok.CommaHex()
mla.RootAxis = tok.CommaHex()
mla.Omega = tok.CommaHex()
mla.AscensionNodeLongitude = tok.CommaHex()
mla.MeanAnomaly = tok.CommaHex()
mla.AF0 = tok.CommaHex()
mla.AF1 = tok.CommaHex()
tok.EndOfData()
return &mla, tok.Err()
}
1 change: 1 addition & 0 deletions standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
"GST": nmea.MakeSentenceParser(ParseGST),
"GSV": nmea.MakeSentenceParser(ParseGSV),
"HDT": nmea.MakeSentenceParser(ParseHDT),
"MLA": nmea.MakeSentenceParser(ParseMLA),
"MSS": nmea.MakeSentenceParser(ParseMSS),
"MTW": nmea.MakeSentenceParser(ParseMTW),
"RMB": nmea.MakeSentenceParser(ParseRMB),
Expand Down
22 changes: 21 additions & 1 deletion standard/standard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,6 @@ func TestTheNMEA0813InformationSheetIssue4(t *testing.T) {

func TestNovatel(t *testing.T) {
// From https://docs.novatel.com/OEM7/Content/Logs/Core_Logs.htm.
// FIXME add more test cases
nmeatest.TestSentenceParserFunc(t,
[]nmea.ParserOption{
nmea.WithChecksumDiscipline(nmea.ChecksumDisciplineStrict),
Expand Down Expand Up @@ -1298,6 +1297,27 @@ func TestNovatel(t *testing.T) {
HeadingTrue: 75.5664,
},
},
{
S: "$GLMLA,23,22,87,0864,83,021f,43,30bb,0000,34c0f6,0c8f05,065ccf,004357,000,00b*37",
Expected: &standard.MLA{
Address: nmea.NewAddress("GLMLA"),
NumMsg: 23,
MsgNum: 22,
PRN: 87,
GPSWeek: 864,
SVHealth: 0x83,
Eccentricity: 0x021f,
AlmanacReferenceTime: 0x43,
InclinationAngle: 0x30bb,
OmegaDot: 0x0000,
RootAxis: 0x34c0f6,
Omega: 0x0c8f05,
AscensionNodeLongitude: 0x065ccf,
MeanAnomaly: 0x004357,
AF0: 0x000,
AF1: 0x00b,
},
},
{
S: "$GPRMB,A,4.32,L,FROM,TO,5109.7578000,N,11409.0960000,W,4.6,279.2,0.0,V,D*4A",
Expected: &standard.RMB{
Expand Down

0 comments on commit 096d90e

Please sign in to comment.