-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support msp version 2 #3
base: master
Are you sure you want to change the base?
Conversation
@amfern Are you interested in co-maintaining a Rust MSP library? |
@wucke13 Appreciate your review, and yes i am interested in co-maintaining, you can fork this project and i will submit this PR to you. as you wish. |
7de0fa7
to
3c04e7a
Compare
@wucke13 i am still working on updating this PR, so don't bother looking re-reviewing it yet |
@wucke13 finished updating the PR, see if there anything i missed, thanks |
@@ -12,6 +12,8 @@ extern crate alloc; | |||
|
|||
extern crate packed_struct; | |||
|
|||
extern crate crc_any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the use
style imports, anyhow this surely better fits the rest of the code the way it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just tried to make it work, not so proficient with rust to have opinion yet
pub fn packet_size_bytes_v2(&self) -> usize { | ||
9 + self.data.len() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rather unfulfilling. I would prefer to have the MspVersion enum in use to determine the actual size of package. However, the MSP version is currently not actually a part of a package...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, maybe create something like this https://github.com/magiclen/crc-any/blob/b3ab9f45eee99d47534707703e442246206ef105/src/lib.rs#L181 for MspPacket, but i rather keep this change out of this PR and create different one in the future
b6b357e
to
5a62e9d
Compare
MspParserState::FlagV2 => { | ||
// uint8, flag, usage to be defined (set to zero) | ||
self.state = MspParserState::CommandV2; | ||
self.packet_data = Vec::with_capacity(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks the code for no_std
. Consider static arrays internally and passing slices (&[u8]
) for input. Vec requires a heap, which is not given in no_std
without additional crates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packet_data
is already Vec<>
, so that means no_std is already broken.
also how do i go about validating no_std is working, i tried creating dummy project with #![no_std]
, similar to https://github.com/hashmismatch/packed_struct.rs/tree/master/packed_struct_nostd_tests. but it just won't compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should fork this repo, and address no_std in separate PR
af5e3b6
to
2e680a9
Compare
version 0.1.4 was released from different branch and no longer considred canon
extended the library to support msp v2 messages