rts-sim-testing-service/third_party/axle_device/beijing12/msg/ssr.go

35 lines
1.0 KiB
Go
Raw Normal View History

package msg
import (
"bytes"
"encoding/binary"
"joylink.club/bj-rtsts-server/third_party/message"
)
type SsrMsg struct {
MsgHeader
SeqNumSsr uint32 // 应答方的序列号
SeqNumSse uint32 // 请求方的序列号
SeqInit1 uint32 // 时序初始化通道1 SEQENQ_1^SID_1^T_1(NR)^DATAVER_1
SeqInit2 uint32 // 时序初始化通道2 SEQENQ_2^SID_2^T_2(NR)^DATAVER_2
DataVer byte // 数据版本号 预留固定值0x01
Tail uint16 // 报文位 CRC16
}
func (s *SsrMsg) Encode() []byte {
data := s.MsgHeader.encode()
data = binary.LittleEndian.AppendUint32(data, s.SeqNumSsr)
data = binary.LittleEndian.AppendUint32(data, s.SeqNumSse)
data = binary.LittleEndian.AppendUint32(data, s.SeqInit1)
data = binary.LittleEndian.AppendUint32(data, s.SeqInit2)
data = append(data, s.DataVer)
s.Tail = message.Rssp_I_Crc16(data)
data = binary.LittleEndian.AppendUint16(data, s.Tail)
return data
}
func (s *SsrMsg) Decode(data []byte) error {
buf := bytes.NewBuffer(data)
return binary.Read(buf, binary.LittleEndian, s)
}