dbc-codegen
dbc-codegen copied to clipboard
Implement multiplexed signals
Messages may contain multiplexed signals e.g.
MessageA: SignalA (Plain / Normal signal) Signal multiplexorX SignalY multiplexed by multiplexorX SignalZ multiplexed by multiplexorX
Basically this means here the multiplexorX indicates whether SignalY or SignalZ ist send as part of this frame. A "plain" signal is always included in the frame (not multiplexed). A message may contain zero, one or multiple multiplexors. Whether a signal is multiplexed or not is indicated by the MultiplexIndicator.
Designwise I think multiplexed signals can be represented in two ways:
- A function that returns an Option e.g. here
signal_y_raw(&self) -> Option<...> - A function that returns an Enum e.g. here
signal_x_raw(&self) -> SignalXMultiplexedwhere the SignalXMultiplexed enum would basically be Y or Z.
I think from an API perspective it's actually more convenient to use the enum variant as it makes it clear what signals are part of which multiplexor and saves some comparsions with Option values that can not even be Some.
An example: http://socialledge.com/sjsu/index.php/DBC_Format#Multiplexed_Message
I would also prefer enum variant.