I am using the gateway with sockets (handshaking is disabled) i am receiving but sending doesn't work,
I have added a 2nd set of routes with handshaing and using virtual PCAN and PCAN View as a sniffer to see the messages.
I have a 3rd party software that's only works with PCAN USB( i am trying replace this Sofware with my own using Socket and PCAN Gateway).
when the 3rd party send the same message i am trying to send it works and i can see it in the PCAN view
When my software send the frame nothing comes up on PCAN view
The message has only one byte of data which is 0, the ID is 0x12081080
any tips on how to troubleshoot it,
this is the packet i am sending over UDP
Code: Select all
Name Value
packet {Length=36}
(0) &H00
(1) &H24 Length
(2) &H00
(3) &H02 Msg Type
(4) &H00
(5) &H00
(6) &H00
(7) &H00
(8) &H00
(9) &H00
(10) &H00
(11) &H00
(12) &HF6 TimeStamp
(13) &H64
(14) &H41
(15) &HEC
(16) &H00
(17) &HE2
(18) &HE2
(19) &H00
(20) &H00
(21) &H01 MsgLen
(22) &H00
(23) &H00
(24) &H12 CanID
(25) &H08 CanID
(26) &H10 CanID
(27) &H80 CanID
(28) &H00 Data
(29) &H00 Da
(30) &H00
(31) &H00
(32) &H00
(33) &H00
(34) &H00
(35) &H00
Code: Select all
Private Function BuildCANPacket(CanMsg As sCANMsg) As Byte()
' Calculate the length of the entire packet
Dim packetLength As UShort = 36 ' Length of the entire CAN frame packet (fixed length for CAN 2.0 A/B)
' Create the packet array with the correct size
Dim packet As Byte() = New Byte(packetLength - 1) {}
' Length field (2 bytes)
packet(0) = CByte((packetLength >> 8) And &HFF)
packet(1) = CByte(packetLength And &HFF)
' Message Type field (2 bytes) - Classic CAN frame type (0x80)
packet(2) = &H0
packet(3) = CanMsg.MsgType ' &H80
' Tag field (8 bytes) - Not used, set to 0
For i As Integer = 4 To 11
packet(i) = 0
Next
' Timestamp fields (8 bytes) - Current timestamp in microseconds
Dim timestamp As Long = DateTime.Now.Ticks \ 10 ' Convert ticks to microseconds
packet(12) = CByte((timestamp >> 24) And &HFF)
packet(13) = CByte((timestamp >> 16) And &HFF)
packet(14) = CByte((timestamp >> 8) And &HFF)
packet(15) = CByte(timestamp And &HFF)
packet(16) = CByte((timestamp >> 56) And &HFF)
packet(17) = CByte((timestamp >> 48) And &HFF)
packet(18) = CByte((timestamp >> 40) And &HFF)
packet(19) = CByte((timestamp >> 32) And &HFF)
' Channel field (1 byte) - Not used, set to 0
packet(20) = 0
' DLC field (1 byte) - Set to the length of the data
packet(21) = CByte(CanMsg.MsgLen)
' Flags field (2 bytes) - Assuming a standard frame with no RTR
packet(22) = 0
packet(23) = 0
' CAN ID field (4 bytes)
packet(24) = CByte((CanMsg.ID >> 24) And &HFF)
packet(25) = CByte((CanMsg.ID >> 16) And &HFF)
packet(26) = CByte((CanMsg.ID >> 8) And &HFF)
packet(27) = CByte(CanMsg.ID And &HFF)
' CAN Data field (8 bytes)
For i As Integer = 0 To CanMsg.MsgLen - 1 'Data.Length - 1
packet(28 + i) = CanMsg.MsgData(i)
Next
Return packet
End Function