We are trying to get the new TdxAllLibraryDll.dll working in C#. We have opened the port and we have a message appearing on our CAN monitor software, but we are unsure how to use the CAN-Write and CAN_Read functions.
We are using the can.tCanMsg structure to build our CAN message. Our sample code is as follows:
public static void Write(int CANPort, Char[] message, UInt32 messageID)
{
can.tCanMsg canMessage = new can.tCanMsg();
canMessage.data = message;
canMessage.dataLen = 8;
canMessage.id = messageID;
if (CANPort == 1 && canPort1 != IntPtr.Zero)
{
GCHandle handle1 = GCHandle.Alloc(canMessage);
IntPtr ptrMessage = (IntPtr) handle1;
uint ret = can.Can_Write(canPort1, ptrMessage, 1);
handle1.Free();
}
}
The version of the DLL is 2.0.0.3858.
Please help.