# Libcanard v0 dsdl\_compiler .uavcan to .h

**URL:** <https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948>\
**Category:** Libcanard\
**Created:** [September 28, 2020, 3:43am UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948 "2020-09-28T03:43:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![newcomer](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/n/e5b9ba/32.png) [@newcomer](https://forum.opencyphal.org/u/newcomer)\
**Post date:** [September 28, 2020, 3:43am UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/1 "2020-09-28T03:43:52Z")

</div>

What is the command to generate .h for libcanard v0?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [September 28, 2020, 2:37pm UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/2 "2020-09-28T14:37:23Z")

</div>

There is no DSDL compiler for Libcanard v0.

---

<div class="post-metadata">

**Author:** ![newcomer](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/n/e5b9ba/32.png) [@newcomer](https://forum.opencyphal.org/u/newcomer)\
**Post date:** [September 29, 2020, 1:46am UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/3 "2020-09-29T01:46:02Z")

</div>

I found it in ardupilot.

> **[archived-libcanard/dsdl\_compiler at master · ArduPilot/archived-libcanard](https://github.com/ArduPilot/archived-libcanard/tree/master/dsdl_compiler)**
>
> Minimal implementation of the UAVCAN protocol stack in C for resource constrained applications - ArduPilot/archived-libcanard

---

<div class="post-metadata">

**Author:** ![deekay](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@deekay](https://forum.opencyphal.org/u/deekay)\
**Post date:** [September 29, 2020, 12:50pm UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/4 "2020-09-29T12:50:51Z")

</div>

If you are using DSDL types with @union, pay attention to a small bug in the compiler that I found. In **init**.py. Se below. I noticed this because the tag size was not calculated correctly…

Row 330:  
`t.union = len(t.fields).bit_length()`

I needed to change to  
`t.union = (len(t.fields)-1).bit_length()`

Row 341-344:

```auto
if t.request_union:
        t.request_union = len(t.request_fields).bit_length()
  if t.response_union:
       t.response_union = len(t.response_fields).bit_length()

```

I changed to

```auto
if t.request_union:
    t.request_union = (len(t.request_fields)-1).bit_length()
if t.response_union:
    t.response_union = (len(t.response_fields)-1).bit_length()

```

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [September 29, 2020, 3:37pm UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/5 "2020-09-29T15:37:37Z")

</div>

While we’re at it, there is far more than one bug in that compiler, which is why we pulled it from upstream wholesale.

---

<div class="post-metadata">

**Author:** ![Mechatronikus](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/mechatronikus/32/834_2.png) [@Mechatronikus](https://forum.opencyphal.org/u/Mechatronikus)\
**Post date:** [June 24, 2021, 1:16pm UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/6 "2021-06-24T13:16:08Z")

</div>

What is the suggested way to do this nowadays?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [June 24, 2021, 1:31pm UTC](https://forum.opencyphal.org/t/libcanard-v0-dsdl-compiler-uavcan-to-h/948/7 "2021-06-24T13:31:01Z")

</div>

It mostly depends on your objectives. What are you building and what are the requirements? What programming language you are using? Where the end product is going to be integrated to?
