Single bit extraction

Hi, i’m new to RealDash CAN, i want to extract only a single bit, for example if i have 1001000 and i want to extract only the value in bit position 4 (so the 1) how can i do that in Xml CAN? Because when i activate or deactivate the ASR on my car, the 4th bit change value from 1 to 0 or 0 to 1 and the other remain the same, but the car reuse the same address for door state, if i open the passenger door the 3th bit go to 1 and if i close go to 0, so i need only the bit of ASR otherwise i can’t extract anything because when realdash convert in dec there are a lot of different dec value.

I use Adapters (CAN/LIN) → CAN Analyzer

This is a basic example of how to read a single bit from the CAN frame. You need to replace offset and length to match the byte you are interested of:

<value name="BIT4" offset="0" length="1" units="bit" conversion="V>>3"></value>

When you specify units=“bit”, RealDash reads it as a on/off value reading the rightmost bit of the value. For that reason the conversion=“V>>3” uses a bit shift to move the ‘intersting’ bit to the right.

RealDash CAN XML documentation is here:

RealDash-extras/RealDash-CAN at master · janimm/RealDash-extras (github.com)

Tell me, ofset, I understood what shifts the bit, but how to specify a specific byte?

Typically CAN frame has 8 bytes, like

00 11 22 33 44 55 66 77

Offset determines which byte to start from the left. offset=“0” would indicate byte with value 00, offset=“1” byte with value 11 and so on.

1 Like

Edit: Forum is English only.

Tell me, is it possible to specify a certain number of bytes in xml somehow? I came across the fact that on one id there are about 5-7 data on the icons on the device

I’m not sure if I understand what you mean. The length attribute specifies number of bytes to read for that value.

I can’t do it with this id, for some reason I count the second number in a byte, but how do I specify the first?Not wearing a seat belt

Id10330058
Off B3 73 F3 00 08 00 00 00
On 33 73 F3 00 08 00 00 00

Bit 7 (128 ) is changing in the first byte i.e. 33 to B3 (in hex)

offset=“0” length=“1” units=“bit” conversion=“V>>7”

2 Likes

Thank you it’s working