I am using toradexcelibraries_v1_7_3275. Within CAN demo,
DWORD CanRxProcess(HANDLE hCan)
{
INT i;
tCanMsg canBuf;
DWORD returnValue;
BYTE data[8] = {0}; // Rx buffer
// Configure timeout to 5 sec, by default it is set to 1 sec
Can_SetConfigInt(hCan, L"Timeout", 5000, StoreVolatile); // optional
// 3. Apply configuration to hardware
if (!Can_Open(hCan))
{
printf("CAN Rx Open failed\r\n");
return 0;
}
// 4. Use CAN
canBuf.dataLen = 8;
returnValue = Can_Read(hCan, &canBuf);
canBuf.dataLen is set to length of 8 bytes. Actually the received message is less than 8 bytes, but canBuf.dataLen is always 8. Although last bytes of canBuf.data are untouched.
Is it possible that canBuf.dataLen reflects real length of received CAN message by Can_Read() ? In CANOpen, can message length varies from 1 bytes to 8.