arduino-CAN icon indicating copy to clipboard operation
arduino-CAN copied to clipboard

Leading 0 are not printed

Open atkforever opened this issue 4 years ago • 1 comments

Leading 0 are not printed, for instance I should receive this data : 6000220100000000, instead I receive this : 6002210000.

I've modified the code as follows:

........ ........ ........ // only print packet data for non-RTR packets while (CAN.available()) { Serial.print(CAN.read(),HEX); ....... ....... ....... .

atkforever avatar Mar 09 '21 14:03 atkforever

For better and easier workfolw, Try to read out the raw buffer of the Can Controler.

I used the Pull from here:

https://github.com/deltaphi/arduino-CAN/tree/deltaphi/master

Declare array:

uint8_t CanB[8];

if (CAN.available()) { CAN.readBytes(CanB, 8); // 8 bytes

byte1 = CanB[0] byte2 = CanB[1]
byte3 = CanB[2]
byte4 = CanB[3]

.... etc }

Now you can declare a Array of your size and read all raw data.

maybe you are sending RTR packeds that get ignored?

Petros144 avatar Mar 09 '21 17:03 Petros144