A tiny example of how to run a C-ITS stack on cube devices.
With the provided sources you have the necessary tools in your hands to run a C-ITS stack on devices such as the cube:evk. Of course, you can also avoid this trouble and simply use Vanetza ;-)
This project makes use of several cube APIs:
- cube:radio for receiving and transmitting V2X frames
- cube:ubx for fetching position data from the u-blox GNSS receiver
- cube:time for reading the current ITS timestamp
Each of these libraries is bundled as a CMake package with every cube device, so they can be easily integrated into projects using CMake's find_package mechanism.
The V2X radio can be operated either in "DSRC" (ITS-G5) or "C-V2X" (LTE) mode as controlled by the v2xconfig tool.
With cube:radio, the low-level interactions with the radio hardware are separated from user applications by means of UNIX domain sockets
Thus, user applications can focus on receiving and transmitting V2X frames as shown in radio.cpp.
Besides V2X frames, cube:radio also provides channel load measurements in the form of channel-busy-ratio samples.
The cube_radio_poll function enables user applications to wait for radio events efficiently, similar to the POSIX poll call.
Our cube devices have u-blox GNSS receivers on their boards, which communicate with the host system via the binary UBX protocol. The cube:ubx library grants user applications easy access to UBX frames sent by the GNSS receiver without having to parse the binary protocol manually.
Since multiple applications rely on the GNSS receiver, e.g. also the synchronization of the system clock, we run gpsd on cube:os by default.
As demonstrated by PositionSourceUbx found in position.cpp, user applications can connect to gpsd and retrieve UBX data from there with minimal effort.
As mentioned earlier, the cube's system clock is synchronized through GNSS. You can check the synchronization state with the cube-timectl command-line tool. The same information provided by this tool, e.g. the current TAI-UTC offset and ITS timestamp, can also be retrieved by user applications using the cube:time library.
In cube-tiny-stack we make use of cube:time when filling the ITS timestamp in V2X frames to be transmitted (see Communication::generate_transmission) and in check_its_clock showing the clock state at application start-up.