Send CAN messages
Posted: Mon 4. Mar 2013, 12:20
Hello,
I have a PCAN-USB and a motor Maxon EPOS 24/1 and I am developing an interface on Visual Basic for the communication between them.
In addition to this I have a PCAN_USB.vb and my doubt is: How can I send a CAN message? Visual Basic creates an error because of TPCANMsg: I want send the DATA of CAN message as an array but is wrong and it's because I don't understand this part of the code:
<StructLayout(LayoutKind.Sequential, Pack:=1)> Public Structure TPCANMsg
Public ID As Integer ' 11/29 bit identifier
Public MSGTYPE As Byte ' Bits from MSGTYPE_*
Public LEN As Byte ' Data Length Code of the Msg (0..8)
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=8)> _
Public DATA As Byte() ' Data 0 .. 7
End Structure
function --> Write(ByRef msg As TPCANMsg)
I've defined a new variable as TPCANMsg:
Dim message_send As TPCANMsg
message_send.ID = 601
message_send.MSGTYPE = 0
message_send.LEN = 8
here DATA --> ???????
Thank you very much.
Regards.
I have a PCAN-USB and a motor Maxon EPOS 24/1 and I am developing an interface on Visual Basic for the communication between them.
In addition to this I have a PCAN_USB.vb and my doubt is: How can I send a CAN message? Visual Basic creates an error because of TPCANMsg: I want send the DATA of CAN message as an array but is wrong and it's because I don't understand this part of the code:
<StructLayout(LayoutKind.Sequential, Pack:=1)> Public Structure TPCANMsg
Public ID As Integer ' 11/29 bit identifier
Public MSGTYPE As Byte ' Bits from MSGTYPE_*
Public LEN As Byte ' Data Length Code of the Msg (0..8)
<MarshalAs(UnmanagedType.ByValArray, sizeconst:=8)> _
Public DATA As Byte() ' Data 0 .. 7
End Structure
function --> Write(ByRef msg As TPCANMsg)
I've defined a new variable as TPCANMsg:
Dim message_send As TPCANMsg
message_send.ID = 601
message_send.MSGTYPE = 0
message_send.LEN = 8
here DATA --> ???????
Thank you very much.
Regards.