Implement partial embedded_can 0.4 compatibility (id conversions, transmit, receive) #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relevant to #44. Was working with another third party crate that used embedded_can types and Id conversions in particular were a pain, so decided to jump in and try to add some support here.
In this PR:
From
andInto
embedded_can id types for fdcan id types. My initial approach was to actually type aliasembedded::can::{Id, StandardId, ExtendedId}
to their fdcan equivalents if the feature flag was enabled (branch here). This works as the types are drop-in replacements for each other, but feels a little risky and I couldn't make the docs generate cleanly. In my project, swapping to this version meant adding someinto()
s but didn't add any code size as the conversions are trivial and optimise away.transmit_frame()
andtransmit_preserve_frame()
functions which behave the same astransmit_frame()
andtransmit_preserve()
but accept anembedded_can::Frame
.receive_frame()
,receive0_frame()
andreceive1_frame()
functions which behave the same asreceive()
but construct a newembedded_can::Frame
-implementing type.Not in this PR:
embedded_can
doesn't yet support it. See CAN FD support rust-embedded/embedded-hal#578.embedded_can::Error
.