tonton81 / FlexCAN_T4

FlexCAN (CAN 2.0 / CANFD) Library for Teensy 3.x and 4.0
https://forum.pjrc.com/threads/56035-FlexCAN_T4-FlexCAN-for-Teensy-4
MIT License
195 stars 65 forks source link

problem reading msg identifier #19

Closed leonardoBolzonella closed 3 years ago

leonardoBolzonella commented 3 years ago

Hello, I have been testing FlexCAN using a Teensy3.6 to send data to a custom ECU that uses a custom can code. I have changed the header file so that the msg.id is of type uint16_t, in order to match the custom can code. When a message is sent from the ECU with identifier 0x901 (1001 0000 0001), the teensy is reading id = 0x101 (001 0000 0001). I tried reverting to its original type (uint32_t) but nothing changed. Any idea why only 11 bits are being read in the id, instead of the 12 I was expecting?

I hope the question is clear, Cheers, Leo

tonton81 commented 3 years ago

try setting msg.flags.extended to 1 standard frames are 11bit extended frames are 29bit

no need to cast it to 16bit, just set it

msg.id = 0x901; msg.flags.extended = 1;

leonardoBolzonella commented 3 years ago

Thanks for the quick reply! Should it set it in the frame being sent or is it a setting for the CAN receiver code? Sorry if this sounds like an obvious question but this is my first time using CAN protocol.

tonton81 commented 3 years ago

sending

leonardoBolzonella commented 3 years ago

Worked, thank you!