package msg import ( "bytes" "encoding/binary" "joylink.club/bj-rtsts-server/third_party/message" ) type SseMsg struct { MsgHeader SeqNum uint32 // 序列号 SeqEnq1 uint32 //时序校正请求通道1 SID_1^T_1(NE) SeqEnq2 uint32 // 时序校正请求通道2 SID_2^T_2(NE) Tail uint16 //报文位 CRC16 } func (s *SseMsg) Encode() []byte { data := s.MsgHeader.encode() data = binary.LittleEndian.AppendUint32(data, s.SeqNum) data = binary.LittleEndian.AppendUint32(data, s.SeqEnq1) data = binary.LittleEndian.AppendUint32(data, s.SeqEnq2) s.Tail = message.Rssp_I_Crc16(data) data = binary.LittleEndian.AppendUint16(data, s.Tail) return data } func (s *SseMsg) Decode(data []byte) error { buf := bytes.NewBuffer(data) return binary.Read(buf, binary.LittleEndian, s) }