msp-rs / multiwii_serial_protocol_v2.rs

A Multiwii Serial Protocol (MSP) implementation for Rust
4 stars 2 forks source link

parse msp v2 packet size as u16 instead of usize #16

Closed amfern closed 4 years ago

amfern commented 4 years ago

This caused trouble when cross compiling to arm

wucke13 commented 4 years ago

It should have been like this from the beginning. Also: For serialization, have a look over here: https://github.com/wucke13/mavlink-msp-bridge/blob/master/src/msp.rs#L405 For deserialization, over there: https://github.com/wucke13/mavlink-msp-bridge/blob/master/src/msp.rs#L456 and here https://github.com/wucke13/mavlink-msp-bridge/blob/master/src/msp.rs#L230

The read macro could easily be adjusted to not use the Read trait but instead do some slicing operation, maybe with an offset?

amfern commented 4 years ago

IIUC you propose to use the get! macro to avoid code duplication and use the size_of instead of specifying the size manually. I like this macro, makes the code more neat

wucke13 commented 4 years ago

I quite like my deser code, as it is also easy to convert to async. The only thing missing is the xor for V1 messages. And porting from Read/Write to something no_std friendly. Unfortunately I don't have the time to work on this soonish. For now your proposed change definitely goes into the right direction, so LGTM :smile: