Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None unique field enums are not renamed #52

Open
wallem89 opened this issue Mar 24, 2023 · 2 comments
Open

None unique field enums are not renamed #52

wallem89 opened this issue Mar 24, 2023 · 2 comments

Comments

@wallem89
Copy link

I have a DBC file which has non unique field names in an enumerated signal. Example:

/// Defined values for Command
#[derive(Clone, Copy, PartialEq)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub enum CommandCommand{
    NotAvailable,
    Error,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Reserved,
    Release,
    Close,
    Open,
    Init,
    _Other(u8),
}

I know this is a bit strange but all none used enums are set to reserved. I could delete them so that _Other is handling those but renaming would be done as for the enums starting with a non-alphabetic character .

From DBC:

VAL_ 2566903515 Command 15 "Not Available" 14 "Error" 13 "Reserved" 12 "Reserved" 11 "Reserved" 10 "Reserved" 9 "Reserved" 8 "Reserved" 7 "Reserved" 6 "Reserved" 5 "Reserved" 4 "Reserved" 3 "Release" 2 "Close" 1 "Open" 0 "Init" ;

For now my workaround is to rename the Reserved enums in the DBC-file:

VAL_ 2566903515 Command 15 "Not Available" 14 "Error" 13 "Reserved_13" 12 "Reserved_12" 11 "Reserved_11" 10 "Reserved_10" 9 "Reserved_9" 8 "Reserved_8" 7 "Reserved_7" 6 "Reserved_6" 5 "Reserved_5" 4 "Reserved_4" 3 "Release" 2 "Close" 1 "Open" 0 "Init" ;

Which will give me unique enums:

/// Defined values for Command
#[derive(Clone, Copy, PartialEq)]
#[cfg_attr(feature = "debug", derive(Debug))]
pub enum CommandCommand{
    NotAvailable,
    Error,
    Reserved13,
    Reserved12,
    Reserved11,
    Reserved10,
    Reserved9,
    Reserved8,
    Reserved7,
    Reserved6,
    Reserved5,
    Reserved4,
    Release,
    Close,
    Open,
    Init,
    _Other(u8),
}

I could try to implement this myself and send in a PR but depends if you thinks this makes sense.

@JoNil
Copy link
Contributor

JoNil commented May 8, 2024

I have a pr for that in the can-dbc crate that would fix it when parsing: marcelbuesing/can-dbc#15

@killercup
Copy link
Member

Just saw @marcelbuesing wrote that this would be better done here. If you want to port the PR over here, I'd be happy to accept it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants