-
Notifications
You must be signed in to change notification settings - Fork 9
/
system.go
52 lines (45 loc) · 1.39 KB
/
system.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package rtcm3
import (
"encoding/binary"
"github.com/go-restruct/restruct"
)
// System Parameters
type Message1013 struct {
AbstractMessage
ReferenceStationId uint16 `struct:"uint16:12"`
Mjd uint16 `struct:"uint16"`
SecondsOfDay uint32 `struct:"uint32:17"`
MessageCount uint8 `struct:"uint8:5,sizeof=Messages"`
LeapSeconds uint8 `struct:"uint8"`
Messages []struct {
Id uint16 `struct:"uint16:12"`
SyncFlag bool `struct:"uint8:1,variantbool"`
TransmissionInterval uint16 `struct:"uint16"`
}
}
func DeserializeMessage1013(data []byte) (msg Message1013) {
restruct.Unpack(data, binary.BigEndian, &msg)
return msg
}
func (msg Message1013) Serialize() []byte {
data, _ := restruct.Pack(binary.BigEndian, &msg)
return data
}
// Unicode Text String
type Message1029 struct {
AbstractMessage
ReferenceStationId uint16 `struct:"uint16:12"`
Mjd uint16 `struct:"uint16"`
SecondsOfDay uint32 `struct:"uint32:17"`
Characters uint8 `struct:"uint8:7"`
CodeUnitsLength uint8 `struct:"uint8"`
CodeUnits string `struct:"[]byte,sizefrom=CodeUnitsLength"`
}
func DeserializeMessage1029(data []byte) (msg Message1029) {
restruct.Unpack(data, binary.BigEndian, &msg)
return msg
}
func (msg Message1029) Serialize() []byte {
data, _ := restruct.Pack(binary.BigEndian, &msg)
return data
}