Skip to content

Uavcan Serialization Rule Generator

TheLarsinator edited this page Jun 25, 2021 · 5 revisions

Uavcan Serialization Rule Generator

This class generates serialization rules that can be used to deserialize and serialize Uavcan frames. Using the parsed DSDL, a list of uavcan channels is generated for each message and service. All compound types are flattened so that the final serialization rule is purely made up of primitive datatypes or voids.

Uavcan Channel

A uavcan channel holds the information required to (de-)serialize a field in a uavcan frame.

Properties

  • BaseType, BaseType, The field datatype: INT, UINT, FLOAT, BOOL, VOID
  • Size, int, the size of the field in bits
  • FieldName, the full name of the field, including namespace and parent datatypes
  • IsDynamicArray, bool, indicates if it is a dynamic array
  • ArraySize, int, max elements in the dynamic array

Flattening

All compound t ypes are flattened when generating serialization rules. This results in rules only containing primitive datatypes, making serialization very straight forward.

Example

Consider the following stand-alone datatype, representing a PID controller. Filename: PIDController.1.0.uavcan

# PID Controller
float32 p_term
float32 i_term
float32 d_term

@sealed
@assert _offset_.max <= (64 * 8)     # One CAN FD frames max

and the following message for a cruise controller. Filename: 12.CruiseControl.1.0.uavcan

# Cruise control
PIDController.1.0 cruise_control_pid
@sealed
@assert _offset_.max <= (64 * 8)     # One CAN FD frames max

Flattening the Cruise Control message would result in a list of three uavcan channels, with basetype FLOAT, Size 32 and fieldname CruiseControl.cruise_control_pid_x_term

Clone this wiki locally