diff --git a/third_party/can_btm/balise_btm.go b/third_party/can_btm/balise_btm.go index 52ba334..ef06e21 100644 --- a/third_party/can_btm/balise_btm.go +++ b/third_party/can_btm/balise_btm.go @@ -125,6 +125,32 @@ func (s *btmCanetClient) dealWithAptReq(f *message.CanetFrame) { } } +// BTM发送响应给ATP +// 当收到应答器报文时响应:时间同步帧、状态应答帧、数据帧 +// 当未收到应答器报文时响应:时间同步帧、状态应答帧 +func (s *btmCanetClient) rspToAtp() { + timeSyncF := message.NewBtmTimeSyncCheckFrame(s.atpReqSn) + timeSyncCf := timeSyncF.Encode().Encode() + statusF := message.NewBtmStatusRspFrame(s.atpReqSn) + //true-收到应答器报文 + //todo + isRcvTelegram := false + + if isRcvTelegram { //当收到应答器报文时响应:时间同步帧、状态应答帧、数据帧 + s.sendCanetFrame(timeSyncCf) + + } else { //当未收到应答器报文时响应:时间同步帧、状态应答帧 + statusCf := statusF.Encode().Encode() + s.sendCanetFrame(timeSyncCf) + s.sendCanetFrame(statusCf) + } +} + +// 发送Canet帧,一帧13字节 +func (s *btmCanetClient) sendCanetFrame(cf []byte) { + s.udpClient.Send(cf) +} + ////////////////////////////////////////////////////////////////////////////////////////// // 处理接收的状态应答帧 diff --git a/third_party/message/can_btm_rsp.go b/third_party/message/can_btm_rsp.go index 2ab9c44..2c2b06f 100644 --- a/third_party/message/can_btm_rsp.go +++ b/third_party/message/can_btm_rsp.go @@ -2,6 +2,8 @@ package message import "log/slog" +//BTM与ATP之间为双向通信,ATP(主)定时发送请求帧,BTM(从)在未接收到应答器报文时回复状态应答器帧和时间同步帧,在接收到应答器报文时回复所有帧 + // CreateBtmRspFramesData 数据帧与状态应答帧同时发送给ATP // 共17帧,17X12个字节,每个帧12字节 // msg - 应答器报文