dbc-codegen icon indicating copy to clipboard operation
dbc-codegen copied to clipboard

Implement multiplexed signals

Open marcelbuesing opened this issue 4 years ago • 3 comments

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.

marcelbuesing avatar Mar 19 '21 08:03 marcelbuesing

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) -> SignalXMultiplexed where 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.

marcelbuesing avatar Mar 19 '21 08:03 marcelbuesing

An example: http://socialledge.com/sjsu/index.php/DBC_Format#Multiplexed_Message

andresv avatar Mar 19 '21 08:03 andresv

I would also prefer enum variant.

andresv avatar Mar 19 '21 08:03 andresv