File: query.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 (29 lines) | stat: -rw-r--r-- 740 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
package nmea

const (
	// TypeQuery type of Query sentence for a listener to request a particular sentence from a talker
	TypeQuery = "Q"
)

// Query sentences is special type of sentence for a listener to request a particular sentence from a talker.
// https://www.tronico.fi/OH6NT/docs/NMEA0183.pdf (page 3)
//
// Format: $ttllQ,sss*hh<CR><LF>
// Example: $CCGPQ,GGA*2B<CR><LF>
type Query struct {
	BaseSentence
	DestinationTalkerID string
	RequestedSentence   string
}

// newQuery constructor
func newQuery(s BaseSentence) (Sentence, error) {
	p := NewParser(s)
	p.AssertType(TypeQuery)

	return Query{
		BaseSentence:        s,
		DestinationTalkerID: s.Raw[3:5],
		RequestedSentence:   p.String(0, "requested sentence"),
	}, p.Err()
}