nmea

package module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2019 License: MIT Imports: 8 Imported by: 0

README

go-nmea Build Status Go Report Card Coverage Status GoDoc

This is a NMEA library for the Go programming language (http://golang.org).

Installing

Using go get
go get github.com/adrianmo/go-nmea

After this command go-nmea is ready to use. Its source will be in:

$GOPATH/src/github.com/adrianmo/go-nmea

Supported sentences

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

  • RMC - Recommended Minimum Specific GPS/Transit data
  • 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

Example

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

Contributions

Please, feel free to implement support for new sentences, fix bugs, refactor code, etc. and send a pull-request to update the library.

Documentation

Index

Constants

View Source
const (
	// PrefixGNGNS prefix
	//
	// Deprecated: Use TypeGNS instead
	PrefixGNGNS = "GNGNS"

	// PrefixGPGGA prefix
	//
	// Deprecated: Use TypeGGA instead
	PrefixGPGGA = "GPGGA"

	// PrefixGPGLL prefix for GPGLL sentence type
	//
	// Deprecated: Use TypeGLL instead
	PrefixGPGLL = "GPGLL"

	// PrefixGPGSA prefix of GPGSA sentence type
	//
	// Deprecated: Use TypeGSA instead
	PrefixGPGSA = "GPGSA"

	// PrefixGPRMC prefix of GPRMC sentence type
	//
	// Deprecated: Use TypeRMC instead
	PrefixGPRMC = "GPRMC"

	// PrefixPGRME prefix for PGRME sentence type
	//
	// Deprecated: Use TypePGRME instead
	PrefixPGRME = "PGRME"

	// PrefixGLGSV prefix
	//
	// Deprecated: Use TypeGSV instead
	PrefixGLGSV = "GLGSV"

	// PrefixGNGGA prefix
	//
	// Deprecated: Use TypeGGA instead
	PrefixGNGGA = "GNGGA"

	// PrefixGNRMC prefix of GNRMC sentence type
	//
	// Deprecated: Use TypeRMC instead
	PrefixGNRMC = "GNRMC"

	// PrefixGPGSV prefix
	//
	// Deprecated: Use TypeGSV instead
	PrefixGPGSV = "GPGSV"

	// PrefixGPHDT prefix of GPHDT sentence type
	//
	// Deprecated: Use TypeHDT instead
	PrefixGPHDT = "GPHDT"

	// PrefixGPVTG prefix
	//
	// Deprecated: Use TypeVTG instead
	PrefixGPVTG = "GPVTG"

	// PrefixGPZDA prefix
	//
	// Deprecated: Use TypeZDA instead
	PrefixGPZDA = "GPZDA"
)
View Source
const (
	// TypeGGA type for GGA sentences
	TypeGGA = "GGA"
	// Invalid fix quality.
	Invalid = "0"
	// GPS fix quality
	GPS = "1"
	// DGPS fix quality
	DGPS = "2"
	// PPS fix
	PPS = "3"
	// RTK real time kinematic fix
	RTK = "4"
	// FRTK float RTK fix
	FRTK = "5"
)
View Source
const (
	// TypeGLL type for GLL sentences
	TypeGLL = "GLL"
	// ValidGLL character
	ValidGLL = "A"
	// InvalidGLL character
	InvalidGLL = "V"
)
View Source
const (
	// TypeGNS type for GNS sentences
	TypeGNS = "GNS"
	// NoFixGNS Character
	NoFixGNS = "N"
	// AutonomousGNS Character
	AutonomousGNS = "A"
	// DifferentialGNS Character
	DifferentialGNS = "D"
	// PreciseGNS Character
	PreciseGNS = "P"
	// RealTimeKinematicGNS Character
	RealTimeKinematicGNS = "R"
	// FloatRTKGNS RealTime Kinematic Character
	FloatRTKGNS = "F"
	// EstimatedGNS Fix Character
	EstimatedGNS = "E"
	// ManualGNS Fix Character
	ManualGNS = "M"
	// SimulatorGNS Character
	SimulatorGNS = "S"
)
View Source
const (
	// TypeGSA type for GSA sentences
	TypeGSA = "GSA"
	// Auto - Field 1, auto or manual fix.
	Auto = "A"
	// Manual - Field 1, auto or manual fix.
	Manual = "M"
	// FixNone - Field 2, fix type.
	FixNone = "1"
	// Fix2D - Field 2, fix type.
	Fix2D = "2"
	// Fix3D - Field 2, fix type.
	Fix3D = "3"
)
View Source
const (
	// TypePGRME type for PGRME sentences
	TypePGRME = "GRME"
	// ErrorUnit must be meters (M)
	ErrorUnit = "M"
)
View Source
const (
	// TypeRMC type for RMC sentences
	TypeRMC = "RMC"
	// ValidRMC character
	ValidRMC = "A"
	// InvalidRMC character
	InvalidRMC = "V"
)
View Source
const (
	// TypeRTE type for RTE sentences
	TypeRTE = "RTE"

	// ActiveRoute active route
	ActiveRoute = "c"

	// WaypointList list containing waypoints
	WaypointList = "w"
)
View Source
const (
	// SentenceStart is the token to indicate the start of a sentence.
	SentenceStart = "$"

	// SentenceStartEncapsulated is the token to indicate the start of encapsulated data.
	SentenceStartEncapsulated = "!"

	// FieldSep is the token to delimit fields of a sentence.
	FieldSep = ","

	// ChecksumSep is the token to delimit the checksum of a sentence.
	ChecksumSep = "*"
)
View Source
const (
	// TypeTHS type for THS sentences
	TypeTHS = "THS"
	// AutonomousTHS autonomous ths heading
	AutonomousTHS = "A"
	// EstimatedTHS estimated (dead reckoning) THS heading
	EstimatedTHS = "E"
	// ManualTHS manual input THS heading
	ManualTHS = "M"
	// SimulatorTHS simulated THS heading
	SimulatorTHS = "S"
	// InvalidTHS not valid THS heading (or standby)
	InvalidTHS = "V"
)
View Source
const (
	// Degrees value
	Degrees = '\u00B0'
	// Minutes value
	Minutes = '\''
	// Seconds value
	Seconds = '"'
	// Point value
	Point = '.'
	// North value
	North = "N"
	// South value
	South = "S"
	// East value
	East = "E"
	// West value
	West = "W"
)
View Source
const (
	// TypeVDM type for VDM sentences
	TypeVDM = "VDM"

	// TypeVDO type for VDO sentences
	TypeVDO = "VDO"
)
View Source
const (
	// TypeALC type for ALC sentences
	TypeALC = "ALC"
)
View Source
const (
	// TypeALF type for ALF sentences
	TypeALF = "ALF"
)
View Source
const (
	// TypeALR type for ALR sentences
	TypeALR = "ALR"
)
View Source
const (
	// TypeARC type for ARC sentences
	TypeARC = "ARC"
)
View Source
const (
	// TypeDBK type for DBK sentences
	TypeDBK = "DBK"
)
View Source
const (
	// TypeDBS type for DBS sentences
	TypeDBS = "DBS"
)
View Source
const (
	// TypeDBT type for DBT sentences
	TypeDBT = "DBT"
)
View Source
const (
	// TypeDPT type for DPT sentences
	TypeDPT = "DPT"
)
View Source
const (
	// TypeGSV type for GSV sentences
	TypeGSV = "GSV"
)
View Source
const (
	// TypeHBT type for HBT sentences
	TypeHBT = "HBT"
)
View Source
const (
	// TypeHDG type for HDG sentences
	TypeHDG = "HDG"
)
View Source
const (
	// TypeHDT type for HDT sentences
	TypeHDT = "HDT"
)
View Source
const (
	// TypeROT type for ROT sentences
	TypeROT = "ROT"
)
View Source
const (
	// TypeVHW type for VHW sentences
	TypeVHW = "VHW"
)
View Source
const (
	// TypeVTG type for VTG sentences
	TypeVTG = "VTG"
)
View Source
const (
	// TypeWPL type for WPL sentences
	TypeWPL = "WPL"
)
View Source
const (
	// TypeZDA type for ZDA sentences
	TypeZDA = "ZDA"
)

Variables

This section is empty.

Functions

func FormatDMS

func FormatDMS(l float64) string

FormatDMS returns the degrees, minutes, seconds format for the given LatLong.

func FormatGPS

func FormatGPS(l float64) string

FormatGPS formats a GPS/NMEA coordinate

func ParseDMS

func ParseDMS(s string) (float64, error)

ParseDMS parses a coordinate in degrees, minutes, seconds. - e.g. 33° 23' 22"

func ParseDecimal

func ParseDecimal(s string) (float64, error)

ParseDecimal parses a decimal format coordinate. e.g: 151.196019

func ParseGPS

func ParseGPS(s string) (float64, error)

ParseGPS parses a GPS/NMEA coordinate. e.g 15113.4322S

func ParseLatLong

func ParseLatLong(s string) (float64, error)

ParseLatLong parses the supplied string into the LatLong.

Supported formats are: - DMS (e.g. 33° 23' 22") - Decimal (e.g. 33.23454) - GPS (e.g 15113.4322S)

Types

type ALC added in v1.1.2

type ALC struct {
	BaseSentence `json:"base_sentence,omitempty" mapstructure:"-"`
	TotalNum     int64           `json:"total_num,omitempty" mapstructure:"total_num"`       // total number of sentences this message 01 to 99
	SentenceNum  int64           `json:"sentence_num,omitempty" mapstructure:"sentence_num"` // sentence index number 01-99
	Index        int64           `json:"index,omitempty" mapstructure:"index"`               // sequential message index
	AlertNum     int64           `json:"alert_num,omitempty" mapstructure:"alert_num"`       // Number of alert entries 0 - n
	Alerts       []ALCAlertEntry `json:"alerts,omitempty" mapstructure:"-"`
}

ALC cyclic alert list

func (ALC) ToMap added in v1.2.0

func (s ALC) ToMap() (map[string]interface{}, error)

type ALCAlertEntry added in v1.1.2

type ALCAlertEntry struct {
	MCode         string `json:"m_code,omitempty"`         // manufacture mnemonic code(FEC, null)
	AlertID       string `json:"alert_id,omitempty"`       // alert identifier 000 - 999999
	AlertInstance string `json:"alert_instance,omitempty"` // alert instance null
	Revision      string `json:"revision,omitempty"`       // revision counter 1 - 99
}

type ALF added in v1.1.2

type ALF struct {
	BaseSentence   `json:"base_sentence,omitempty" mapstrucure:"-"`
	TotalNum       int64  `json:"total_num,omitempty" mapstrucure:"total_num,omitempty"`                // total number of alf senteces this message (1 - 2)
	SentenceNum    int64  `mapstructure:"sentence_num,omitempty" json:"sentence_num,omitempty"`         // sentence number (1 - 2)
	SeqID          string `mapstructure:"seq_id,omitempty" json:"seq_id,omitempty"`                     // sequential message identifier (0 - 9)
	LastChangeTime Time   `mapstructure:"last_change_time,omitempty" json:"last_change_time,omitempty"` // time of last change, hhmmss.ss or null
	AlertCatogory  string `mapstructure:"alert_catogory,omitempty" json:"alert_catogory,omitempty"`     // alert category, A = Alert category A, B = Alert category B, null
	AlertPriority  string `mapstructure:"alert_priority,omitempty" json:"alert_priority,omitempty"`     // alert priority A=Alarm W=Warning C=Caution, null when SentenceNum=2
	AlertState     string `mapstructure:"alert_state,omitempty" json:"alert_state,omitempty"`           // alert state V=Not Acked, S=Silence, A=Acked, O/U=Resolved,Not Acked, N=normal state, null when SentenceNum=2
	MCode          string `mapstructure:"m_code,omitempty" json:"m_code,omitempty"`                     // manufactrure mnemonic code FEC/null
	AlertID        string `mapstructure:"alert_id,omitempty" json:"alert_id,omitempty"`                 // alert identifier 000-999999
	AlertInstance  string `mapstructure:"alert_instance,omitempty" json:"alert_instance,omitempty"`     // alert instance null
	Revision       string `mapstructure:"revision,omitempty" json:"revision,omitempty"`                 // revision counter
	Escalation     string `mapstructure:"escalation,omitempty" json:"escalation,omitempty"`             // escalation counter
	AlertText      string `mapstructure:"alert_text,omitempty" json:"alert_text,omitempty"`             // alert text max. 16 characters for 1st sentence, maximum length of the field for 2nd sentence later
}

ALF alert sentence http://aprs.gids.nl/nmea/#hdt

func (ALF) ToMap added in v1.2.0

func (s ALF) ToMap() (map[string]interface{}, error)

type ALR added in v1.1.2

type ALR struct {
	BaseSentence `mapstructure:"-,omitempty" json:"base_sentence,omitempty"`
	Time         Time   `mapstructure:"-,omitempty" json:"time,omitempty"`              // time of alarm condition change, UTC
	ID           string `mapstructure:"id,omitempty" json:"id,omitempty"`               // unique alarm number (identifier) at alarm source
	Condition    string `mapstructure:"condition,omitempty" json:"condition,omitempty"` // alarm condition
	ACK          string `mapstructure:"ack,omitempty" json:"ack,omitempty"`             // alarm acknowledge state A=acknowledged, V=unacknowledged
	Text         string `mapstructure:"text,omitempty" json:"text,omitempty"`           // alarm's description text
}

ALR set alarm state http://aprs.gids.nl/nmea/#hdt

func (ALR) ToMap added in v1.2.0

func (s ALR) ToMap() (map[string]interface{}, error)

type ARC added in v1.1.2

type ARC struct {
	BaseSentence
	Time     Time   // release time of alert command refused
	Reserved string // used for proprietary alerts, defined by the manufactrure(FEC, null)
	ID       string // alarm identifier 000-999999
	Instance string // alarm instance null
	Command  string // refused alart command A=Ackknowlege
}

ARC alarm command refused http://aprs.gids.nl/nmea/#ARC

func (ARC) ToMap added in v1.2.0

func (s ARC) ToMap() (map[string]interface{}, error)

type BaseSentence

type BaseSentence struct {
	Talker   string   // The talker id (e.g GP)
	Type     string   // The data type (e.g GSA)
	Fields   []string // Array of fields
	Checksum string   // The Checksum
	Raw      string   // The raw NMEA sentence received
}

BaseSentence contains the information about the NMEA sentence

func ParseSentence added in v1.2.0

func ParseSentence(raw string) (BaseSentence, error)

parseSentence parses a raw message into it's fields

func (BaseSentence) DataType added in v1.1.1

func (s BaseSentence) DataType() string

DataType returns the type of the message

func (BaseSentence) Prefix

func (s BaseSentence) Prefix() string

Prefix returns the talker and type of message

func (BaseSentence) String

func (s BaseSentence) String() string

String formats the sentence into a string

func (BaseSentence) TalkerID added in v1.1.1

func (s BaseSentence) TalkerID() string

TalkerID returns the talker of the message

type DBK added in v1.1.2

type DBK struct {
	BaseSentence
	DepthFeet   float64 // depth in feet
	Feet        string  // unit 'f'
	DepthMeters float64 // depth in meters
	Meters      string  // unit 'M'
	DepthFathom float64 // depth in fathom
	Fathom      string  // unit 'F'
}

DBK depth below keel http://aprs.gids.nl/nmea/#DBK

func (DBK) ToMap added in v1.2.0

func (s DBK) ToMap() (map[string]interface{}, error)

type DBS added in v1.1.2

type DBS struct {
	BaseSentence
	DepthFeet   float64 // depth in feet
	Feet        string  // unit 'f'
	DepthMeters float64 // depth in meters
	Meters      string  // unit 'M'
	DepthFathom float64 // depth in fathom
	Fathom      string  // unit 'F'
}

DBS depth below keel http://aprs.gids.nl/nmea/#DBS

func (DBS) ToMap added in v1.2.0

func (s DBS) ToMap() (map[string]interface{}, error)

type DBT added in v1.1.2

type DBT struct {
	BaseSentence
	DepthFeet   float64 // depth in feet
	Feet        string  // unit 'f'
	DepthMeters float64 // depth in meters
	Meters      string  // unit 'M'
	DepthFathom float64 // depth in fathom
	Fathom      string  // unit 'F'
}

DBT depth below keel http://aprs.gids.nl/nmea/#DBT

func (DBT) ToMap added in v1.2.0

func (s DBT) ToMap() (map[string]interface{}, error)

type DPT added in v1.1.2

type DPT struct {
	BaseSentence
	Depth  float64 // water depth relative to transducer, in meters
	Offset float64 // offset from transducer, in meters
	Range  float64 // maximum range scale in use
}

DPT depth below keel http://aprs.gids.nl/nmea/#DPT

func (DPT) ToMap added in v1.2.0

func (s DPT) ToMap() (map[string]interface{}, error)

type Date

type Date struct {
	Valid bool
	DD    int
	MM    int
	YY    int
}

Date type

func ParseDate

func ParseDate(ddmmyy string) (Date, error)

ParseDate field ddmmyy format

func (Date) String

func (d Date) String() string

String representation of date

type GGA added in v1.1.1

type GGA struct {
	BaseSentence
	Time          Time    // Time of fix.
	Latitude      float64 // Latitude.
	Longitude     float64 // Longitude.
	FixQuality    string  // Quality of fix.
	NumSatellites int64   // Number of satellites in use.
	HDOP          float64 // Horizontal dilution of precision.
	Altitude      float64 // Altitude.
	Separation    float64 // Geoidal separation
	DGPSAge       string  // Age of differential GPD data.
	DGPSId        string  // DGPS reference station ID.
}

GGA is the Time, position, and fix related data of the receiver.

func (GGA) ToMap added in v1.2.0

func (s GGA) ToMap() (map[string]interface{}, error)

type GLGSV deprecated

type GLGSV = GSV

GLGSV represents the GPS Satellites in view http://aprs.gids.nl/nmea/#glgsv

Deprecated: Use GSV instead

type GLGSVInfo deprecated

type GLGSVInfo = GSVInfo

GLGSVInfo represents information about a visible satellite

Deprecated: Use GSVInfo instead

type GLL added in v1.1.1

type GLL struct {
	BaseSentence
	Latitude  float64 // Latitude
	Longitude float64 // Longitude
	Time      Time    // Time Stamp
	Validity  string  // validity - A-valid
}

GLL is Geographic Position, Latitude / Longitude and time. http://aprs.gids.nl/nmea/#gll

func (GLL) ToMap added in v1.2.0

func (s GLL) ToMap() (map[string]interface{}, error)

type GNGGA deprecated

type GNGGA = GGA

GNGGA is the Time, position, and fix related data of the receiver.

Deprecated: Use GGA instead

type GNGNS deprecated added in v1.1.1

type GNGNS = GNS

GNGNS is standard GNSS sentance that combined multiple constellations

Deprecated: Use GNS instead

type GNRMC deprecated

type GNRMC = RMC

GNRMC is the Recommended Minimum Specific GNSS data. http://aprs.gids.nl/nmea/#rmc

Deprecated: Use RCM instead

type GNS added in v1.1.1

type GNS struct {
	BaseSentence
	Time       Time
	Latitude   float64
	Longitude  float64
	Mode       []string
	SVs        int64
	HDOP       float64
	Altitude   float64
	Separation float64
	Age        float64
	Station    int64
}

GNS is standard GNSS sentance that combined multiple constellations

func (GNS) ToMap added in v1.2.0

func (s GNS) ToMap() (map[string]interface{}, error)

type GPGGA deprecated

type GPGGA = GGA

GPGGA represents fix data. http://aprs.gids.nl/nmea/#gga

Deprecated: Use GGA instead

type GPGLL deprecated

type GPGLL = GLL

GPGLL is Geographic Position, Latitude / Longitude and time. http://aprs.gids.nl/nmea/#gll

Deprecated: Use GLL instead

type GPGSA deprecated

type GPGSA = GSA

GPGSA represents overview satellite data. http://aprs.gids.nl/nmea/#gsa

Deprecated: Use GSA instead

type GPGSV deprecated

type GPGSV = GSV

GPGSV represents the GPS Satellites in view http://aprs.gids.nl/nmea/#gpgsv

Deprecated: Use GSV instead

type GPGSVInfo deprecated

type GPGSVInfo = GSVInfo

GPGSVInfo represents information about a visible satellite

Deprecated: Use GSVInfo instead

type GPHDT deprecated added in v1.1.1

type GPHDT = HDT

GPHDT is the Actual vessel heading in degrees True. http://aprs.gids.nl/nmea/#hdt

Deprecated: Use HDT instead

type GPRMC deprecated

type GPRMC = RMC

GPRMC is the Recommended Minimum Specific GNSS data. http://aprs.gids.nl/nmea/#rmc

Deprecated: Use RMC instead

type GPVTG deprecated

type GPVTG = VTG

GPVTG represents track & speed data. http://aprs.gids.nl/nmea/#vtg

Deprecated: Use VTG instead

type GPZDA deprecated

type GPZDA = ZDA

GPZDA represents date & time data. http://aprs.gids.nl/nmea/#zda

Deprecated: Use ZDA instead

type GSA added in v1.1.1

type GSA struct {
	BaseSentence
	Mode    string   // The selection mode.
	FixType string   // The fix type.
	SV      []string // List of satellite PRNs used for this fix.
	PDOP    float64  // Dilution of precision.
	HDOP    float64  // Horizontal dilution of precision.
	VDOP    float64  // Vertical dilution of precision.
}

GSA represents overview satellite data. http://aprs.gids.nl/nmea/#gsa

func (GSA) ToMap added in v1.2.0

func (s GSA) ToMap() (map[string]interface{}, error)

type GSV added in v1.1.1

type GSV struct {
	BaseSentence
	TotalMessages   int64     // Total number of messages of this type in this cycle
	MessageNumber   int64     // Message number
	NumberSVsInView int64     // Total number of SVs in view
	Info            []GSVInfo // visible satellite info (0-4 of these)
}

GSV represents the GPS Satellites in view http://aprs.gids.nl/nmea/#glgsv

func (GSV) ToMap added in v1.2.0

func (s GSV) ToMap() (map[string]interface{}, error)

type GSVInfo added in v1.1.1

type GSVInfo struct {
	SVPRNNumber int64 // SV PRN number, pseudo-random noise or gold code
	Elevation   int64 // Elevation in degrees, 90 maximum
	Azimuth     int64 // Azimuth, degrees from true north, 000 to 359
	SNR         int64 // SNR, 00-99 dB (null when not tracking)
}

GSVInfo represents information about a visible satellite

type HBT added in v1.1.2

type HBT struct {
	BaseSentence
	Interval float64 // configured repeat interval (50s)
	Status   string  // equipment status A=normal
	ID       string  // sequential sequence identifier 0-9
}

HBT heartheat supervision sentence http://aprs.gids.nl/nmea/#HBT

func (HBT) ToMap added in v1.2.0

func (s HBT) ToMap() (map[string]interface{}, error)

type HDG added in v1.1.2

type HDG struct {
	BaseSentence
	Heading            float64
	Deviation          float64
	DeviationDirection string
	Variation          float64
	VariationDirection string
}

HDG is the Actual vessel heading in degrees True. http://aprs.gids.nl/nmea/#hdt

func (HDG) ToMap added in v1.2.0

func (s HDG) ToMap() (map[string]interface{}, error)

type HDT added in v1.1.1

type HDT struct {
	BaseSentence
	Heading float64 // Heading in degrees
	True    bool    // Heading is relative to true north
}

HDT is the Actual vessel heading in degrees True. http://aprs.gids.nl/nmea/#hdt

func (HDT) ToMap added in v1.2.0

func (s HDT) ToMap() (map[string]interface{}, error)

type PGRME

type PGRME struct {
	BaseSentence
	Horizontal float64 // Estimated horizontal position error (HPE) in metres
	Vertical   float64 // Estimated vertical position error (VPE) in metres
	Spherical  float64 // Overall spherical equivalent position error in meters
}

PGRME is Estimated Position Error (Garmin proprietary sentence) http://aprs.gids.nl/nmea/#rme

func (PGRME) ToMap added in v1.2.0

func (s PGRME) ToMap() (map[string]interface{}, error)

type Parser added in v1.2.0

type Parser struct {
	BaseSentence
	// contains filtered or unexported fields
}

Parser provides a simple way of accessing and parsing sentence fields

func NewParser added in v1.2.0

func NewParser(s BaseSentence) *Parser

NewParser constructor

func (*Parser) AssertType added in v1.2.0

func (p *Parser) AssertType(typ string)

AssertType makes sure the sentence's type matches the provided one.

func (*Parser) Date added in v1.2.0

func (p *Parser) Date(i int, context string) Date

Date returns the Date value at the specified index. If the value is empty, the Date is marked as invalid.

func (*Parser) EnumChars added in v1.2.0

func (p *Parser) EnumChars(i int, context string, options ...string) []string

EnumChars returns an array of strings that are matched in the Mode field. It will only match the number of characters that are in the Mode field. If the value is empty, it will return an empty array

func (*Parser) EnumString added in v1.2.0

func (p *Parser) EnumString(i int, context string, options ...string) string

EnumString returns the field value at the specified index. An error occurs if the value is not one of the options and not empty.

func (*Parser) Err added in v1.2.0

func (p *Parser) Err() error

Err returns the first error encountered during the parser's usage.

func (*Parser) Float64 added in v1.2.0

func (p *Parser) Float64(i int, context string) float64

Float64 returns the float64 value at the specified index. If the value is an empty string, 0 is returned.

func (*Parser) Int64 added in v1.2.0

func (p *Parser) Int64(i int, context string) int64

Int64 returns the int64 value at the specified index. If the value is an empty string, 0 is returned.

func (*Parser) LatLong added in v1.2.0

func (p *Parser) LatLong(i, j int, context string) float64

LatLong returns the coordinate value of the specified fields.

func (*Parser) ListString added in v1.2.0

func (p *Parser) ListString(from int, context string) (list []string)

ListString returns a list of all fields from the given start index. An error occurs if there is no fields after the given start index.

func (*Parser) SetErr added in v1.2.0

func (p *Parser) SetErr(context, value string)

SetErr assigns an error. Calling this method has no effect if there is already an error.

func (*Parser) SixBitASCIIArmour added in v1.2.0

func (p *Parser) SixBitASCIIArmour(i int, fillBits int, context string) []byte

SixBitASCIIArmour decodes the 6-bit ascii armor used for VDM and VDO messages

func (*Parser) String added in v1.2.0

func (p *Parser) String(i int, context string) string

String returns the field value at the specified index.

func (*Parser) Time added in v1.2.0

func (p *Parser) Time(i int, context string) Time

Time returns the Time value at the specified index. If the value is empty, the Time is marked as invalid.

type RMC added in v1.1.1

type RMC struct {
	BaseSentence
	Time      Time    // Time Stamp
	Validity  string  // validity - A-ok, V-invalid
	Latitude  float64 // Latitude
	Longitude float64 // Longitude
	Speed     float64 // Speed in knots
	Course    float64 // True course
	Date      Date    // Date
	Variation float64 // Magnetic variation
}

RMC is the Recommended Minimum Specific GNSS data. http://aprs.gids.nl/nmea/#rmc

func (RMC) ToMap added in v1.2.0

func (s RMC) ToMap() (map[string]interface{}, error)

type ROT added in v1.1.2

type ROT struct {
	BaseSentence
	Rate   float64 // rate of turn, degrees/minute, "-" bow turns to port
	Status string
}

ROT rate of turn http://aprs.gids.nl/nmea/#hdt

func (ROT) ToMap added in v1.2.0

func (s ROT) ToMap() (map[string]interface{}, error)

type RTE added in v1.1.1

type RTE struct {
	BaseSentence
	NumberOfSentences         int64    // Number of sentences in sequence
	SentenceNumber            int64    // Sentence number
	ActiveRouteOrWaypointList string   // Current active route or waypoint list
	Name                      string   // Name or number of active route
	Idents                    []string // List of ident of waypoints
}

RTE is a route of waypoints

func (RTE) ToMap added in v1.2.0

func (s RTE) ToMap() (map[string]interface{}, error)

type Sentence

type Sentence interface {
	fmt.Stringer
	Prefix() string
	DataType() string
	TalkerID() string
	ToMap() (map[string]interface{}, error)
}

Sentence interface for all NMEA sentence

func Parse

func Parse(raw string) (Sentence, error)

Parse parses the given string into the correct sentence type.

type THS added in v1.1.1

type THS struct {
	BaseSentence
	Heading float64 // Heading in degrees
	Status  string  // Heading status
}

THS is the Actual vessel heading in degrees True with status. http://www.nuovamarea.net/pytheas_9.html

func (THS) ToMap added in v1.2.0

func (s THS) ToMap() (map[string]interface{}, error)

type Time

type Time struct {
	Valid       bool
	Hour        int
	Minute      int
	Second      int
	Millisecond int
}

Time type

func ParseTime

func ParseTime(s string) (Time, error)

ParseTime parses wall clock time. e.g. hhmmss.ssss An empty time string will result in an invalid time.

func (Time) String

func (t Time) String() string

String representation of Time

type VDMVDO added in v1.1.1

type VDMVDO struct {
	BaseSentence
	NumFragments   int64
	FragmentNumber int64
	MessageID      int64
	Channel        string
	Payload        []byte
}

VDMVDO is a format used to encapsulate generic binary payloads. It is most commonly used with AIS data. http://catb.org/gpsd/AIVDM.html

func (VDMVDO) ToMap added in v1.2.0

func (s VDMVDO) ToMap() (map[string]interface{}, error)

type VHW added in v1.1.2

type VHW struct {
	BaseSentence
	HeadingTrue     float64
	True            string
	HeadingMagnetic float64
	Magnetic        string
	SpeedKnots      float64
	Knots           string
	SpeedKph        float64
	Kph             string
}

VHW is the Actual vessel heading in degrees True. http://aprs.gids.nl/nmea/#hdt

func (VHW) ToMap added in v1.2.0

func (s VHW) ToMap() (map[string]interface{}, error)

type VTG added in v1.1.1

type VTG struct {
	BaseSentence
	TrueTrack        float64
	MagneticTrack    float64
	GroundSpeedKnots float64
	GroundSpeedKPH   float64
}

VTG represents track & speed data. http://aprs.gids.nl/nmea/#vtg

func (VTG) ToMap added in v1.2.0

func (s VTG) ToMap() (map[string]interface{}, error)

type WPL added in v1.1.1

type WPL struct {
	BaseSentence
	Latitude  float64 // Latitude
	Longitude float64 // Longitude
	Ident     string  // Ident of nth waypoint
}

WPL contains information about a waypoint location

func (WPL) ToMap added in v1.2.0

func (s WPL) ToMap() (map[string]interface{}, error)

type ZDA added in v1.1.1

type ZDA struct {
	BaseSentence
	Time          Time
	Day           int64
	Month         int64
	Year          int64
	OffsetHours   int64 // Local time zone offset from GMT, hours
	OffsetMinutes int64 // Local time zone offset from GMT, minutes
}

ZDA represents date & time data. http://aprs.gids.nl/nmea/#zda

func (ZDA) ToMap added in v1.2.0

func (s ZDA) ToMap() (map[string]interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL