File: hdm.go

package info (click to toggle)
golang-github-adrianmo-go-nmea 1.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 900 kB
  • sloc: makefile: 15
file content (31 lines) | stat: -rw-r--r-- 886 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package nmea

const (
	// TypeHDM type of HDM sentence for vessel heading in degrees with respect to magnetic north
	TypeHDM = "HDM"
	// MagneticHDM for valid Magnetic heading
	MagneticHDM = "M"
)

// HDM is vessel heading in degrees with respect to magnetic north produced by any device or system producing magnetic heading.
// https://gpsd.gitlab.io/gpsd/NMEA.html#_hdm_heading_magnetic
//
// Format: $--HDM,xxx.xx,M*hh<CR><LF>
// Example: $HCHDM,093.8,M*2B
type HDM struct {
	BaseSentence
	Heading       float64 // Heading in degrees
	MagneticValid bool    // Heading is respect to magnetic north
}

// newHDM constructor
func newHDM(s BaseSentence) (Sentence, error) {
	p := NewParser(s)
	p.AssertType(TypeHDM)
	m := HDM{
		BaseSentence:  s,
		Heading:       p.Float64(0, "heading"),
		MagneticValid: p.EnumString(1, "magnetic", MagneticHDM) == MagneticHDM,
	}
	return m, p.Err()
}