technocreatives / dbc-codegen

Generate Rust structs for messages from a dbc (CAN bus definition) file.
Apache License 2.0
43 stars 23 forks source link

Generate inital arbitrary implementation #15

Closed marcelbuesing closed 3 years ago

marcelbuesing commented 3 years ago

Addresses #12. For now it's really arbitrary still have to figure out how to generate those signals within a range.

marcelbuesing commented 3 years ago

Ok I am not sure whether the arbitrary crate was actually meant to produce meaningful arbitrary values with defined bounds. Would be great if someone else has some input on this.

killercup commented 3 years ago

I can look at it later today.

I see there is int_in_range and choose on Unstructured, so integers and enums should be okay. Making that work for floats… hm. I would probably get random bytes in a loop, and break if they are valid. Actually, you could do this for the whole structure -- try to parse the random data in a loop until it's valid.

marcelbuesing commented 3 years ago

Added the ranges for boolean values and integers but just taking the min value for floating values right now. I think there has to be some way to do arbitrary floats without a loop, within the range.

killercup commented 3 years ago

Sounds good to me. Let's merge this for now and improve on it later.