Skip to content

Commit

Permalink
Document the process for adding currently missing DSDL types. (#96)
Browse files Browse the repository at this point in the history
* Document the process for adding currently missing DSDL types.

This fixes #94.

* Streamline installation instructions for nunavut.

Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>

* Be consistent and always compile for any target endianness.

Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>
  • Loading branch information
aentinger and pavel-kirienko committed Feb 16, 2021
1 parent c7a3265 commit cdb0308
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,64 @@ bool transmitCanFrame(CanardFrame const & frame) {
```
### Contribution
Please take a look at the [wiki](https://github.com/107-systems/107-Arduino-UAVCAN/wiki) for notes pertaining development of `107-Arduino-UAVCAN`.
#### How to add missing wrappers
##### Step 1) Generate C header files from DSDL
**Option A) Use [nunavut/nnvg](https://github.com/UAVCAN/nunavut)**
* Install **nunavut**: `pip install nunavut` (you will need a functional [Python installation](https://docs.python.org/3/using/index.html))
* Get some DSDL
```bash
git clone https://github.com/UAVCAN/public_regulated_data_types
```
* Generate C header files from DSDL
```bash
nnvg --target-language c \
--pp-max-emptylines=1 \
--pp-trim-trailing-whitespace \
--target-endianness=any \
--enable-serialization-asserts \
--outdir public_regulated_data_types/uavcan-header \
public_regulated_data_types/uavcan

nnvg --target-language c \
--pp-max-emptylines=1 \
--pp-trim-trailing-whitespace \
--target-endianness=any \
--enable-serialization-asserts \
--lookup public_regulated_data_types/uavcan \
--outdir public_regulated_data_types/reg-header \
public_regulated_data_types/reg
```
**Option B) Use [nunaweb](http://nunaweb.uavcan.org/)**
##### Step 2) Copy generated C header files to [`src/types`](https://github.com/107-systems/107-Arduino-UAVCAN/tree/master/src/types)
```bash
types/reg/drone/physics/electricity/
├── Power_0_1.h
├── PowerTs_0_1.h
├── Source_0_1.h
└── SourceTs_0_1.h
```
##### Step 3) Fix include path in generated C header files by prefixing it with `<types/`
```diff
-#include <uavcan/file/Path_1_0.h>
+#include <types/uavcan/file/Path_1_0.h>
...
-#include <reg/drone/physics/electricity/Power_0_1.h>
+#include <types/reg/drone/physics/electricity/Power_0_1.h>
```
##### Step 4) Manually implement wrapper classes in [`src/wrappers`](https://github.com/107-systems/107-Arduino-UAVCAN/tree/master/src/wrappers)
```bash
wrappers/reg/drone/physics/electricity/
├── Power_0_1.hpp
├── PowerTs_0_1.hpp
├── Source_0_1.hpp
└── SourceTs_0_1.hpp
```
##### Step 5) Add the wrapper clases to [`src/ArduinoUAVCANTypes.h`](https://github.com/107-systems/107-Arduino-UAVCAN/blob/master/src/ArduinoUAVCANTypes.h)
```diff
+#include "wrappers/reg/drone/physics/electricity/Power_0_1.hpp"
+#include "wrappers/reg/drone/physics/electricity/PowerTs_0_1.hpp"
+#include "wrappers/reg/drone/physics/electricity/Source_0_1.hpp"
+#include "wrappers/reg/drone/physics/electricity/SourceTs_0_1.hpp"
```
##### Step 6) [Create PR](https://github.com/107-systems/107-Arduino-UAVCAN/pulls) to mainline your changes
Note: Only UAVCAN types listed in [public_regulated_data_types:master](https://github.com/UAVCAN/public_regulated_data_types) will be accepted into this repository.

2 comments on commit cdb0308

@nbelanger99
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good!

@aentinger
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nbelanger99 thank you! 😉

Please sign in to comment.