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 bug with unsigned types and negative factors #78

Closed cpctaylo closed 4 months ago

cpctaylo commented 5 months ago

This PR fixes a bug in how the library chooses Rust types to represent signals.

We tried a DBC with a 16 bit unsigned signal with a factor of -1. This means the range of valid values is [-65535, 0]. But this confused the function scaled_signal_to_rust_int which chose i8 when it should have picked i32.

This PR will:

Happy to address any comments or change requests.