Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the process for adding currently missing DSDL types. #96

Merged
merged 3 commits into from
Feb 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
aentinger marked this conversation as resolved.
Show resolved Hide resolved
--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.