雷达与VOBC协议解码,调整

This commit is contained in:
tiger_zhou 2024-01-23 10:19:41 +08:00
parent 5379bc11f3
commit 6b16afc7b3

View File

@ -24,15 +24,16 @@ type Radar struct {
Tail byte Tail byte
} }
type RadarData struct { type RadarData struct {
SourceData byte SourceData byte //接收源数据
valRange byte data uint16 //移位后的数据
valRange byte //数据取值范围
} }
type RadarState struct { type RadarState struct {
SourceState byte SourceState byte //原数据
Model string Model string // 天线模式
SyntheticalState string SyntheticalState string //综合状态
DirState string DirState string //方向状态
Dir string Dir string //方向
} }
func (r *Radar) Decode(data []byte) error { func (r *Radar) Decode(data []byte) error {
@ -147,7 +148,7 @@ func readSpeedOrCounter(buf *bytes.Buffer) *RadarData {
}*/ }*/
ss, _ := buf.ReadByte() ss, _ := buf.ReadByte()
limit, _ := buf.ReadByte() limit, _ := buf.ReadByte()
return &RadarData{SourceData: ss, valRange: limit} return &RadarData{SourceData: ss, valRange: limit, data: uint16(ss) << 8}
} }
func readRadarInnerData(buf *bytes.Buffer) (byte, byte) { func readRadarInnerData(buf *bytes.Buffer) (byte, byte) {