technocreatives / dbc-codegen

Generate Rust structs for messages from a dbc (CAN bus definition) file.
Apache License 2.0
48 stars 31 forks source link

fix duplicate enum names on multiplex messages #65

Closed linusharberg closed 9 months ago

linusharberg commented 9 months ago

Two enums would render with the same name, example below

BO_ 2365539326 Example: 8 SCC
 SG_ message2 m2 : 32|1@0+ (1,0) [0|1] ""  TCU
 SG_ message1 m1 : 39|16@0+ (0.01,0) [0|655.35] ""  TCU
 SG_ Multiplexor M : 23|16@0+ (1,0) [0|0] ""  TCU

VAL_ 2365539326 Multiplexor 1 "Message 1" 2 "Message 2" ;

Would render as:

pub enum ExampleMultiplexor {
        M1(ExampleMultiplexorM1),
        M2(ExampleMultiplexorM2),
}

pub enum ExampleMultiplexor {
        Message1,
        Message2,
} 

This fix will render as:

pub enum ExampleMultiplexorIndex {
        M1(ExampleMultiplexorM1),
        M2(ExampleMultiplexorM2),
}

pub enum ExampleMultiplexor {
        Message1,
        Message2,
}