forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vdmvdo.go
35 lines (31 loc) · 869 Bytes
/
vdmvdo.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
32
33
34
35
package nmea
const (
// TypeVDM type for VDM sentences
TypeVDM = "VDM"
// TypeVDO type for VDO sentences
TypeVDO = "VDO"
)
// VDMVDO is a format used to encapsulate generic binary payloads. It is most commonly used
// with AIS data.
// http://catb.org/gpsd/AIVDM.html
type VDMVDO struct {
BaseSentence
NumFragments int64
FragmentNumber int64
MessageID int64
Channel string
Payload []byte
}
// newVDMVDO constructor
func newVDMVDO(s BaseSentence) (VDMVDO, error) {
p := newParser(s)
m := VDMVDO{
BaseSentence: s,
NumFragments: p.Int64(0, "number of fragments"),
FragmentNumber: p.Int64(1, "fragment number"),
MessageID: p.Int64(2, "sequence number"),
Channel: p.String(3, "channel ID"),
Payload: p.SixBitASCIIArmour(4, int(p.Int64(5, "number of padding bits")), "payload"),
}
return m, p.Err()
}