Newbie question: startbit and bitcount with bigendian

I’m trying to translate the bit positions I have in my DBC file to how startbit and bitcount has been implemented in Realdash CAN XML.

in Realdash are the bit’s numbered as the table below? for example if I was looking at offset=“4” and length=“1” this would be equivalent to startbit=“39” and bitcount=“8” or does it count left to right i.e. startbit=“32” and bitcount=“8”?

|0 | 7| 6| 5| 4| 3| 2| 1| 0|
|1 |15|14|13|12|11|10| 9| 8|
|2 |23|22|21|20|19|18|17|16|
|3 |31|30|29|28|27|26|25|24|
|4 |39|38|37|36|35|34|33|32|
|5 |47|46|45|44|43|42|41|40|
|6 |55|54|53|52|51|50|49|48|
|7 |63|62|61|60|59|58|57|56|

then based on the answer above, the next part of my question is; i’m trying to get a 12bit number, basically the second nibble for offset 4 and the value of offset 5, the DBC says bitpos=40 len=12, this means (in the above table) start at bit 40 and count back 12 (to 35)

I have tried this, but i’m not getting the correct value for RPM (I’m setting endianess=“big” for the frame)

> <value targetId="37" offset="4" length="2" conversion="((B4 &amp; 0xF &lt;&lt; 8) | B5) * 2"></value> <!-- RPM 40/12-->

if I have understood what I have already read in the forum’s this should be taking the value in byte 4, masking the last 4 digits, and then appending the value form byte 5 (bitOR), the *2 is the factor

I hope i’m on the right track I have already got loads of data in, i’m just struggling with any value greater than a single byte.

Hope this all makes sense, an oppogies if all this has been covered elsewhere, I did try looking!!

Thanks

Problem with the above example is that offset attribute indicates that we start reading data from 5th byte, but conversion refers to B4 and B5, which would be 5th and 6th byte from offset 4 overshooting the frame data.

I would try this differently. Your RPM data is in 12 bits of bytes offset 4 and 5. So lets read those two bytes as 16 bit value and mask uppermost 4 bits out from the value:

<value targetId="37" offset="4" length="2" conversion="V &amp; 0xFFF"></value> <!-- RPM -->

Thanks, That worked and I have been able to get the RPM value, However i’m still a bit confused on the explination

I was using offset="4"with length=“2” so I thought that meant read byte 4 and byte 5 hence using B4 and B5 in the conversion.

In the explianation you say offset=“4” indicates that we start reading data from 5th byte and B4 = 5th Byte and B5 = 6th Byte. I thought B4 was the same as offset 4,could you explain this a little more?

Sorry for being a pain!! I find I need examples to help me understand the methodologies

Thanks

Offset and length specifies where value is read from CAN frame.
Conversion then operates with data extracted from frame with offset and length.