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

Ignore DBC internal message for unassigned signals #55

Closed hcsch closed 1 year ago

hcsch commented 1 year ago

VECTOR__INDEPENDENT_SIG_MSG is zero-size with non-zero-size signals, causing an error during codegen.

As the signals in this message are unassigned to any real message, just ignoring it is probably the way to go.

See also https://github.com/cantools/cantools/issues/62

hcsch commented 1 year ago

Sorry for the spam, I just noticed that I was still missing something after setting up the changed code to test with the DBC that I have. I'll mark this PR ready for review again once I've actually tested the code :)

killercup commented 1 year ago

Hi, sorry for the late response! This looks good, but I don't have a test file to check it. I'll merge it anyway :)

If you're still interested, could you add a simple test as a new PR to make sure this continues to work?

hcsch commented 1 year ago

I could add an example to testing/dbc-examples/example.dbc, if that's fine by you, though I don't currently have a use for this anymore as I ended up wanting to parse databases at runtime without recompilation.

VECTOR__INDEPENDENT_SIG_MSG messages kinda look like this, based on what I've seen:

BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX
 SG_ Unassigned0 : 0|32@1- (1.2345,0) [0|20000] "" Vector__XXX
 SG_ Unassigned3 : 0|16@1- (1,23450) [0|0] "" Vector__XXX
 SG_ Unassigned1 : 0|37@1- (-1,0) [-3000|0] "" Vector__XXX
 SG_ RandomSignal : 0|5@1- (1,0) [0|0] "" Vector__XXX

Basically just signals plucked out of other messages for later use in a real message again, but unused at the moment.