nmea

package module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 12 Imported by: 1

README

go-nmea

Build Status Go Report Card Coverage Status GitHub

This is a fork of the https://github.com/adrianmo/go-nmea repository.

Features

  • All the futures of https://github.com/adrianmo/go-nmea
  • All types (structs) have a Valid and InvalidReason property
  • Supports additional nmea0183 sentences (GST, HEV, MDA, MWD, MWV, ROT, VWR)
  • Implement SignalK interface
  • Moved to Ginkgo tests

Installing

To install go-nmea use go get:

go get github.com/munnik/go-nmea

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

Staying up to date

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

Supported sentences

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

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

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.

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.

Documentation

Index

Constants

View Source
const (
	// TypeALR type for ALR sentences
	TypeALR = "ALR"
	// Active alarm
	ActiveALR = "A"
	// Inactive alarm
	InactiveALR = "V"
	// Active alarm
	AcknowledgedALR = "A"
	// Inactive alarm
	UnacknowledgedALR = "V"
)
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"
	// EST estimated fix.
	EST = "6"
)
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 (
	// TypeMWV type for MWV sentences
	TypeMWV = "MWV"

	ReferenceRelative = "R"
	ReferenceTrue     = "T"

	WindSpeedUnitKPH   = "K"
	WindSpeedUnitKnots = "N"
	WindSpeedUnitMPS   = "M"
	WindSpeedUnitMPH   = "S"

	ValidMWV   = "A"
	InvalidMWV = "V"
)
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 (
	// TypeROT type for ROT sentences
	TypeROT = "ROT"

	ValidROT   = "A"
	InvalidROT = "V"
)
View Source
const (
	// TypeRSA type for RSA sentences
	TypeRSA = "RSA"

	ValidRSA   = "A"
	InvalidRSA = "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 (
	// TypeVWR type for VWR sentences
	TypeVWR = "VWR"

	LeftOfBow  = "L"
	RightOfBow = "R"
)
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 (
	// TypeGST type for GST sentences
	TypeGST = "GST"
)
View Source
const (
	// TypeGSV type for GSV sentences
	TypeGSV = "GSV"
)
View Source
const (
	// TypeHDT type for HDT sentences
	TypeHDT = "HDT"
)
View Source
const (
	// TypeHEV type for HEV sentences
	TypeHEV = "HEV"
)
View Source
const (
	// TypeMDA type for MDA sentences
	TypeMDA = "MDA"
)
View Source
const (
	// TypeMTK type for PMTK sentences
	TypeMTK = "PMTK"
)
View Source
const (
	// TypeMWD type for MWD sentences
	TypeMWD = "MWD"
)
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 Checksum added in v1.4.0

func Checksum(s string) string

Checksum xor all the bytes in a string an return it as an uppercase hex string

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 LatDir added in v1.4.0

func LatDir(l float64) string

LatDir returns the latitude direction symbol

func LonDir added in v1.4.0

func LonDir(l float64) string

LonDir returns the longitude direction symbol

func MustRegisterParser added in v1.4.0

func MustRegisterParser(sentenceType string, parser ParserFunc)

MustRegisterParser register a custom parser or panic

func RegisterParser added in v1.4.0

func RegisterParser(sentenceType string, parser ParserFunc) error

RegisterParser register a custom parser

Types

type ALR added in v1.5.0

type ALR struct {
	BaseSentence
	Time        Time
	Identifier  String
	Condition   String
	State       String
	Description String
}

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

func (ALR) GetDescription added in v1.5.0

func (s ALR) GetDescription() (string, error)

func (ALR) GetIdentifier added in v1.5.0

func (s ALR) GetIdentifier() (string, error)

func (ALR) IsActive added in v1.5.0

func (s ALR) IsActive() (bool, error)

func (ALR) IsUnacknowledged added in v1.5.0

func (s ALR) IsUnacknowledged() (bool, error)

type Alarm added in v1.5.0

type Alarm interface {
	IsActive() (bool, error)
	IsUnacknowledged() (bool, error)
	GetDescription() (string, error)
}

Alarm retrieves alarm information from the sentence

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
	TagBlock TagBlock // NMEA tagblock
}

BaseSentence contains the information about the NMEA sentence

func (BaseSentence) DataType added in v1.4.0

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.4.0

func (s BaseSentence) TalkerID() string

TalkerID returns the talker of the message

type CallSign added in v1.4.0

type CallSign interface {
	GetCallSign() (string, error)
}

CallSign retrieves the call sign of the vessel from the sentence

type DBS added in v1.4.0

type DBS struct {
	BaseSentence
	DepthFeet    Float64
	DepthMeters  Float64
	DepthFathoms Float64
}

DBS - Depth Below Surface https://gpsd.gitlab.io/gpsd/NMEA.html#_dbs_depth_below_surface

func (DBS) GetDepthBelowSurface added in v1.4.0

func (s DBS) GetDepthBelowSurface() (float64, error)

GetDepthBelowSurface retrieves the depth below surface from the sentence

type DBT added in v1.4.0

type DBT struct {
	BaseSentence
	DepthFeet    Float64
	DepthMeters  Float64
	DepthFathoms Float64
}

DBT - Depth below transducer https://gpsd.gitlab.io/gpsd/NMEA.html#_dbt_depth_below_transducer

func (DBT) GetDepthBelowTransducer added in v1.4.0

func (s DBT) GetDepthBelowTransducer() (float64, error)

GetDepthBelowTransducer retrieves the depth below the transducer from the sentence

type DPT added in v1.4.0

type DPT struct {
	BaseSentence
	Depth      Float64
	Offset     Float64
	RangeScale Float64
}

DPT - Depth of Water https://gpsd.gitlab.io/gpsd/NMEA.html#_dpt_depth_of_water

func (DPT) GetDepthBelowKeel added in v1.4.0

func (s DPT) GetDepthBelowKeel() (float64, error)

GetDepthBelowKeel retrieves the depth below the keel from the sentence

func (DPT) GetDepthBelowSurface added in v1.4.0

func (s DPT) GetDepthBelowSurface() (float64, error)

GetDepthBelowSurface retrieves the depth below surface from the sentence

func (DPT) GetDepthBelowTransducer added in v1.4.0

func (s DPT) GetDepthBelowTransducer() (float64, error)

GetDepthBelowTransducer retrieves the depth below the keel from the sentence

type Date

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

Date type

func NewDate added in v1.4.0

func NewDate(year int, month int, day int) Date

NewDate creates a valid Date

func NewInvalidDate added in v1.4.0

func NewInvalidDate(reason string) Date

NewInvalidDate creates an invalid Date

func ParseDate

func ParseDate(s string) Date

ParseDate field ddmmyy format

func (Date) String

func (d Date) String() string

String representation of Date

type DateTime added in v1.4.0

type DateTime interface {
	GetDateTime() (string, error)
}

DateTime retrieves the date and time in RFC3339Nano format

type DepthBelowKeel added in v1.4.0

type DepthBelowKeel interface {
	GetDepthBelowKeel() (float64, error)
}

DepthBelowKeel retrieves the depth below keel from the sentence

type DepthBelowSurface added in v1.4.0

type DepthBelowSurface interface {
	GetDepthBelowSurface() (float64, error)
}

DepthBelowSurface retrieves the depth below surface from the sentence

type DepthBelowTransducer added in v1.4.0

type DepthBelowTransducer interface {
	GetDepthBelowTransducer() (float64, error)
}

DepthBelowTransducer retrieves the depth below the transducer from the sentence

type Destination added in v1.4.0

type Destination interface {
	GetDestination() (string, error)
}

Destination retrieves the destination of the vessel from the sentence

type DewPointTemperature added in v1.4.0

type DewPointTemperature interface {
	GetDewPointTemperature() (float64, error)
}

DewPointTemperature retrieves the dew point temperature from the sentence

type ENINumber added in v1.4.0

type ENINumber interface {
	// https://en.wikipedia.org/wiki/ENI_number
	GetENINumber() (string, error)
}

ENINumber retrieves the ENI number of the vessel from the sentence

type ETA added in v1.4.0

type ETA interface {
	GetETA() (time.Time, error)
}

ETA retrieves the ETA of the vessel from the sentence

type FixQuality added in v1.4.0

type FixQuality interface {
	GetFixQuality() (string, error)
}

FixQuality retrieves the fix quality from the sentence

type FixType added in v1.4.0

type FixType interface {
	GetFixType() (string, error)
}

FixType retrieves the fix type from the sentence

type Float64 added in v1.4.0

type Float64 struct {
	Valid         bool
	InvalidReason string
	Value         float64
}

Float64 type

func NewFloat64 added in v1.4.0

func NewFloat64(v float64) Float64

NewFloat64 creates a valid Float64

func NewInvalidFloat64 added in v1.4.0

func NewInvalidFloat64(reason string) Float64

NewInvalidFloat64 creates an invalid Float64

func ParseDMS

func ParseDMS(s string) Float64

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

func ParseDecimal

func ParseDecimal(s string) Float64

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

func ParseFloat64 added in v1.4.0

func ParseFloat64(s string) Float64

ParseFloat64 parses a string and creates a Float64, if the string can't be parsed an invalid Float64 is returned

func ParseGPS

func ParseGPS(s string) Float64

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

func ParseLatLong

func ParseLatLong(s string) Float64

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)

func (Float64) GetValue added in v1.4.0

func (v Float64) GetValue() (float64, error)

GetValue returns the float64 value or an error if valid is false

type GGA added in v1.4.0

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) GetFixQuality added in v1.4.0

func (s GGA) GetFixQuality() (string, error)

GetFixQuality retrieves the fix quality from the sentence

func (GGA) GetNumberOfSatellites added in v1.4.0

func (s GGA) GetNumberOfSatellites() (int64, error)

GetNumberOfSatellites retrieves the number of satellites from the sentence

func (GGA) GetPosition3D added in v1.4.0

func (s GGA) GetPosition3D() (float64, float64, float64, error)

GetPosition3D retrieves the 3D position from the sentence

type GLL added in v1.4.0

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) GetPosition2D added in v1.4.0

func (s GLL) GetPosition2D() (float64, float64, error)

GetPosition2D retrieves the 2D position from the sentence

type GNS added in v1.4.0

type GNS struct {
	BaseSentence
	Time       Time
	Latitude   Float64
	Longitude  Float64
	Mode       StringList
	SVs        Int64
	HDOP       Float64
	Altitude   Float64
	Separation Float64
	Age        Float64
	Station    Int64
}

GNS is standard GNSS sentance that combined multiple constellations

func (GNS) GetPosition3D added in v1.4.0

func (s GNS) GetPosition3D() (float64, float64, float64, error)

GetPosition3D retrieves the 3D position from the sentence

type GSA added in v1.4.0

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) GetFixType added in v1.4.0

func (s GSA) GetFixType() (string, error)

GetFixType retrieves the fix type from the sentence

func (GSA) GetNumberOfSatellites added in v1.4.0

func (s GSA) GetNumberOfSatellites() (int64, error)

GetNumberOfSatellites retrieves the number of satellites from the sentence

type GST added in v1.4.0

type GST struct {
	BaseSentence
	Time                                 Time
	RMSPseudorangeResiduals              Float64
	ErrorEllipseSemiMajorAxis1SigmaError Float64
	ErrorEllipseSemiMinorAxis1SigmaError Float64
	ErrorEllipseOrientation              Float64
	Latitude1SigmaError                  Float64
	Longitude1SigmaError                 Float64
	Height1SigmaError                    Float64
}

GST - Position error statistics

type GSV added in v1.4.0

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) GetNumberOfSatellites added in v1.4.0

func (s GSV) GetNumberOfSatellites() (int64, error)

GetNumberOfSatellites retrieves the number of satellites from the sentence

type GSVInfo added in v1.4.0

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 HDT added in v1.4.0

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) GetTrueHeading added in v1.4.0

func (s HDT) GetTrueHeading() (float64, error)

GetTrueHeading retrieves the true heading from the sentence

type HEV added in v1.4.0

type HEV struct {
	BaseSentence
	Heave Float64 // Heave in meters
}

HEV - Heave

func (HEV) GetHeave added in v1.4.0

func (s HEV) GetHeave() (float64, error)

GetHeave retrieves the heave from the sentence

type Heave added in v1.4.0

type Heave interface {
	GetHeave() (float64, error)
}

Heave retrieves the heave from the sentence

type Humidity added in v1.4.0

type Humidity interface {
	GetHumidity() (float64, error)
}

Humidity retrieves the relative humidity from the sentence

type IMONumber added in v1.4.0

type IMONumber interface {
	GetIMONumber() (string, error)
}

IMONumber retrieves the IMO number of the vessel from the sentence

type Int64 added in v1.4.0

type Int64 struct {
	Valid         bool
	InvalidReason string
	Value         int64
}

Int64 type

func NewInt64 added in v1.4.0

func NewInt64(v int64) Int64

NewInt64 creates a valid Int64

func NewInvalidInt64 added in v1.4.0

func NewInvalidInt64(reason string) Int64

NewInvalidInt64 creates an invalid Int64

func ParseInt64 added in v1.4.0

func ParseInt64(s string) Int64

ParseInt64 parses a string and creates a Int64, if the string can't be parsed an invalid Int64 is returned

func (Int64) GetValue added in v1.4.0

func (v Int64) GetValue() (int64, error)

GetValue returns the int64 value or an error if valid is false

type MDA added in v1.4.0

type MDA struct {
	BaseSentence
	BarometricPressureInInchesOfMercury Float64
	BarometricPressureInBar             Float64
	AirTemperature                      Float64
	WaterTemperature                    Float64
	RelativeHumidity                    Float64
	DewPoint                            Float64
	WindDirectionTrue                   Float64
	WindDirectionMagnetic               Float64
	WindSpeedInKnots                    Float64
	WindSpeedInMetersPerSecond          Float64
}

MDA - Meteorological Composite

func (MDA) GetDewPointTemperature added in v1.4.0

func (s MDA) GetDewPointTemperature() (float64, error)

GetDewPointTemperature retrieves the dew point temperature from the sentence

func (MDA) GetHumidity added in v1.4.0

func (s MDA) GetHumidity() (float64, error)

GetHumidity retrieves the relative humidity from the sentence

func (MDA) GetMagneticWindDirection added in v1.4.0

func (s MDA) GetMagneticWindDirection() (float64, error)

GetMagneticWindDirection retrieves the true wind direction from the sentence

func (MDA) GetOutsidePressure added in v1.4.0

func (s MDA) GetOutsidePressure() (float64, error)

GetOutsidePressure retrieves the outside pressure from the sentence

func (MDA) GetOutsideTemperature added in v1.4.0

func (s MDA) GetOutsideTemperature() (float64, error)

GetOutsideTemperature retrieves the outside air temperature from the sentence

func (MDA) GetTrueWindDirection added in v1.4.0

func (s MDA) GetTrueWindDirection() (float64, error)

GetTrueWindDirection retrieves the true wind direction from the sentence

func (MDA) GetWaterTemperature added in v1.4.0

func (s MDA) GetWaterTemperature() (float64, error)

GetWaterTemperature retrieves the outside air temperature from the sentence

func (MDA) GetWindSpeed added in v1.4.0

func (s MDA) GetWindSpeed() (float64, error)

GetWindSpeed retrieves wind speed from the sentence

type MMSI added in v1.4.0

type MMSI interface {
	GetMMSI() (string, error)
}

MMSI retrieves the MMSI of the vessel from the sentence

type MTK added in v1.4.0

type MTK struct {
	BaseSentence
	Cmd  Int64
	Flag Int64
}

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

type MWD added in v1.4.0

type MWD struct {
	BaseSentence
	WindDirectionTrue          Float64
	WindDirectionMagnetic      Float64
	WindSpeedInKnots           Float64
	WindSpeedInMetersPerSecond Float64
}

MWD - Wind Direction & Speed

func (MWD) GetMagneticWindDirection added in v1.4.0

func (s MWD) GetMagneticWindDirection() (float64, error)

GetMagneticWindDirection retrieves the true wind direction from the sentence

func (MWD) GetTrueWindDirection added in v1.4.0

func (s MWD) GetTrueWindDirection() (float64, error)

GetTrueWindDirection retrieves the true wind direction from the sentence

func (MWD) GetWindSpeed added in v1.4.0

func (s MWD) GetWindSpeed() (float64, error)

GetWindSpeed retrieves wind speed from the sentence

type MWV added in v1.4.0

type MWV struct {
	BaseSentence
	Angle         Float64
	Reference     String
	WindSpeed     Float64
	WindSpeedUnit String
	Status        String
}

MWV - Wind Speed and Angle

func (MWV) GetRelativeWindDirection added in v1.4.0

func (s MWV) GetRelativeWindDirection() (float64, error)

GetRelativeWindDirection retrieves the relative wind direction from the sentence

func (MWV) GetTrueWindDirection added in v1.4.0

func (s MWV) GetTrueWindDirection() (float64, error)

GetTrueWindDirection retrieves the true wind direction from the sentence

func (MWV) GetWindSpeed added in v1.4.0

func (s MWV) GetWindSpeed() (float64, error)

GetWindSpeed retrieves wind speed from the sentence

type MagneticCourseOverGround added in v1.4.0

type MagneticCourseOverGround interface {
	GetmagneticCourseOverGround() (float64, error)
}

MagneticCourseOverGround retrieves the magnetic course over ground from the sentence

type MagneticHeading added in v1.4.0

type MagneticHeading interface {
	GetMagneticHeading() (float64, error)
}

MagneticHeading retrieves the magnetic heading from the sentence

type MagneticVariation added in v1.4.0

type MagneticVariation interface {
	GetMagneticVariation() (float64, error)
}

MagneticVariation retrieves the magnetic variation from the sentence

type MagneticWindDirection added in v1.4.0

type MagneticWindDirection interface {
	GetMagneticWindDirection() (float64, error)
}

MagneticWindDirection retrieves the magnetic wind direction from the sentence

type NavigationStatus interface {
	GetNavigationStatus() (string, error)
}

NavigationStatus retrieves the navigation status from the sentence

type NumberOfSatellites added in v1.4.0

type NumberOfSatellites interface {
	GetNumberOfSatellites() (int64, error)
}

NumberOfSatellites retrieves the number of satellites from the sentence

type OutsideTemperature added in v1.4.0

type OutsideTemperature interface {
	GetOutsideTemperature() (float64, error)
}

OutsideTemperature retrieves the outside air temperature from the sentence

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

type Parser added in v1.4.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.4.0

func NewParser(s BaseSentence) *Parser

NewParser constructor

func (*Parser) AssertType added in v1.4.0

func (p *Parser) AssertType(typ string)

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

func (*Parser) Date added in v1.4.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.4.0

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

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.4.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.4.0

func (p *Parser) Err() error

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

func (*Parser) Float64 added in v1.4.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.4.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.4.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.4.0

func (p *Parser) ListString(from int, context string) StringList

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.4.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.4.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.4.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.4.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 ParserFunc added in v1.4.0

type ParserFunc func(BaseSentence) (Sentence, error)

ParserFunc callback used to parse specific sentence variants

type Position2D added in v1.4.0

type Position2D interface {
	GetPosition2D() (float64, float64, error)
}

Position2D retrieves the 2D position from the sentence

type Position3D added in v1.4.0

type Position3D interface {
	GetPosition3D() (float64, float64, float64, error)
}

Position3D retrieves the 3D position from the sentence

type RMC added in v1.4.0

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) GetDateTime added in v1.4.0

func (s RMC) GetDateTime() (string, error)

GetDateTime retrieves the date and time in RFC3339Nano format

func (RMC) GetMagneticVariation added in v1.4.0

func (s RMC) GetMagneticVariation() (float64, error)

GetMagneticVariation retrieves the magnetic variation from the sentence

func (RMC) GetPosition2D added in v1.4.0

func (s RMC) GetPosition2D() (float64, float64, error)

GetPosition2D retrieves the latitude and longitude from the sentence

func (RMC) GetSpeedOverGround added in v1.4.0

func (s RMC) GetSpeedOverGround() (float64, error)

GetSpeedOverGround retrieves the speed over ground from the sentence

func (RMC) GetTrueCourseOverGround added in v1.4.0

func (s RMC) GetTrueCourseOverGround() (float64, error)

GetTrueCourseOverGround retrieves the true course over ground from the sentence

type ROT added in v1.4.0

type ROT struct {
	BaseSentence
	RateOfTurn Float64 // Rate of turn
	Status     String
}

ROT - Rate of turn

func (ROT) GetRateOfTurn added in v1.4.0

func (s ROT) GetRateOfTurn() (float64, error)

GetRateOfTurn retrieves the rate of turn from the sentence

type RSA added in v1.4.6

type RSA struct {
	BaseSentence
	RudderAngleStarboard Float64
	StatusStarboard      String
	RudderAnglePortside  Float64
	StatusPortside       String
}

RSA - Rudder Angle

func (RSA) GetRudderAngle added in v1.4.6

func (s RSA) GetRudderAngle() (float64, error)

GetRudder retrieves the rudder angle of the single rudder from the sentence

func (RSA) GetRudderAnglePortside added in v1.4.6

func (s RSA) GetRudderAnglePortside() (float64, error)

GetRudderAnglePortside retrieves the rudder angle of the portside rudder from the sentence

func (RSA) GetRudderAngleStarboard added in v1.4.6

func (s RSA) GetRudderAngleStarboard() (float64, error)

GetRudderAngleStarboard retrieves the rudder angle of the startboard rudder from the sentence

type RTE added in v1.4.0

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                    StringList // List of ident of waypoints
}

RTE is a route of waypoints

type RateOfTurn added in v1.4.0

type RateOfTurn interface {
	GetRateOfTurn() (float64, error)
}

RateOfTurn retrieves the rate of turn from the sentence

type RelativeWindDirection added in v1.4.0

type RelativeWindDirection interface {
	GetRelativeWindDirection() (float64, error)
}

RelativeWindDirection retrieves the relative wind direction from the sentence

type RudderAngle added in v1.4.6

type RudderAngle interface {
	GetRudderAngle() (float64, error)
	GetRudderAngleStarboard() (float64, error)
	GetRudderAnglePortside() (float64, error)
}

RudderAngle retrieves the rudder angle from the sentence

type Sentence

type Sentence interface {
	fmt.Stringer
	Prefix() string
	DataType() string
	TalkerID() string
}

Sentence interface for all NMEA sentence

func Parse

func Parse(raw string, options ...string) (Sentence, error)

Parse parses the given string into the correct sentence type. options can be passed as string, supported options are: * "AllowEmptyChecksum" * "AllowChecksumMismatch"

type SpeedOverGround added in v1.4.0

type SpeedOverGround interface {
	GetSpeedOverGround() (float64, error)
}

SpeedOverGround retrieves the speed over ground from the sentence

type SpeedThroughWater added in v1.4.0

type SpeedThroughWater interface {
	GetSpeedThroughWater() (float64, error)
}

SpeedThroughWater retrieves the speed through water from the sentence

type String added in v1.4.0

type String struct {
	Valid         bool
	InvalidReason string
	Value         string
}

String type

func NewInvalidString added in v1.4.0

func NewInvalidString(reason string) String

NewInvalidString creates an invalid String

func NewString added in v1.4.0

func NewString(v string) String

NewString creates a valid String

func (String) GetValue added in v1.4.0

func (v String) GetValue() (string, error)

GetValue returns the string value or an error if valid is false

type StringList added in v1.4.0

type StringList struct {
	Valid         bool
	InvalidReason string
	Values        []String
}

StringList type

func NewInvalidStringList added in v1.4.0

func NewInvalidStringList(reason string) StringList

NewInvalidStringList creates an invalid StringList

func NewStringList added in v1.4.0

func NewStringList(v []String) StringList

NewStringList creates a valid StringList

type THS added in v1.4.0

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) GetTrueHeading added in v1.4.0

func (s THS) GetTrueHeading() (float64, error)

GetTrueHeading retrieves the true heading from the sentence

type TagBlock added in v1.4.0

type TagBlock struct {
	Valid         bool
	InvalidReason string
	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
}

TagBlock type

func NewInvalidTagblock added in v1.4.0

func NewInvalidTagblock(reason string) TagBlock

NewInvalidTagblock creates an invalid TagBlock

func NewTagblock added in v1.4.0

func NewTagblock() TagBlock

NewTagblock creates a valid TagBlock

type Time

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

Time type

func NewInvalidTime added in v1.4.0

func NewInvalidTime(reason string) Time

NewInvalidTime creates an invalid Time

func NewTime added in v1.4.0

func NewTime(hour int, minute int, second int, millisecond int) Time

NewTime creates a valid Time

func ParseTime

func ParseTime(s string) Time

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 TrueCourseOverGround added in v1.4.0

type TrueCourseOverGround interface {
	GetTrueCourseOverGround() (float64, error)
}

TrueCourseOverGround retrieves the true course over ground from the sentence

type TrueHeading added in v1.4.0

type TrueHeading interface {
	GetTrueHeading() (float64, error)
}

TrueHeading retrieves the true heading from the sentence

type TrueWindDirection added in v1.4.0

type TrueWindDirection interface {
	GetTrueWindDirection() (float64, error)
}

TrueWindDirection retrieves the true wind direction from the sentence

type VDMVDO added in v1.4.0

type VDMVDO struct {
	BaseSentence
	NumFragments   Int64
	FragmentNumber Int64
	MessageID      Int64
	Channel        String
	Payload        []byte
	ais.Packet
}

VDMVDO is a format used to encapsulate generic binary payloads. It is most commonly used with AIS data. https://gpsd.gitlab.io/gpsd/AIVDM.html

func (VDMVDO) GetCallSign added in v1.4.0

func (s VDMVDO) GetCallSign() (string, error)

GetCallSign retrieves the call sign of the vessel from the sentence

func (VDMVDO) GetDestination added in v1.4.0

func (s VDMVDO) GetDestination() (string, error)

GetDestination retrieves the destination from the sentence

func (VDMVDO) GetENINumber added in v1.4.0

func (s VDMVDO) GetENINumber() (string, error)

GetENINumber retrieves the ENI number of the vessel from the sentence

func (VDMVDO) GetETA added in v1.4.0

func (s VDMVDO) GetETA() (time.Time, error)

GetETA retrieves the estimated time of arrival from the sentence

func (VDMVDO) GetIMONumber added in v1.4.0

func (s VDMVDO) GetIMONumber() (string, error)

GetIMONumber retrieves the IMO number of the vessel from the sentence

func (VDMVDO) GetMMSI added in v1.4.0

func (s VDMVDO) GetMMSI() (string, error)

GetMMSI retrieves the MMSI of the vessel from the sentence

func (VDMVDO) GetNavigationStatus added in v1.4.0

func (s VDMVDO) GetNavigationStatus() (string, error)

GetNavigationStatus retrieves the navigation status from the sentence

func (VDMVDO) GetPosition2D added in v1.4.0

func (s VDMVDO) GetPosition2D() (float64, float64, error)

GetPosition2D retrieves the 2D position from the sentence

func (VDMVDO) GetRateOfTurn added in v1.4.0

func (s VDMVDO) GetRateOfTurn() (float64, error)

GetRateOfTurn retrieves the rate of turn from the sentence

func (VDMVDO) GetSpeedOverGround added in v1.4.0

func (s VDMVDO) GetSpeedOverGround() (float64, error)

GetSpeedOverGround retrieves the speed over ground from the sentence

func (VDMVDO) GetTrueCourseOverGround added in v1.4.0

func (s VDMVDO) GetTrueCourseOverGround() (float64, error)

GetTrueCourseOverGround retrieves the true course over ground from the sentence

func (VDMVDO) GetTrueHeading added in v1.4.0

func (s VDMVDO) GetTrueHeading() (float64, error)

GetTrueHeading retrieves the true heading from the sentence

func (VDMVDO) GetVesselBeam added in v1.4.0

func (s VDMVDO) GetVesselBeam() (float64, error)

GetVesselBeam retrieves the beam of the vessel from the sentence

func (VDMVDO) GetVesselLength added in v1.4.0

func (s VDMVDO) GetVesselLength() (float64, error)

GetVesselLength retrieves the length of the vessel from the sentence

func (VDMVDO) GetVesselName added in v1.4.0

func (s VDMVDO) GetVesselName() (string, error)

GetVesselName retrieves the name of the vessel from the sentence

func (VDMVDO) GetVesselType added in v1.4.0

func (s VDMVDO) GetVesselType() (string, error)

GetVesselType retrieves the type of the vessel from the sentence

type VHW added in v1.4.0

type VHW struct {
	BaseSentence
	TrueHeading            Float64
	MagneticHeading        Float64
	SpeedThroughWaterKnots Float64
	SpeedThroughWaterKPH   Float64
}

VHW contains information about water speed and heading

func (VHW) GetMagneticHeading added in v1.4.0

func (s VHW) GetMagneticHeading() (float64, error)

GetMagneticHeading retrieves the magnetic heading from the sentence

func (VHW) GetSpeedThroughWater added in v1.4.0

func (s VHW) GetSpeedThroughWater() (float64, error)

GetSpeedThroughWater retrieves the speed through water from the sentence

func (VHW) GetTrueHeading added in v1.4.0

func (s VHW) GetTrueHeading() (float64, error)

GetTrueHeading retrieves the true heading from the sentence

type VTG added in v1.4.0

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) GetMagneticCourseOverGround added in v1.4.0

func (s VTG) GetMagneticCourseOverGround() (float64, error)

GetMagneticCourseOverGround retrieves the magnetic course over ground from the sentence

func (VTG) GetSpeedOverGround added in v1.4.0

func (s VTG) GetSpeedOverGround() (float64, error)

GetSpeedOverGround retrieves the speed over ground from the sentence

func (VTG) GetTrueCourseOverGround added in v1.4.0

func (s VTG) GetTrueCourseOverGround() (float64, error)

GetTrueCourseOverGround retrieves the true course over ground from the sentence

type VWR added in v1.4.0

type VWR struct {
	BaseSentence
	Angle                        Float64
	LeftRightOfBow               String
	WindSpeedInKnots             Float64
	WindSpeedInMetersPerSecond   Float64
	WindSpeedInKilometersPerHour Float64
}

VWR - Relative (Apparent) Wind Speed and Angle

func (VWR) GetRelativeWindDirection added in v1.4.0

func (s VWR) GetRelativeWindDirection() (float64, error)

GetRelativeWindDirection retrieves the true wind direction from the sentence

func (VWR) GetWindSpeed added in v1.4.0

func (s VWR) GetWindSpeed() (float64, error)

GetWindSpeed retrieves wind speed from the sentence

type VesselBeam added in v1.4.0

type VesselBeam interface {
	GetVesselBeam() (float64, error)
}

VesselBeam retrieves the beam of the vessel from the sentence

type VesselLength added in v1.4.0

type VesselLength interface {
	GetVesselLength() (float64, error)
}

VesselLength retrieves the length of the vessel from the sentence

type VesselName added in v1.4.0

type VesselName interface {
	GetVesselName() (string, error)
}

VesselName retrieves the name of the vessel from the sentence

type VesselType added in v1.4.0

type VesselType interface {
	GetVesselType() (string, error)
}

VesselType retrieves the type of the vessel from the sentence

type WPL added in v1.4.0

type WPL struct {
	BaseSentence
	Latitude  Float64 // Latitude
	Longitude Float64 // Longitude
	Ident     String  // Ident of nth waypoint
}

WPL contains information about a waypoint location

type WaterTemperature added in v1.4.0

type WaterTemperature interface {
	GetWaterTemperature() (float64, error)
}

WaterTemperature retrieves the water temperature from the sentence

type WindSpeed added in v1.4.0

type WindSpeed interface {
	GetWindSpeed() (float64, error)
}

WindSpeed retrieves the wind speed from the sentence

type ZDA added in v1.4.0

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) GetDateTime added in v1.4.0

func (s ZDA) GetDateTime() (string, error)

GetDateTime retrieves the date and time in RFC3339Nano format

Jump to

Keyboard shortcuts

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