File: rot.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-- 793 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 (
	// TypeROT type of ROT sentence for vessel rate of turn
	TypeROT = "ROT"
	// ValidROT data is valid
	ValidROT = "A"
	// InvalidROT data is invalid
	InvalidROT = "V"
)

// ROT is sentence for rate of turn.
// https://gpsd.gitlab.io/gpsd/NMEA.html#_rot_rate_of_turn
//
// Format: $HEROT,-xxx.x,A*hh<CR><LF>
// Example: $HEROT,-11.23,A*07
type ROT struct {
	BaseSentence
	RateOfTurn float64 // rate of turn Z in deg/min (- means bow turns to port)
	Valid      bool    // "A" data valid,  "V" invalid data
}

func newROT(s BaseSentence) (Sentence, error) {
	p := NewParser(s)
	p.AssertType(TypeROT)
	return ROT{
		BaseSentence: s,
		RateOfTurn:   p.Float64(0, "rate of turn"),
		Valid:        p.EnumString(1, "status valid", ValidROT, InvalidROT) == ValidROT,
	}, p.Err()
}