A NMEA parser library in pure Go

Overview

go-nmea

Build Status Go Report Card Coverage Status GoDoc

This is a NMEA library for the Go programming language (Golang).

Features

  • Parse individual NMEA 0183 sentences
  • Support for sentences with NMEA 4.10 "TAG Blocks"
  • Register custom parser for unsupported sentence types
  • User-friendly MIT license

Installing

To install go-nmea use go get:

go get github.com/adrianmo/go-nmea

This will then make the github.com/adrianmo/go-nmea package available to you.

Staying up to date

To update go-nmea to the latest version, use go get -u github.com/adrianmo/go-nmea.

Supported sentences

At this moment, this library supports the following sentence types:

Sentence type Description
RMC Recommended Minimum Specific GPS/Transit data
PMTK Messages for setting and reading commands for MediaTek gps modules.
GGA GPS Positioning System Fix Data
GSA GPS DOP and active satellites
GSV GPS Satellites in view
GLL Geographic Position, Latitude / Longitude and time
VTG Track Made Good and Ground Speed
ZDA Date & time data
HDT Actual vessel heading in degrees True
GNS Combined GPS fix for GPS, Glonass, Galileo, and BeiDou
PGRME Estimated Position Error (Garmin proprietary sentence)
THS Actual vessel heading in degrees True and status
VDM/VDO Encapsulated binary payload
WPL Waypoint location
RTE Route
VHW Water Speed and Heading
DPT Depth of Water
DBS Depth Below Surface
DBT Depth below transducer

If you need to parse a message that contains an unsupported sentence type you can implement and register your own message parser and get yourself unblocked immediately. Check the example below to know how to implement and register a custom message parser. However, if you think your custom message parser could be beneficial to other users we encourage you to contribute back to the library by submitting a PR and get it included in the list of supported sentences.

Examples

Built-in message parsing

package main

import (
	"fmt"
	"log"
	"github.com/adrianmo/go-nmea"
)

func main() {
	sentence := "$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70"
	s, err := nmea.Parse(sentence)
	if err != nil {
		log.Fatal(err)
	}
	if s.DataType() == nmea.TypeRMC {
		m := s.(nmea.RMC)
		fmt.Printf("Raw sentence: %v\n", m)
		fmt.Printf("Time: %s\n", m.Time)
		fmt.Printf("Validity: %s\n", m.Validity)
		fmt.Printf("Latitude GPS: %s\n", nmea.FormatGPS(m.Latitude))
		fmt.Printf("Latitude DMS: %s\n", nmea.FormatDMS(m.Latitude))
		fmt.Printf("Longitude GPS: %s\n", nmea.FormatGPS(m.Longitude))
		fmt.Printf("Longitude DMS: %s\n", nmea.FormatDMS(m.Longitude))
		fmt.Printf("Speed: %f\n", m.Speed)
		fmt.Printf("Course: %f\n", m.Course)
		fmt.Printf("Date: %s\n", m.Date)
		fmt.Printf("Variation: %f\n", m.Variation)
	}
}

Output:

$ go run main/main.go

Raw sentence: $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
Time: 22:05:16.0000
Validity: A
Latitude GPS: 5133.8200
Latitude DMS: 51° 33' 49.200000"
Longitude GPS: 042.2400
Longitude DMS: 0° 42' 14.400000"
Speed: 173.800000
Course: 231.800000
Date: 13/06/94
Variation: -4.200000

TAG Blocks

NMEA 4.10 TAG Block values can be accessed via the message's TagBlock struct:

package main

import (
	"fmt"
	"log"
	"time"
	"github.com/adrianmo/go-nmea"
)

func main() {
	sentence := "\\s:Satelite_1,c:1553390539*62\\!AIVDM,1,1,,A,[email protected]`K6`nV00Sv,0*52"
	s, err := nmea.Parse(sentence)
	if err != nil {
		log.Fatal(err)
	}
	parsed := s.(nmea.VDMVDO)
	fmt.Printf("TAG Block timestamp: %v\n", time.Unix(parsed.TagBlock.Time, 0))
	fmt.Printf("TAG Block source:    %v\n", parsed.TagBlock.Source)
}

Output (locale/time zone dependent):

$  go run main/main.go
 
TAG Block timestamp: 2019-03-24 14:22:19 +1300 NZDT
TAG Block source:    Satelite_1

Custom message parsing

If you need to parse a message not supported by the library you can implement your own message parsing. The following example implements a parser for the hypothetical XYZ NMEA sentence type.

package main

import (
	"fmt"

	"github.com/adrianmo/go-nmea"
)

// A type to hold the parsed record
type XYZType struct {
	nmea.BaseSentence
	Time    nmea.Time
	Counter int64
	Label   string
	Value   float64
}

func main() {
	// Do this once it will error if you register the same type multiple times
	err := nmea.RegisterParser("XYZ", func(s nmea.BaseSentence) (nmea.Sentence, error) {
		// This example uses the package builtin parsing helpers
		// you can implement your own parsing logic also
		p := nmea.NewParser(s)
		return XYZType{
			BaseSentence: s,
			Time:         p.Time(0, "time"),
			Label:        p.String(1, "label"),
			Counter:      p.Int64(2, "counter"),
			Value:        p.Float64(3, "value"),
		}, p.Err()
	})

	if err != nil {
		panic(err)
	}

	sentence := "$00XYZ,220516,A,23,5133.82,W*42"
	s, err := nmea.Parse(sentence)
	if err != nil {
		panic(err)
	}

	m, ok := s.(XYZType)
	if !ok {
		panic("Could not parse type XYZ")
	}

	fmt.Printf("Raw sentence: %v\n", m)
	fmt.Printf("Time: %s\n", m.Time)
	fmt.Printf("Label: %s\n", m.Label)
	fmt.Printf("Counter: %d\n", m.Counter)
	fmt.Printf("Value: %f\n", m.Value)
}

Output:

$ go run main/main.go

Raw sentence: $AAXYZ,220516,A,23,5133.82,W*42
Time: 22:05:16.0000
Label: A
Counter: 23
Value: 5133.820000

Contributing

Please feel free to submit issues or fork the repository and send pull requests to update the library and fix bugs, implement support for new sentence types, refactor code, etc.

License

Check LICENSE.

Comments
  • Implement support for VDM/VDO encapsulated binary messages

    Implement support for VDM/VDO encapsulated binary messages

    Hello,

    This pull request implements support for VDM/VDO encapsulated message parsing. It requires a change to sentence.go as these messages use '!' instead of '$' as start byte.

    VDM and VDO are the same message, depending on the circumstances or configuration the sender will produce one or the other, but they are handled identically. Currently I made one decoder that handles both messages, is this the way to go?

    Sincerely, Bertold

    opened by BertoldVdb 15
  • Default value for empty string

    Default value for empty string

    When a value is missing in a nmea string the float or int value in the parsed sentence is set to 0. This way it is hard to determine if the value is really 0 or the data was missing. E.g. $GPVTG,0.3,T,,M,,N,12.6,K*78 would result in GroundSpeedKnots: 0 and GroundSpeedKPH: 12.6. Now it is easy to guess that that GroundSpeedKnots is invalid, but for TrueTrack: 0.3 and MagneticTrack: 0 it is not possible.

    Is there a specific reason why this is done in this way?

    I would suggest to add getters to the sentences for all the value like:

    func (s VTG) GetTrueTrack() (float64, error) {
    	if s.hasValidTrueTrack {
    		return s.TrueTrack, nil
    	}
    	return 0, fmt.Errorf("TrueTrack is missing in the nmea string")
    }
    

    These getters can check an internal state for each value and return an error if the value was not available in the original nmea string. This will also not break existing code because it is still possible to use TrueTrack, MagneticTrack etc directly.

    kind/enhancement status/ready 
    opened by munnik 14
  • Accept other talkers than

    Accept other talkers than "GP"

    The NMEA 0183 protocol offers multiple talkers based on which equipment generated the message.
    GP indicates a GPS receiver, GL a GLONASS receiver, GN a combined GNSS receiver, IN an integrated navigation receiver and so forth. See here for examples of different talkers.

    As of today, go-nmea only accepts GP for most messages as talker. Is there an easy way of allowing different talkers for all NMEA messages, or is it necessary to implement specific functions for all talkers?

    A concrete example is the HDT, which in many cases is HEHDT and INHDT.

    An easy (but dirty) way is of course to manipulate the talker into GP.

    status/needs-info kind/enhancement 
    opened by sthorshaug 14
  • Functions for talker and message type

    Functions for talker and message type

    To make it easier to use sentences where the talker is unknown, I've added functions to retrieve the talker and message type separately.
    This gives the opportunity to case switch the type of message, which e.g. would be nice to have when receiving $GNGGA and $GPGGA simultaneously.

    opened by sthorshaug 12
  • expose xorChecksum

    expose xorChecksum

    expose xorChecksum to be able to use when creating MTK requests.

    discussion https://github.com/adrianmo/go-nmea/pull/60#pullrequestreview-271338475

    example usage: https://github.com/arribada/smartLoraTracker/blob/3ae623f282f79d2b2f08045381a9e037d9ff6ab8/tools/gpsLora/gpsLora.go#L57

    Signed-off-by: Krasi Georgiev [email protected]

    opened by krasi-georgiev 11
  • Make `ParseSentence` function unexported

    Make `ParseSentence` function unexported

    Judging by #18, it looks like the ParseSentence function is causing confusion when using the library. Making it unexported would remove this potential confusion.

    In a first inspection, I didn't see any reason to export the function as it's only used internally.

    @icholy any thoughts?

    opened by adrianmo 11
  • Major Refactor

    Major Refactor

    This is a pretty big refactor that introduce breaking changes. Let me know what you think.

    Breaking changes

    • Add Date & Time types.
    • Convert numeric fields to either float64 or int64.
    • Rename Sentence to Sent
    • Rename Sent.GetSentence() to Sent.Sentence()
    • Rename SentenceI to Message
    • Rename NewLatLong to ParseLatLong

    Non-Breaking changes

    • Add ParseSentence(string)
    • Add Sent.Prefix() string
    • Add nmea: prefix to error messages.
    • Unify error message format.
    • Add parser to simplify sentence parsing.
    opened by icholy 11
  • added memorization of latitude/longitude direction

    added memorization of latitude/longitude direction

    If the library stores geographical coordinate values, it is also good to store their directions. Thanks to this, you can recover complete information about the coordinates:

    fmt.Printf("Latitude GPS: %s %s\n", nmea.FormatGPS(m.Latitude), m.LatDirection)
    fmt.Printf("Latitude DMS: %s %s\n", nmea.FormatDMS(m.Latitude), m.LatDirection)
    fmt.Printf("Longitude GPS: %s %s\n", nmea.FormatGPS(m.Longitude), m.LonDirection)
    fmt.Printf("Longitude DMS: %s %s\n", nmea.FormatDMS(m.Longitude), m.LonDirection)
    
    Latitude GPS: 5433.2508 N
    Latitude DMS: 54° 33' 15.048000" N
    Longitude GPS: 1825.6375 E
    Longitude DMS: 18° 25' 38.250000" E
    
    opened by krawczyk87 7
  • Support custom message types

    Support custom message types

    I would like to extend this lib to support custom message parsing, is this something you would consider merging. We are using this to parse some custom message which are not part of the NMEA standard. The idea is to have a way to register parsers for new message types.

    kind/feature 
    opened by yavosh 6
  • Doesn't handle null fields.

    Doesn't handle null fields.

    I have the following sentence:

    $GPRMC,142754.0,A,4302.539570,N,07920.379823,W,0.0,,070617,0.0,E,A*3F

    Which fails to parse with: GPRMC decode course error: due to the parser not handling null fields correctly. The easiest solution would be to use 0 when there's a null field, but idk if that's a good idea.

    https://www.trimble.com/OEM_ReceiverHelp/V4.44/en/NMEA-0183messages_MessageOverview.html

    All messages conform to the NMEA-0183 version 3.01 format. All begin with $ and end with a carriage return and a line feed. Data fields follow comma (,) delimiters and are variable in length. Null fields still follow comma (,) delimiters, but contain no information.

    kind/bug status/help-wanted 
    opened by icholy 6
  • Check sentence starts with dollar ($) sign

    Check sentence starts with dollar ($) sign

    Actually, my issue is that I have some malformed NMEA sentences due to serial communication issues, which led to a crash in the library. My intention here is simply to avoid the crash, not necessarily to recover from it. However, reading a bit about NMEA, it seems that $ is a "start delimiter", so I agree with your solution to start reading from the last $. I'm checking the * after splitting. I also added some tests.

    opened by bezineb5 6
  • processing multiline / segmented messages

    processing multiline / segmented messages

    I could not find an example for processing AIS 5 message here. This type of message has more than one line for example:

    \g:1-2-3730,s:43576,c:1654340281,t:165434038119!AIVDM,2,1,7,,569EH`8000009aGUB20IF1UD4r1UF3OK7>22220N4PT38t0000000000,042

    \g:2-2-37305A!AIVDM,2,2,7,,000000000000000,262

    Is there any way to process such cases?

    opened by metemaad 0
  • Allow sentence parsing customization (SentenceParser struct) ...

    Allow sentence parsing customization (SentenceParser struct) ...

    • Allow sentence parsing customization (callbacks for CRC and tagblocks) (SentenceParser struct) - See #96
    • Add Query sentence,
    • Expose all supported types and their parsers as a map (SupportedParsers),
    • Add 1.18 into CI flow

    BREAKING CHANGE:

    • rename MTK sentence to PMTK001, See #90

    I have added MTK change here as it is deeply tied to sentence parsing internals and has "hacks" to override BaseSentence.TalkerID meaning.

    opened by aldas 3
  • possibility to make CRC check optional for certain sentences

    possibility to make CRC check optional for certain sentences

    Older devices sometimes do not implement NMEA0183 correctly by omitting CRC. It would be nice if there would be way to make parser ignore CRC mismatches for certain sentences.

    We are retrofitting 2005 built vessel that has GPS device sending sentences without CRC. Our navigation engineers say it is not very rare to have older devices like that. So for example devices reading/receiving NMEA0183 sentences have sometimes option to disable CRC checks because of this sad reality.

    opened by aldas 0
  • MTK implementation is currently meant/suitable only for command PMTK001 but there are other messages/commands in MTK

    MTK implementation is currently meant/suitable only for command PMTK001 but there are other messages/commands in MTK

    I think MTK implementation is not correct. MTK is command protocol embedded into NMEA sentence. Fields that current MTK struct has are meant for MTK packet "PMTK001" but actually MTK packet can have variable amound of data fields.

    See:

    • https://www.rhydolabz.com/documents/25/PMTK_A11.pdf
    • https://www.sparkfun.com/datasheets/GPS/Modules/PMTK_Protocol.pdf
    opened by aldas 3
  • Add GSensord - not sure how to deal with checksums being optional

    Add GSensord - not sure how to deal with checksums being optional

    NB: I don't actually expect you to merge this request, I've broken the handling of missing checksums.

    I also think this might be a specific usecase and not a standards type issue.

    Basically the Navman MIVUE dashcams add a $GSENSORD sentence that doesn't have checksums.

    I did consider refactoring to make types checksum aware so they can complain if they're expecting a checksum or not, but I wasn't sure how you'd like to proceed.

    Probably best to just leave it out entirely, or have an unexpected type handler, but then I could just do that with a substring match before parsing.

    Sample data:

    $GSENSORD,0.060,0.120,-0.180
    $GPRMC,073815.000,A,2703.7507,S,15257.3940,E,30.35,36.48,060419,,,A*74
    $GPGGA,073815.000,2703.7507,S,15257.3940,E,1,12,0.8,8.4,M,39.6,M,,0000*4B
    $GPGSA,A,3,22,31,03,01,193,26,194,18,23,16,14,11,1.6,0.8,1.4*31
    $GPGSV,4,1,16,01,44,297,37,03,55,211,28,09,01,263,,11,19,310,22*7C
    $GPGSV,4,2,16,14,22,118,27,16,27,032,40,18,33,331,30,22,80,195,37*7D
    $GPGSV,4,3,16,23,28,245,32,26,40,065,42,31,42,142,40,32,25,248,*7A
    $GPGSV,4,4,16,42,57,343,29,193,78,210,24,194,39,337,36,195,15,346,27*4D
    $GSENSORD,-0.120,0.120,-0.250
    $GPRMC,073816.000,A,2703.7438,S,15257.3995,E,30.42,35.62,060419,,,A*79
    $GPGGA,073816.000,2703.7438,S,15257.3995,E,1,12,0.8,8.4,M,39.6,M,,0000*4D
    $GPGSA,A,3,22,31,03,01,193,26,194,18,23,16,14,11,1.6,0.8,1.4*31
    $GPGSV,4,1,16,01,44,297,37,03,55,211,27,09,01,263,,11,19,310,21*70
    $GPGSV,4,2,16,14,22,118,25,16,27,032,39,18,33,331,31,22,80,195,37*70
    $GPGSV,4,3,16,23,28,245,33,26,40,065,43,31,42,142,29,32,25,248,*75
    $GPGSV,4,4,16,42,57,343,30,193,78,210,24,194,39,337,36,195,15,346,29*4B
    
    opened by freman 9
  • Document message specification

    Document message specification

    Since there's no public canonical nmea reference, we've been linking to different resources on the web. It would be better to maintain our own copy of the message specifications that we implement.

    area/documentation kind/enhancement 
    opened by icholy 4
Releases(v1.7.0)
  • v1.7.0(Mar 1, 2022)

    New Sentences 💌

    • DTM - Datum Reference
    • OSD - Own Ship Data
    • RSD - RADAR System Data
    • TLL - Target latitude and longitude
    • TTM - Tracked Target Message
    • VBW - Dual Ground/Water Speed

    Thank you! 🥇

    @aldas


    Full Changelog: https://github.com/adrianmo/go-nmea/compare/v1.6.0...v1.7.0

    Source code(tar.gz)
    Source code(zip)
  • v1.6.0(Jan 11, 2022)

    New Sentences 💌

    • AAM - Waypoint Arrival Alarm (#88)
    • ALA - System Faults and alarms (#88)
    • APB - Autopilot Sentence "B" (#88)
    • BEC - Bearing and distance to waypoint (dead reckoning) (#88)
    • BOD - Bearing waypoint to waypoint (origin to destination) (#88)
    • BWC - Bearing and distance to waypoint, great circle (#88)
    • BWR - Bearing and distance to waypoint (Rhumb Line) (#88)
    • BWW - bearing (from destination) destination waypoint to origin waypoint (#88)
    • DBK - Depth Below Keel (obsolete, use DPT instead) (#88)
    • DOR - Door Status Detection (#88)
    • DSC - Digital Selective Calling Information (#88)
    • DSE - Expanded digital selective calling (#88)
    • EVE - General Event Message (#88)
    • FIR - Fire Detection event with time and location (#88)
    • HSC - Heading steering command (#88)
    • MTA - Air Temperature (obsolete, use XDR instead) (#88)
    • RMB - Recommended Minimum Navigation Information (#88)
    • RPM - Engine or Shaft revolutions and pitch (#88)
    • RSA - Rudder Sensor Angle (#88)
    • VDR - Set and Drift (#88)
    • VLW - Distance Traveled through Water (#88)
    • VPW - Speed Measured Parallel to Wind (#88)
    • VWR - Relative Wind Speed and Angle (#88)
    • VWT - True Wind Speed and Angle (#88)
    • XDR - Transducer Measurement (#88)
    • XTE - Cross-track error, measured (#88)

    Enhancements 🎉

    • DBS - Validate field units in sentences (#88)

    Thank you! 🥇

    @aldas

    Full Changelog: https://github.com/adrianmo/go-nmea/compare/v1.5.0...v1.6.0

    Source code(tar.gz)
    Source code(zip)
  • v1.5.0(Dec 29, 2021)

    New Sentences 💌

    • HDG - Heading, Deviation & Variation (#87)
    • HDM - Heading - Magnetic (#87)
    • MTW - Mean Temperature of Water (#87)
    • ROT - Rate of turn (#87)
    • TXT - Transmission of text messages (#87)
    • PHTRO - (Proprietary) Vessel pitch and roll (Xsens IMU/VRU/AHRS) (#87)
    • PRDID - (Proprietary) Vessel pitch, roll and heading (Xsens IMU/VRU/AHRS) (#87)
    • PSONCMS - (Proprietary) Quaternion, acceleration, rate of turn, magnetic field, sensor temperature (Xsens IMU/VRU/AHRS) (#87)

    Enhancements 🎉

    • Add NMEA 2.3/4.0 related field (FAA mode and Navigation status) (#87)
    • Improved docs with formats, examples and links (#87)
    • GLL - added FAA mode field (NMEA 2.3+) (#87)
    • GNS - added Navigation status field (NMEA 4.1+) (#87)
    • GSA - added System ID field (NMEA 4.1+) (#87)
    • GSV - added System ID field (NMEA 4.1+) (#87)
    • RMC - added FAA Mode (NMEA 2.3+) and Navigaton status (NMEA 4.1+) fields (#87)
    • VTG - added FAA mode field (NMEA 2.3+) (#87)
    • Added Makefile to make testing/checking easier from command line (#87)

    Thank you! 🥇

    @aldas

    Full Changelog: https://github.com/adrianmo/go-nmea/compare/v1.4.2...v1.5.0

    Source code(tar.gz)
    Source code(zip)
  • v1.4.2(Dec 10, 2021)

    Enhancements 🎉

    • Allow omitting the DPT scale field (#84)
    • Add specific error type (NotSupportedError) when parsing not supported sentence (#85)

    Thank you! 🥇

    @aldas @icholy

    Full Changelog: https://github.com/adrianmo/go-nmea/compare/v1.4.1...v1.4.2

    Source code(tar.gz)
    Source code(zip)
  • v1.4.1(Nov 29, 2021)

  • v1.4.0(Sep 10, 2021)

    New Sentences 💌

    • MDA - Meteorological Composite (#81)
    • MWD - Wind Direction and Speed (#81)
    • MWV - Wind Speed and Angle (#81)

    Thank you! 🥇

    @Maescool @icholy

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Aug 26, 2020)

    New features

    • Support for sentences with NMEA 4.10 "TAG Blocks" (#59, #78)
      • Ref.: https://gpsd.gitlab.io/gpsd/AIVDM.html#_nmea_tag_blocks

    TAG Block struct

    type TagBlock struct {
    	Time         int64  // TypeUnixTime unix timestamp (unit is likely to be s, but might be ms, YMMV), parameter: -c
    	RelativeTime int64  // TypeRelativeTime relative time, parameter: -r
    	Destination  string // TypeDestinationID destination identification 15 char max, parameter: -d
    	Grouping     string // TypeGrouping sentence grouping, parameter: -g
    	LineCount    int64  // TypeLineCount line count, parameter: -n
    	Source       string // TypeSourceID source identification 15 char max, parameter: -s
    	Text         string // TypeTextString valid character string, parameter -t
    }
    

    Ref.: https://github.com/adrianmo/go-nmea/blob/master/tagblock.go#L10

    Code example

    NMEA 4.10 TAG Block values can be accessed via the message's TagBlock struct:

    package main
    
    import (
    	"fmt"
    	"log"
    	"time"
    	"github.com/adrianmo/go-nmea"
    )
    
    func main() {
    	sentence := "\\s:Satelite_1,c:1553390539*62\\!AIVDM,1,1,,A,[email protected]`K6`nV00Sv,0*52"
    	s, err := nmea.Parse(sentence)
    	if err != nil {
    		log.Fatal(err)
    	}
    	parsed := s.(nmea.VDMVDO)
    	fmt.Printf("TAG Block timestamp: %v\n", time.Unix(parsed.TagBlock.Time, 0))
    	fmt.Printf("TAG Block source:    %v\n", parsed.TagBlock.Source)
    }
    

    Output (locale/time zone dependent):

    $  go run main/main.go
     
    TAG Block timestamp: 2019-03-24 14:22:19 +1300 NZDT
    TAG Block source:    Satelite_1
    

    Thank you!

    @klyve @simeonmiteff @icholy

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(May 11, 2020)

    Deprecation

    Message parsing is now talker-agnostic, i.e., it is based on the sentence data type only. For a sentence like $XXYYY,220516,A,23,5133.82,W*42, where XX is the talker and YYY is the sentence data type, the parser will only account for the YYY data type, which is what defines the structure and format of the sentence.

    In your code, given a sentence like the following:

    sentence := "$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70"
    

    Instead of using the old, deprecated prefixes (e.g. nmea.PrefixGPRMC) that included the talked ID and the data type:

    s, _ := nmea.Parse(sentence)
    
    // Deprecated nmea.PrefixGPRMC, use nmea.TypeRMC instead
    if s.Prefix() == nmea.PrefixGPRMC {
        m := s.(nmea.GPRMC)
        fmt.Printf("Validity: %s\n", m.Validity)
        ...
    }
    

    Use the DataType() sentence method to determine the parsed sentence data type and then cast it to the right type:

    s, _ := nmea.Parse(sentence)
    
    if s.DataType() == nmea.TypeRMC {
        m := s.(nmea.RMC)
        fmt.Printf("Validity: %s\n", m.Validity)
        ...
    }
    

    New features

    • Ability to register custom message parsers to allow parsing of sentence types that are currently not supported by the library [link].

    New sentences

    • GNS - Combined GPS fix for GPS, Glonass, Galileo, and BeiDou
    • THS - Actual vessel heading in degrees True and status
    • VDM/VDO - Encapsulated binary payload
    • WPL - Waypoint location
    • RTE - Route
    • VHW - Water Speed and Heading
    • DPT - Depth of Water
    • DBS - Depth Below Surface
    • DBT - Depth below transducer

    Thank you!

    @icholy @bmurray @sthorshaug @BertoldVdb @kvartborg @krasi-georgiev @krawczyk87 @yavosh

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jun 20, 2018)

  • v1.0.0(Apr 16, 2018)

    Supported sentences

    • GPRMC - Recommended Minimum Specific GPS/Transit data
    • GNRMC - Recommended Minimum Specific GNSS data
    • GPGGA - GPS Positioning System Fix Data
    • GNGGA - GNSS Positioning System Fix Data
    • GPGSA - GPS DOP and active satellites
    • GPGSV - GPS Satellites in view
    • GLGSV - GLONASS Satellites in view
    • GPGLL - Geographic Position, Latitude / Longitude and time
    • GPVTG - Track Made Good and Ground Speed
    • GPZDA - Date & time data
    • PGRME - Estimated Position Error (Garmin proprietary sentence)
    Source code(tar.gz)
    Source code(zip)
Owner
Adrián Moreno
Adrián Moreno
A parser combinator library for Go.

Takenoco A parser combinator library for Go. Examples CSV parser Dust - toy scripting language Usage Define the parser: package csv import ( "err

shellyln 2 Oct 30, 2022
A general purpose syntax highlighter in pure Go

Chroma — A general purpose syntax highlighter in pure Go NOTE: As Chroma has just been released, its API is still in flux. That said, the high-level i

Alec Thomas 3.5k Dec 3, 2022
A full-featured regex engine in pure Go based on the .NET engine

regexp2 - full featured regular expressions for Go Regexp2 is a feature-rich RegExp engine for Go. It doesn't have constant time guarantees like the b

Doug Clark 645 Dec 5, 2022
HTML, CSS and SVG static renderer in pure Go

Web render This module implements a static renderer for the HTML, CSS and SVG formats. It consists for the main part of a Golang port of the awesome W

Benoit KUGLER 7 Apr 19, 2022
A shell parser, formatter, and interpreter with bash support; includes shfmt

sh A shell parser, formatter, and interpreter. Supports POSIX Shell, Bash, and mksh. Requires Go 1.14 or later. Quick start To parse shell scripts, in

Daniel Martí 5.3k Dec 8, 2022
TOML parser for Golang with reflection.

THIS PROJECT IS UNMAINTAINED The last commit to this repo before writing this message occurred over two years ago. While it was never my intention to

Andrew Gallant 4k Nov 28, 2022
A simple CSS parser and inliner in Go

douceur A simple CSS parser and inliner in Golang. Parser is vaguely inspired by CSS Syntax Module Level 3 and corresponding JS parser. Inliner only p

Aymerick 223 Dec 2, 2022
User agent string parser in golang

User agent parsing useragent is a library written in golang to parse user agent strings. Usage First install the library with: go get xojoc.pw/userage

Alexandru Cojocaru 71 Aug 2, 2021
Simple HCL (HashiCorp Configuration Language) parser for your vars.

HCL to Markdown About To write a good documentation for terraform module, quite often we just need to print all our input variables as a fancy table.

Dmytro Shamenko 15 Dec 14, 2021
A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.

goldmark A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured. goldmark is compliant with CommonMark 0.29. Motivation

Yusuke Inuzuka 2.4k Dec 8, 2022
Unified diff parser and printer for Go

go-diff Diff parser and printer for Go. Installing go get -u github.com/sourcegraph/go-diff/diff Usage It doesn't actually compute a diff. It only rea

Sourcegraph 379 Nov 12, 2022
A PDF renderer for the goldmark markdown parser.

goldmark-pdf goldmark-pdf is a renderer for goldmark that allows rendering to PDF. Reference See https://pkg.go.dev/github.com/stephenafamo/goldmark-p

Stephen Afam-Osemene 91 Oct 21, 2022
Experimental parser Angular template

Experimental parser Angular template This repository only shows what a parser on the Go might look like Benchmark 100k line of template Parser ms @ang

Rustam 8 Dec 15, 2021
A dead simple parser package for Go

A dead simple parser package for Go V2 Introduction Tutorial Tag syntax Overview Grammar syntax Capturing Capturing boolean value Streaming Lexing Sta

Alec Thomas 2.7k Dec 7, 2022
Freestyle xml parser with golang

fxml - FreeStyle XML Parser This package provides a simple parser which reads a XML document and output a tree structure, which does not need a pre-de

null 8 Jul 1, 2022
An extension to the Goldmark Markdown Parser

Goldmark-Highlight An extension to the Goldmark Markdown Parser which adds parsing / rendering capabilities for rendering highlighted text. Highlighte

Kevin Zuern 1 May 25, 2022
A simple json parser built using golang

jsonparser A simple json parser built using golang Installation: go get -u githu

Krisna Pranav 1 Dec 29, 2021
Quick and simple parser for PFSense XML configuration files, good for auditing firewall rules

pfcfg-parser version 0.0.1 : 13 January 2022 A quick and simple parser for PFSense XML configuration files to generate a plain text file of the main c

Rory Campbell-Lange 0 Jan 13, 2022
Interpreted Programming Language built in Go. Lexer, Parser, AST, VM.

Gago | Programming Language Built in Go if you are looking for the docs, go here Gago is a interpreted programming language. It is fully written in Go

Glaukio 4 May 6, 2022