nmea

package module
v0.0.0-...-2931def Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 5 Imported by: 0

README

nmea decoder

only implements gptxt, gprmc, gpgll; dont rly plan on supporting more in the near future

pkg.go.dev

Documentation

Index

Constants

View Source
const PREFIX = "$"

Variables

View Source
var (
	ErrEmptyMessage = errors.New("[NMEA] empty message")
	ErrNoChecksum   = errors.New("[NMEA] no checksum")
)

Functions

func Checksum

func Checksum(str string) (sum uint8)

func ParseDate

func ParseDate(str string) (day, month, year int, err error)

func ParseDegreeMinute

func ParseDegreeMinute(str string, degchars int) (deg int, min float32, err error)

func ParseUTC

func ParseUTC(str string) (hour int, minute int, second int, secondf float32, err error)

Types

type EastWest

type EastWest uint8
const (
	East EastWest = iota
	West
)

type ErrInvalidChecksum

type ErrInvalidChecksum struct {
	Expected uint8
	Got      uint8
	Pkg      string
}

func (*ErrInvalidChecksum) Error

func (err *ErrInvalidChecksum) Error() string

type ErrInvalidFields

type ErrInvalidFields struct {
	*Message
}

func (*ErrInvalidFields) Error

func (err *ErrInvalidFields) Error() string

type ErrInvalidLength

type ErrInvalidLength struct {
	Expected int
	Got      int
}

func (*ErrInvalidLength) Error

func (err *ErrInvalidLength) Error() string

type ErrInvalidPrefix

type ErrInvalidPrefix struct {
	Field string
}

func (*ErrInvalidPrefix) Error

func (err *ErrInvalidPrefix) Error() string

type ErrInvalidType

type ErrInvalidType struct {
	Expected string
	Received string
}

func (*ErrInvalidType) Error

func (err *ErrInvalidType) Error() string

type ErrUnknownType

type ErrUnknownType struct {
	Type string
}

func (*ErrUnknownType) Error

func (err *ErrUnknownType) Error() string

type GPGLL

type GPGLL struct {
	LatitudeDegree int
	LatitudeMinute float32

	NorthSouth NorthSouth

	LongitudeDegree int
	LongitudeMinute float32

	EastWest EastWest

	UTCHour    int
	UTCMinute  int
	UTCSecond  int
	UTCSecondf float32

	Valid bool
}

func (*GPGLL) LatLon

func (msg *GPGLL) LatLon() (lat float64, lon float64)

func (*GPGLL) Parse

func (msg *GPGLL) Parse(m *Message) (err error)

func (*GPGLL) Pretty

func (m *GPGLL) Pretty() string

func (*GPGLL) Serialize

func (m *GPGLL) Serialize() string

func (*GPGLL) Type

func (m *GPGLL) Type() string

type GPRMC

type GPRMC struct {
	UTCHour    int
	UTCMinute  int
	UTCSecond  int
	UTCSecondf float32

	Valid bool

	LatitudeDegree int
	LatitudeMinute float32

	NorthSouth NorthSouth

	LongitudeDegree int
	LongitudeMinute float32

	EastWest EastWest

	Speed float32 // speed over ground knots
	COG   int     // course over ground in degree

	DateDay   int
	DateMonth int
	DateYear  int

	MagneticVariation   int
	MagneticVariationEW EastWest

	PositionMode PositionMode
}

func (*GPRMC) LatLon

func (msg *GPRMC) LatLon() (lat float64, lon float64)

func (*GPRMC) Parse

func (msg *GPRMC) Parse(m *Message) (err error)

func (*GPRMC) Pretty

func (m *GPRMC) Pretty() string

func (*GPRMC) Serialize

func (m *GPRMC) Serialize() string

func (*GPRMC) Time

func (msg *GPRMC) Time() (t time.Time)

func (*GPRMC) Type

func (m *GPRMC) Type() string

type GPTXT

type GPTXT struct {
	TotalMsg int // msgs in transmission
	MsgNum   int // this msgs id in said transmission
	Severity int // ??? 02 ig?

	Text string
}

func (*GPTXT) Parse

func (txt *GPTXT) Parse(m *Message) (err error)

func (*GPTXT) Pretty

func (txt *GPTXT) Pretty() string

func (*GPTXT) Serialize

func (txt *GPTXT) Serialize() string

func (*GPTXT) Type

func (txt *GPTXT) Type() string

type Message

type Message struct {
	Type     string
	Fields   []string
	Checksum uint8
}

func (*Message) GenChecksum

func (m *Message) GenChecksum() uint8

func (Message) Pretty

func (m Message) Pretty() (s string)

func (Message) Serialize

func (m Message) Serialize() (s string)

type NMEAMessage

type NMEAMessage interface {
	Type() string
	Serialize() string
	Parse(m *Message) error
	Pretty() string
}

func Parse

func Parse(str string) (m NMEAMessage, err error)

type NorthSouth

type NorthSouth uint8
const (
	North NorthSouth = iota
	South
)

type PositionMode

type PositionMode uint8
const (
	PositionNoFix PositionMode = iota
	PositionAutonomousGNSSFix
	PositionDifferentialGNSSFix
)

Directories

Path Synopsis
cmd
log command

Jump to

Keyboard shortcuts

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