All Projects → adrianmo → Go Nmea

adrianmo / Go Nmea

Licence: mit
A NMEA parser library in pure Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Go Nmea

Gpslogger
📡 Lightweight GPS Logging Application For Android.
Stars: ✭ 1,348 (+849.3%)
Mutual labels:  gps
Nodejs Tk102
Server for Xexun/Coban TK102 GPS tracker devices
Stars: ✭ 110 (-22.54%)
Mutual labels:  gps
Opentracker
OpenTracker - open source GPS/GLONASS hardware
Stars: ✭ 129 (-9.15%)
Mutual labels:  gps
Locokit
Location, motion, and activity recording framework for iOS
Stars: ✭ 1,353 (+852.82%)
Mutual labels:  gps
Sparkfun ublox arduino library
Library to control UBX binary protocol and NMEA over I2C on Ublox GPS modules
Stars: ✭ 107 (-24.65%)
Mutual labels:  gps
React Native Fused Location
Finest location for react-native on Android using the new Fused API.
Stars: ✭ 118 (-16.9%)
Mutual labels:  gps
Geogeometry
GeoGeometry is a set of algorithms and functions for manipulating geo hashes and geometric shapes with geo coordinates.
Stars: ✭ 94 (-33.8%)
Mutual labels:  gps
Gps Overlay On Video
Telemetry (GPS) data overlay on videos
Stars: ✭ 136 (-4.23%)
Mutual labels:  gps
Huawei Tcx Converter
A makeshift python tool that generates TCX files from Huawei HiTrack files
Stars: ✭ 108 (-23.94%)
Mutual labels:  gps
Jpx
JPX - Java GPX library
Stars: ✭ 125 (-11.97%)
Mutual labels:  gps
Augmentedgaussianprocesses.jl
Gaussian Process package based on data augmentation, sparsity and natural gradients
Stars: ✭ 99 (-30.28%)
Mutual labels:  gps
Ttgo T Beam Car Tracker
TTGO-T-Beam Arduino Car Tracker - ESP32 + LoRa + GPS + GSM (optional)
Stars: ✭ 106 (-25.35%)
Mutual labels:  gps
Georinex
Python RINEX 2 / 3 NAV / OBS / sp3 reader & batch convert to HDF5 with C-like speed
Stars: ✭ 118 (-16.9%)
Mutual labels:  gps
Loose Gnss Imu
Loosely coupled integration of GNSS and IMU
Stars: ✭ 97 (-31.69%)
Mutual labels:  gps
Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (-7.04%)
Mutual labels:  gps
Meshtastic Device
Device code for the Meshtastic ski/hike/fly/customizable open GPS radio
Stars: ✭ 1,331 (+837.32%)
Mutual labels:  gps
Dingding
免root远程钉钉打卡,支持wifi和gps定位,仅支持android系统。本项目出于学习目的,仅用于学习玩耍,请于24小时后自行删除。xposed, crack,package,dingtalk,remote control
Stars: ✭ 116 (-18.31%)
Mutual labels:  gps
Corelocationcli
Command line program to print location information from CoreLocation
Stars: ✭ 138 (-2.82%)
Mutual labels:  gps
Traccar Manager Android
Traccar Manager for Android
Stars: ✭ 133 (-6.34%)
Mutual labels:  gps
Lora Serialization
LoraWAN serialization/deserialization library for The Things Network
Stars: ✭ 120 (-15.49%)
Mutual labels:  gps

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].