obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
1.9 KiB
Title: Generate code from ASN.1
How to generate code from ASN.1 definitions
Generating new ASN.1 structs based on ASN.1 definitions can be a daunting task requiring the appropriate ASN.1 compiler. In particular, we use the asn1c fork maintained by mouse07410.
Though the Vanetza repository comes with various pre-generated ASN.1 messages, you may want to add further or revised versions of these messages. In this case, the following steps guide you how to generate code from ASN.1 definitions on your own.
Prerequisites
We have streamlined the process of installing and using asn1c by relying on a Docker container.
- Install Docker on your system
- Build the Docker container from the
vanetza/asn1/Dockerfileasvanetza-asn1c:latest
docker build --tag vanetza-asn1c:latest vanetza/asn1
Generate ASN.1 code
Our CMake build environment comes with a generate_asn1c code generation target.
This target is available if the the VANETZA_ASN1_WITH_ASN1C CMake option is enabled.
When you invoke this target, CMake will run the Docker container for you with suitable arguments.
You can specify a custom image by modifying the VANETZA_ASN1C_CONTAINER CMake cache variable.
By default, CMake will use the vanetza-asn1c:latest image.
- Update your copy of Vanetza with the new or updated ASN.1 definitions
- Update the CMakeLists.txt file at vanetza/asn1 accordingly
- Create a fresh build directory and configure CMake with enabled ASN.1 targets
- Invoke asn1c and compile Vanetza with newly generated code
# Create a new build directory at the project's root
mkdir build.asn1 && cd build.asn1
# Configure the build with enabled ASN.1 targets and retrieval of ISO ASN.1 files
cmake -DVANETZA_ASN1_WITH_ASN1C=ON -DVANETZA_ASN1_WITH_ISO=ON ..
# Invoke the target calling asn1c
make generate_asn1c
# Compile Vanetza with newly generated ASN.1 code
cmake --build .