DLC filed of CAN message Toradex CE Libraries

In Toradex CE Libraries v2.1 Can_Demo, data length of rx tCanMsg canBuf is set to 8 canBuf.dataLen = 8; However it is possible to receive any frame less than 8 even canBuf.dataLen is set to 8. data[8] is defined by struct tCanMsg, and it has fixed length of 8 bytes. So is it safe to leave canBuf.dataLen to 0 or non-initialed value for rx tCanMsg canBuf ?

The library will fail if the data you have received is bigger than canBuf.dataLen. So you should provide a size there. The canBuf.dataLen only provides a maximal size but not a minimal size. This means you can also receive packets that are smaller than canBuf.dataLen.

ok. Thanks.