diff --git a/third_party/message/can_bus.go b/third_party/message/can_bus.go index a59d659..25f4d7b 100644 --- a/third_party/message/can_bus.go +++ b/third_party/message/can_bus.go @@ -203,31 +203,40 @@ const ( const ( CAN_CRC16_ATPREQ = 0x11021 + CAN_CRC32 = 0x04C11DB7 ) var ( crc16AtpReqTable []uint32 = nil + crc32CanTable []uint32 = nil ) func CanCreateCrcTable() { if crc16AtpReqTable == nil { crc16AtpReqTable = CreateCrcTable(CAN_CRC16_ATPREQ, 16, false) } + if crc32CanTable == nil { + crc32CanTable = CreateCrcTable(CAN_CRC32, 32, false) + } } func calculateAtpReqCrc16(data []byte) uint16 { crc := CrcTableBased(data, 16, 0, false, false, 0, crc16AtpReqTable) return uint16(crc) } +func calculateCanCrc32(data []byte) uint32 { + crc := CrcTableBased(data, 32, 0xFF_FF_FF_FF, false, false, 0, crc32CanTable) + return crc +} // CRC32A的校验范围是:报文+时间戳A func calculateDataRspCrc32A(data []byte) uint32 { - return 0 + return calculateCanCrc32(data) } // CRC32B的校验范围是:报文+时间戳B func calculateDataRspCrc32B(data []byte) uint32 { - return 0 + return calculateCanCrc32(data) } func calculateDataRspCrc32C(data []byte) uint32 { - return 0 + return calculateCanCrc32(data) } diff --git a/third_party/tcp/tcp_client.go b/third_party/tcp/tcp_client.go deleted file mode 100644 index e81963f..0000000 --- a/third_party/tcp/tcp_client.go +++ /dev/null @@ -1,41 +0,0 @@ -package tcp - -import "net" - -type client struct { - laddr *net.TCPAddr //local address - raddr *net.TCPAddr //remote address - con *net.TCPConn //tcp 连接 -} - -func (c *client) NewClientWithLocal(remoteAddr string, localAddr string) *client { - ra, raEr := net.ResolveTCPAddr("tcp", remoteAddr) - if raEr != nil { - panic(raEr) - } - c.raddr = ra - // - la, laEr := net.ResolveTCPAddr("tcp", localAddr) - if laEr != nil { - panic(laEr) - } - c.laddr = la - return c -} -func (c *client) NewClient(remoteAddr string) *client { - ra, raEr := net.ResolveTCPAddr("tcp", remoteAddr) - if raEr != nil { - panic(raEr) - } - c.raddr = ra - c.con.LocalAddr() - return c -} -func (c *client) Start() error { - con, e := net.DialTCP(c.raddr.Network(), c.laddr, c.raddr) - if e != nil { - return e - } - c.con = con - return nil -} diff --git a/third_party/tcp/tcp_server.go b/third_party/tcp/tcp_server.go deleted file mode 100644 index 4ae52b7..0000000 --- a/third_party/tcp/tcp_server.go +++ /dev/null @@ -1 +0,0 @@ -package tcp