Closed hulthe closed 6 months ago
How to handle signals that, when accounting for offset and factor, exceed the capacity of u64s? Currently they willl always be truncated to fit in a u64
Why not fall back to f64? Might produce a warning if desired.
Did some tests with overflowing u64s, and it looks like dbc-codegen doesn't handle those well for other reasons too x)
I'm thinking we leave it. Would like to get this merged.
Before this change, any signal with
offset != 0.0
andfactor != 1.0
would be represented as a float in the generated Rust.This change checks if factor and offset are integers. If so, the generated rust type is set to the smallest integer type that fits the value (accounting for offset and factor).
So a signal like this (8 bits, factor=2, offset=13) would be a u16:
Unresolved Questions
How to handle invalid values provided toset_<signal>
methods.I.e., what should happen if you provide0
to a signed integer signal with offset1
.