[修改]12号线联锁通信增加日志;
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m37s

[bug]12号线联锁驱动字节解析bug
This commit is contained in:
thesai 2024-06-06 18:40:48 +08:00
parent e7b7ff6781
commit c23c70ce05
3 changed files with 12 additions and 5 deletions

View File

@ -14,6 +14,10 @@ import (
"joylink.club/bj-rtsts-server/third_party/udp"
)
const (
logTag = "[北京12号线联锁通信]"
)
// 联锁代理通信接口
type InterlockMessageManager interface {
CollectInterlockRelayInfo(code string) *message.InterlockSendMsgPkg
@ -53,7 +57,7 @@ type interlockProxy struct {
// 驱动信息进行转发
func (i *interlockProxy) handleDriverInfo(b []byte) {
slog.Info(fmt.Sprintf("收到联锁驱动继电器数据:%x", b))
slog.Info(fmt.Sprintf("%s收到联锁驱动继电器数据:%x", logTag, b))
handler := i.manager
if handler != nil {
handler.HandleInterlockDriverInfo(i.runConfig.Code, b)

View File

@ -163,7 +163,7 @@ func (t *InterlockReceiveMsgPkg) Decode(buf []byte) error {
// 驱动数据
preIndex = lastIndex
lastIndex = lastIndex + t.et_out_num
t.parseByte(t.DriveInfo, buf, preIndex, lastIndex)
t.parseByte(buf, preIndex, lastIndex)
// 应答器报文
preIndex = lastIndex
lastIndex = lastIndex + t.tcc_output_len
@ -173,11 +173,11 @@ func (t *InterlockReceiveMsgPkg) Decode(buf []byte) error {
return nil
}
func (t *InterlockReceiveMsgPkg) parseByte(r []bool, buf []byte, start, end int) {
func (t *InterlockReceiveMsgPkg) parseByte(buf []byte, start, end int) {
for i := start; i < end; i++ {
b := buf[i]
for bit := 7; bit >= 0; bit-- {
r = append(r, (b&(1<<bit)) != 0)
t.DriveInfo = append(t.DriveInfo, (b&(1<<bit)) != 0)
}
}
}

View File

@ -457,7 +457,10 @@ func (s *VerifySimulation) HandleInterlockDriverInfo(code string, b []byte) {
continue
}
driverMsg := message.NewInterlockReceiveMsgPkg(0, len(m.QdList), len(m.TransponderId))
driverMsg.Decode(b)
err := driverMsg.Decode(b)
if err != nil {
slog.Error(fmt.Sprintf("联锁驱动数据解析失败:%s", err))
}
driveState := driverMsg.DriveInfo
for i, r := range m.QdList {
ds := driveState[i]