Getting mileage from can-bus works ok.
if (canId == 0x540) {
uint32_t odometer = (uint32_t)rxBuf[7] <<16;
odometer |= rxBuf[6]<<8;
odometer |= rxBuf[5];
Serial.println(odometer); //for test
Then need to make own can-frame to dash app, but it shows 0 there. I confirmed that all in XML which is needed for this is done right.
I want to print that what it is sending to an application to a serial monitor for testing and exclude possible errors in XML.
This to serial monitor:
void SendCANFramesToSerial()
{
byte buf[8];
buf[0] = (0xff);
buf[1] = (0xff);
buf[2] = (0xff);
buf[3] = (0xff);
buf[4] = (0xff);
buf[5] = ((odometer & 0xff);
buf[6] = ((odometer >> 8) & 0xff);
buf[7] = ((odometer >> 16) & 0xff);
These does not print correct value:
Serial.println(buf[5] + buf[6] + buf[7])
Serial.println(buf[5] & 0ff) + (buf[6] << 8) + (buf[7] << 16);