bitsToInt and bitsToUInt produce incorrect results

I am experiencing issues describing CAN messages using bitsToInt and bitsToUInt. I am following the bit numbering and length specified in the DBC file, but the results are incorrect.

To define the steering wheel angle, as shown in the example, I use: bitsToInt(raw, 3, 12) * 1.5 and the result is way off.

Example from the DBC file: https://drive.google.com/file/d/1nq_0XOoCuqhAkpSbnLLV28AfapJcEEpH/view?usp=sharing

I do not encounter any problems with CAN messages that span entire bytes, as I can use bytesToUInt in those cases.

Any ideas?

Comments

  • Hi @tonic

    The bits are indexed differently in the example you give. I believe this might be in RaceChrono as follows (latter half of the first byte, and second byte in full):
    bitsToInt(raw, 4, 12) * 1.5
Sign In or Register to comment.