TPCANMSg could not be marshaled
Posted: Tue 22. Aug 2023, 12:02
Hi,
I'm using the PCAN-Basic lib in a c# application.
I need to send a NMT package with 2 bytes in the payload.
I configure the message like this
The compiler send me this error on the write calling
I'm using the PCAN-Basic lib in a c# application.
I need to send a NMT package with 2 bytes in the payload.
I configure the message like this
Code: Select all
void Send_NMT()
{
TPCANMsg CANMsg = new TPCANMsg();
CANMsg.DATA = new byte[2];
CANMsg.ID = 0x00;
CANMsg.LEN = 2;
CANMsg.MSGTYPE = TPCANMessageType.PCAN_MESSAGE_STANDARD;
CANMsg.DATA[0] = 0x01;
CANMsg.DATA[1] = 0X00;
SendMsgToSingleID(CANMsg);
}
private TPCANStatus SendMsgToSingleID(TPCANMsg CANMsg)
{
return PCANBasic.Write(m_PcanHandle, ref CANMsg);
}
The compiler send me this error on the write calling
Thanks for you helpType could not be mashaled because the length of an embedded array instance does not match the declared length in the layout