-
Notifications
You must be signed in to change notification settings - Fork 78
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
Remove alloc and bytes dependency #136
Conversation
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.
Some small things, this is a nice change overall
It is ready to review. |
Embedded example was been updated too. Cargo compile crc-any dependency with build-dependencies features for this example. Thus example can not been compiled due to alloc dependency. |
@qwerty19106 please check CI |
The cargo fmt errors are fixed. |
You need to rebase over master since the branch has conflicts now. |
7d606f6
to
868c854
Compare
868c854
to
ac358f8
Compare
Rebased |
We can let as it's for now, but for future PRs, you should apply the rustfmt changes on their specific commits. |
And thanks for the contribution! |
Mavlink can be used in no_std mode, for example for thumbv7em-none-eabihf target (Cortex-M microcontrollers).
Heap usage is very bad idea for microcontrollers. It introduces uncontrollable latency and unacceptable for some tasks such as motor control.
Mavlink frame has fixed size: up to 263 bytes for Mavlink V1, up to 280 bytes for Mavlink V2 (MAVLink Packet Format).
I replaced all std::Vec (alloc::Vec) to stack allocated heapless::Vec.
The struct bytes::BytesMut is no support no_std mode. Its API and code very requires on std::Vec.
Moreover BytesMut use BufMut API with chunk_mut method. Due to BytesMut::put_* and BytesMut::get_* methods use while cycle with code, which can not be optimized by compiler (loop unwinding). It is very slow.
Therefore I replace bytes::BytesMut on two small (320 lines summary) and fast structs Bytes and BytesMut with analoguous API.
I replaced all String usages to &'static str.
It is breaking changes, but it increase perfomance in std mode too.