samcrow / canadensis

A Rust implementation of Cyphal
Apache License 2.0
44 stars 5 forks source link

BitArray encoding error #14

Closed chemicstry closed 2 years ago

chemicstry commented 2 years ago

I've been investigating weird boolean register behavior and I think that BitArray is improperly serialized.

I believe the array length is not being encoded as u16 here: https://github.com/samcrow/canadensis/blob/f4b8a91c2c687b1ea9a39a19071d45d7f26f28dc/canadensis_data_types/src/generated.rs#L8093

I've managed to manually patch it with cursor.write_aligned_u16(self.value.len() as u16); and it seems to work. However, I'm not really familliar with the codebase to regenerate the types and make a PR

samcrow commented 2 years ago

Thanks for reporting this. I'll investigate.

samcrow commented 2 years ago

I found a bug that caused the generated serialization code to not write the length field of a variable-length array of bits. That impacted the Bit type used in the register value type.

I published canadensis_data_types 0.2.2 with that issue fixed, and a new version of canadensis_codegen_rust that generates code without that bug.