The read will always request 8 bytes of data even if there are only 2 bytes in the canbus messages.
This completely messes up the read comunication after a 2 byte data data package
it is like this
if(dtaLen <= 32)
{
CANI2C.beginTransmission(0x41);
CANI2C.write(canNum ? 0x17 : 0x07);
CANI2C.endTransmission();
CANI2C.requestFrom(0x41, 8);
for(int i=0; i<8; i++)
{
str[i]= CANI2C.read();
}
}
and it needs to be
if(dtaLen <= 32)
{
CANI2C.beginTransmission(0x41);
CANI2C.write(canNum ? 0x17 : 0x07);
CANI2C.endTransmission();
CANI2C.requestFrom(0x41, dtaLen);
for(int i=0; i<dtaLen; i++)
{
str[i]= CANI2C.read();
}
}
After this change I could use the CANBED dual in my sprinter to sniff the internal CANBUS's. before this changes it was even starting to think that there were extended CAN message on the CANBUS. Please fix this in your code, I am not the only one having this problem.