forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hdm.go
31 lines (28 loc) · 881 Bytes
/
hdm.go
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) (HDM, 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()
}