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

Min/Max of 64-bit signals #56

Open Felix-El opened 1 year ago

Felix-El commented 1 year ago

When I create a unsigned 64-bit signal in the DBC (full range, no offset/scaling) the generated code fails to compile because the MAX constant has a value that exceeds u64 limits.

The issue seems to be:

This seems like a flaw in the design. Here are a few workarounds I can think of:

  1. If min / max are not interesting anyway and you can tweak the DBC, you can do that.
  2. dbc-codegen could add #[cfg(feature = "range_checked")] to the MIN and MAX constants so with range checking disabled at least there is no compilation error.

Has anyone else faced this issue before? Do you see a better way to work around the issue? I'm willing to spend time on this but need some guidance.