jamesmunns / postcard

A no_std + serde compatible message library for Rust
Apache License 2.0
788 stars 76 forks source link

Document how to use CRC combined with COBS #117

Open FrozenDroid opened 8 months ago

FrozenDroid commented 8 months ago

Thanks for this crate. It looks really promising!

However, I'm running into a snag:
Serializing a message using COBS with included CRC is obvious; the deserialization is not at all.
CobsAccumulator only takes a T type parameter which is Deserialize, so I can't wrap any extra flavors in. I also haven't found a way on how to get a slice out of the accumulator. Using &[u8] or heapless::Vec as the T doesn't work; it always returns an empty slice.

tomhampshire commented 5 months ago

@FrozenDroid I'm trying to do exactly the same, serialize using COBS with included CRC, then deserialize using COBS with included CRC. Did you get this working? Would you be able to provide a working example, if so? Perhaps this example could then also be included in the repo docs.

jamesmunns commented 5 months ago

It's very possible that you can't use CobsAccumulator and CRC out of the box for the reasons mentioned here.

I might suggest copy and pasting and modifying CobsAccumulator into your project (it's only a few hundred lines) for now, though I would be happy to consider a version that handles flavors better for postcard 2.0! (cc #128)