# Single bit extraction

**URL:** <https://forum.realdash.net/t/single-bit-extraction/4377>\
**Category:** Adapters (CAN/LIN)\
**Created:** [December 26, 2023, 5:21pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377 "2023-12-26T17:21:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carot](https://forum.realdash.net/letter_avatar_proxy/v4/letter/c/779978/32.png) [@Carot](https://forum.realdash.net/u/Carot)\
**Post date:** [December 26, 2023, 5:21pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/1 "2023-12-26T17:21:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [December 27, 2023, 8:46am UTC](https://forum.realdash.net/t/single-bit-extraction/4377/2 "2023-12-27T08:46:19Z")

</div>

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:

```auto
<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)](https://github.com/janimm/RealDash-extras/tree/master/RealDash-CAN)

---

<div class="post-metadata">

**Author:** ![Jrasik](https://forum.realdash.net/user_avatar/forum.realdash.net/jrasik/32/779_2.png) [@Jrasik](https://forum.realdash.net/u/Jrasik)\
**Post date:** [December 28, 2023, 10:06pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/3 "2023-12-28T22:06:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [December 29, 2023, 7:25am UTC](https://forum.realdash.net/t/single-bit-extraction/4377/4 "2023-12-29T07:25:14Z")

</div>

Typically CAN frame has 8 bytes, like

```auto
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.

---

<div class="post-metadata">

**Author:** ![Jrasik](https://forum.realdash.net/user_avatar/forum.realdash.net/jrasik/32/779_2.png) [@Jrasik](https://forum.realdash.net/u/Jrasik)\
**Post date:** [December 29, 2023, 2:36pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/5 "2023-12-29T14:36:44Z")

</div>

Edit: Forum is English only.

---

<div class="post-metadata">

**Author:** ![Jrasik](https://forum.realdash.net/user_avatar/forum.realdash.net/jrasik/32/779_2.png) [@Jrasik](https://forum.realdash.net/u/Jrasik)\
**Post date:** [January 2, 2024, 5:52pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/6 "2024-01-02T17:52:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![realdashdev](https://forum.realdash.net/user_avatar/forum.realdash.net/realdashdev/32/6_2.png) [@realdashdev](https://forum.realdash.net/u/realdashdev)\
**Post date:** [January 3, 2024, 1:04pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/7 "2024-01-03T13:04:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jrasik](https://forum.realdash.net/user_avatar/forum.realdash.net/jrasik/32/779_2.png) [@Jrasik](https://forum.realdash.net/u/Jrasik)\
**Post date:** [January 5, 2024, 6:21pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/8 "2024-01-05T18:21:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mmain](https://forum.realdash.net/user_avatar/forum.realdash.net/mmain/32/651_2.png) [@mmain](https://forum.realdash.net/u/mmain)\
**Post date:** [January 8, 2024, 8:41am UTC](https://forum.realdash.net/t/single-bit-extraction/4377/9 "2024-01-08T08:41:10Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![Jrasik](https://forum.realdash.net/user_avatar/forum.realdash.net/jrasik/32/779_2.png) [@Jrasik](https://forum.realdash.net/u/Jrasik)\
**Post date:** [January 8, 2024, 8:24pm UTC](https://forum.realdash.net/t/single-bit-extraction/4377/10 "2024-01-08T20:24:28Z")

</div>

Thank you it’s working
