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

Generate Clone and Copy traits for Multiplexor structures

Open utopalex opened this issue 1 year ago • 0 comments

Given a multiplexor structure such as

BO_ 850 ID352BMS_energyStatus: 8 VehicleBus
 SG_ BMS_multiplexor M : 0|2@1+ (1,0) [0|3] "" Vector__XXX
 SG_ BMS_energyBuffer m1 : 16|16@1+ (0.01,0) [0|655.35] "KWh"  Receiver
 SG_ BMS_energyToChargeComplete m1 : 48|16@1+ (0.02,0) [0|1310.7] "KWh"  Receiver
 SG_ BMS_expectedEnergyRemaining m1 : 32|16@1+ (0.02,0) [0|1310.7] "KWh"  Receiver
 SG_ BMS_fullChargeComplete : 7|1@1+ (1,0) [0|1] ""  Receiver
 SG_ BMS_idealEnergyRemaining m0 : 48|16@1+ (0.02,0) [0|1310.7] "KWh"  Receiver
 SG_ BMS_nominalEnergyRemaining m0 : 32|16@1+ (0.02,0) [0|1310.7] "KWh"  Receiver
 SG_ BMS_nominalFullPackEnergy m0 : 16|16@1+ (0.02,0) [0|1310.7] "KWh"  Receiver

dbc-codegen properly generates:

#[derive(Default)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub struct Id352bmsEnergyStatusBmsMultiplexorM0 { raw: [u8; 8] }

However, since it doesn't generate #[derive(Default, Copy, Clone)], I can't use this enum type directly in my multi-threaded code without running into "Id352bmsEnergyStatusBmsMultiplexorM0: Clone" is not satisfied. For other types, directly implementing a message, however these traits are generated.

I can manually add "Copy, Clone" traits and make the generated code works, but it breaks once I make a change to my DBC file.

Is there a good reason for this behaviour and some way to get around it, or could it be a new feature?

utopalex avatar Aug 14 '24 14:08 utopalex