This commit is contained in:
xzb 2023-11-27 09:14:20 +08:00
parent f66960b9f4
commit 0138e76481
3 changed files with 40 additions and 0 deletions

View File

@ -78,6 +78,12 @@ func Default() BtmCanetClient {
func (s *btmCanetClient) Start(bcm BtmCanetManager) {
s.bcm = bcm
cfg := s.bcm.GetBtmCanetConfig()
//测试用
cfg.Open = true
cfg.RemoteUdpPort = 5555
cfg.RemoteIp = "192.168.3.5"
cfg.LocalUdpPort = 6666
//
if !cfg.Open {
return
}

View File

@ -1,5 +1,10 @@
package message
import (
"fmt"
"strings"
)
// BtmStatusRspFrame BTM发往ATP的状态应答帧
type BtmStatusRspFrame struct {
//帧ID
@ -157,3 +162,18 @@ func (f *BtmStatusRspFrame) Encode() *CanetFrame {
cf.CanData = writer.(CanBusData).GetData()
return cf
}
func (f *BtmStatusRspFrame) String() string {
sb := strings.Builder{}
sb.WriteString(fmt.Sprintf("BtmStatusRspFrame ID1 = 0x%0x, ID2 = 0x%0x, ID3 = 0x%0x, ID4 = 0x%0x,",
f.FId.ID1, f.FId.ID2, f.FId.ID3, f.FId.ID4))
sb.WriteString(fmt.Sprintf("Dsn = %d", f.Dsn))
sb.WriteString(fmt.Sprintf(",BaliseCounter = %d", f.BaliseCounter))
sb.WriteString(fmt.Sprintf(",MessageCounter = %d", f.MessageCounter))
sb.WriteString(fmt.Sprintf(",PowerAmplifierOn = %t", f.PowerAmplifierOn))
sb.WriteString(fmt.Sprintf(",AtpReqCrcCheckWrong = %t", f.AtpReqCrcCheckWrong))
sb.WriteString(fmt.Sprintf(",PowerAmplifierFailure = %t", f.PowerAmplifierFailure))
sb.WriteString(fmt.Sprintf(",AntennaFault = %t", f.AntennaFault))
sb.WriteString(fmt.Sprintf(",DetailedCode = %d", f.DetailedCode))
sb.WriteString(fmt.Sprintf(",TkTimeA = %d", f.TkTimeA))
return sb.String()
}

View File

@ -1,5 +1,10 @@
package message
import (
"fmt"
"strings"
)
// BtmTimeSyncCheckFrame BTM发往ATP的时间校验帧
type BtmTimeSyncCheckFrame struct {
//帧ID
@ -17,6 +22,7 @@ func NewBtmTimeSyncCheckFrame(sn byte) *BtmTimeSyncCheckFrame {
FId: *NewCanFrameId(CAN_ADDR_RSP_ATP, CAN_ADDR_RSP_BTM, CAN_FRAME_TIME_SYNC_RSP, sn),
}
}
func (f *BtmTimeSyncCheckFrame) Decode(cf *CanetFrame) bool {
f.FId = cf.CanId
//
@ -100,3 +106,11 @@ func (f *BtmTimeSyncCheckFrame) Encode() *CanetFrame {
cf.CanData = writer.(CanBusData).GetData()
return cf
}
func (f *BtmTimeSyncCheckFrame) String() string {
sb := strings.Builder{}
sb.WriteString(fmt.Sprintf("BtmTimeSyncCheckFrame ID1 = 0x%0x, ID2 = 0x%0x, ID3 = 0x%0x, ID4 = 0x%0x,",
f.FId.ID1, f.FId.ID2, f.FId.ID3, f.FId.ID4))
sb.WriteString(fmt.Sprintf("T2 = %d", f.T2))
sb.WriteString(fmt.Sprintf(",T3 = %d", f.T3))
return sb.String()
}