雷达与VOBC协议解码,调整
This commit is contained in:
parent
7816c447fa
commit
5379bc11f3
20
third_party/message/radar.go
vendored
20
third_party/message/radar.go
vendored
@ -70,7 +70,7 @@ func (rd *RadarData) getSumVal() byte {
|
|||||||
return rd.SourceData + rd.valRange
|
return rd.SourceData + rd.valRange
|
||||||
}
|
}
|
||||||
func (s *RadarState) parseState() {
|
func (s *RadarState) parseState() {
|
||||||
//第6位 == SW_Mode0, 第7位 == SW_Mode1
|
//第7位 == SW_Mode0, 第6位 == SW_Mode1
|
||||||
// 11:两个天线和双通道都OK
|
// 11:两个天线和双通道都OK
|
||||||
// 10:DRS05_Single-Mode 40度,50度的天线或通道故障
|
// 10:DRS05_Single-Mode 40度,50度的天线或通道故障
|
||||||
// 01:DRS05_Single-Mode 50度,40度的天线或通道故障
|
// 01:DRS05_Single-Mode 50度,40度的天线或通道故障
|
||||||
@ -78,7 +78,7 @@ func (s *RadarState) parseState() {
|
|||||||
// 模式的工作差别:工作在11.模式时效果最好。单模式10或01时可信度下降。
|
// 模式的工作差别:工作在11.模式时效果最好。单模式10或01时可信度下降。
|
||||||
arr := s.getBitsStateArr()
|
arr := s.getBitsStateArr()
|
||||||
s.Model = bitStateStr(arr[6:])
|
s.Model = bitStateStr(arr[6:])
|
||||||
// 第3位=计算状态位,第4位=信号质量标志位,第5位=Black5out标志位
|
// 第5位=计算状态位,第4位=信号质量标志位,第3位=Black5out标志位
|
||||||
// 110:计算状态,高质量
|
// 110:计算状态,高质量
|
||||||
// 地面信号反射良好,高精度的信号计算
|
// 地面信号反射良好,高精度的信号计算
|
||||||
// 100: 计算状态,低质量
|
// 100: 计算状态,低质量
|
||||||
@ -98,20 +98,24 @@ func (s *RadarState) parseState() {
|
|||||||
s.Dir = bitStateStr(arr[0:1])
|
s.Dir = bitStateStr(arr[0:1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *RadarState) getBitsStateArr() []byte {
|
func (s *RadarState) getBitsStateArr() [8]byte {
|
||||||
bits := make([]byte, 8)
|
//bits := make([]byte, 8)
|
||||||
|
var bits2 [8]byte = [8]byte{}
|
||||||
for i := 0; i < 8; i++ {
|
for i := 0; i < 8; i++ {
|
||||||
bit := s.SourceState >> uint(i) & 1
|
bit := s.SourceState >> uint(i) & 1
|
||||||
bits[i] = bit
|
bits2[i] = bit
|
||||||
}
|
}
|
||||||
return bits
|
return bits2
|
||||||
}
|
}
|
||||||
|
|
||||||
func bitStateStr(data []byte) string {
|
func bitStateStr(data []byte) string {
|
||||||
var build = strings.Builder{}
|
var build = strings.Builder{}
|
||||||
for _, d := range data {
|
for i := len(data) - 1; i >= 0; i-- {
|
||||||
build.WriteString(fmt.Sprintf("%v", d))
|
build.WriteString(fmt.Sprintf("%v", data[i]))
|
||||||
}
|
}
|
||||||
|
/*for _, d := range data {
|
||||||
|
build.WriteString(fmt.Sprintf("%v", d))
|
||||||
|
}*/
|
||||||
return build.String()
|
return build.String()
|
||||||
}
|
}
|
||||||
func (r *Radar) checkTail() bool {
|
func (r *Radar) checkTail() bool {
|
||||||
|
47
third_party/message/radar_test.go
vendored
Normal file
47
third_party/message/radar_test.go
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package message
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRadar(t *testing.T) {
|
||||||
|
data := make([]byte, 0)
|
||||||
|
data = append(data, radar_head1) //0
|
||||||
|
data = append(data, radar_head2) //1
|
||||||
|
data = append(data, 1) //自增
|
||||||
|
data = append(data, 1) //速度3
|
||||||
|
data = append(data, 0) //4
|
||||||
|
data = append(data, 1) //s1 5
|
||||||
|
data = append(data, 0) //6
|
||||||
|
data = append(data, 1) //s2 7
|
||||||
|
data = append(data, 0) //8
|
||||||
|
data = append(data, 0) //内部使用 9
|
||||||
|
data = append(data, 0) //内部使用 9
|
||||||
|
data = append(data, createState())
|
||||||
|
var sum int
|
||||||
|
for _, s := range data {
|
||||||
|
sum += int(s)
|
||||||
|
}
|
||||||
|
data = append(data, byte(^sum+1))
|
||||||
|
radar := &Radar{}
|
||||||
|
radar.Decode(data)
|
||||||
|
fmt.Println(radar)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createState() byte {
|
||||||
|
var b byte = 0
|
||||||
|
b1 := b | (byte(1) << 7) | (byte(1) << 6) | (byte(1) << 5) | (byte(1) << 4) | (byte(1) << 1) | (byte(1) << 1)
|
||||||
|
return b1
|
||||||
|
}
|
||||||
|
func TestR1(t *testing.T) {
|
||||||
|
var b byte = 0
|
||||||
|
fmt.Printf("%08b\n", b)
|
||||||
|
//6,7位 11
|
||||||
|
//3,4,5位 011
|
||||||
|
// 1位 1
|
||||||
|
//0位 1
|
||||||
|
b1 := b | (byte(1) << 7) | (byte(1) << 6) | (byte(1) << 5) | (byte(1) << 4) | (byte(1) << 1) | (byte(1) << 0)
|
||||||
|
fmt.Printf("%08b\n", b1)
|
||||||
|
fmt.Println(b1)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user