Having trouble with startbit and bitlength in my .xml files

My DBC file has a lot of values that don’t cleanly work with offset/length, but the ones that do are working fine.

An example of one of the many IDs I’m having trouble with is this:

1|10@0+ (0.1,0) ← this is the syntax I’m familiar with
startbit=1 | bitlength=10 @ big endian (scale,offset)

I’ve tried using:

\ \ What am I doing wrong?

For starters, bitlength should be bitcount. I think you have the same issue with big endian data as with this discussion:


Oops, I should have just copy-pasted. I was using bitcount though.

I’m not seeing the connection to the post you linked, but I might just be an idiot. How would I modify my above statement?

So I got a good value, but it was half of what I expected… not sure why but if you see something wrong with what I posted above let me know.

To help further, I would need to have more details of how your CAN frame data looks like and what are the bits you are trying to read from the frame. Try to use the CAN monitor to get a snapshot of frame values and pinpoint where the interesting data is.

Since the value with pedal at 100% = 0011 1110 1000, it makes sense the value should be v/10. I didn’t change the CAN monitor to BIG ENDIAN, so just reminding you. I highlighted the values that change in binary.


This is somewhat tricky as big endian to little endian bytes are in a ‘wrong side’ of each other. I think best way to handle this is to use individual bytes in conversion:

<frame id="0x204" endianess="big">
    <value targetId="42" offset="0" length="2" conversion="((B0 &amp; 0x3 &lt;&lt; 8) | B1) * 0.1"></value></frame>

In above example, I take value of first byte, mask it by 0x3 (use only lowest 2 bits), bitshift to the left by 8. Then I do bitwise or with second byte and apply 0.1 scale.

Hope this helps.

First off, this worked for this situation so thanks.

I’ve been adding more IDs and I think I had some issues due to the byte numbering.

If you use the example above and have offset 3, length 2, would you use “B3 | B4” or “B0 | B1”?

I changed to latter and it looks like my data is correct now. Just wanted to make sure I understand this because I’m going to try and modify the DBCtoXML conversion.

Also, a lot of people have asked for Ford XML files. I can send mine when I finish if you want to incorporate it. However, Ford modifies their CAN IDs slightly between models so it probably won’t work for all Fords.

Yes, offset=0 ↔ B0, offset=1 ↔ B1 …