Skip to content
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

Implement partial embedded_can 0.4 compatibility (id conversions, transmit, receive) #56

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

projectgus
Copy link

@projectgus projectgus commented Oct 17, 2024

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:

  • Implements From and Into embedded_can id types for fdcan id types. My initial approach was to actually type alias embedded::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 some into()s but didn't add any code size as the conversions are trivial and optimise away.
  • Adds new transmit_frame() and transmit_preserve_frame() functions which behave the same as transmit_frame() and transmit_preserve() but accept an embedded_can::Frame.
  • Adds new receive_frame(), receive0_frame() and receive1_frame() functions which behave the same as receive() but construct a new embedded_can::Frame-implementing type.

Not in this PR:

  • Support for CAN-FD, as embedded_can doesn't yet support it. See CAN FD support  rust-embedded/embedded-hal#578.
  • Support for embedded_can::Error.
  • Support for trait Can. These require an associated type so IIUC not quite compatible with the current APIs. (Also, for my application I chose to split the structs into Rx and Tx so I didn't look that closely at these.)
  • Generated docs, apart from the one-liner. I'm not sure what the best practice around including feature-gated things like this in the crate docs are...?

… types.

Expand CI to build and test with and without the flag set.
- Implement Frame.into<TxFrameHeader>
- Add transmit_frame() & transmit_preserve_frame() for transmitting
  frames.
@projectgus
Copy link
Author

Marking as a draft because I haven't tested the receive functions yet.

@projectgus projectgus changed the title Add embedded_can 0.4 Id and transmit compatibility Implement partial embedded_can 0.4 compatibility (id conversions, transmit, receive) Oct 17, 2024
…::Frame.

Classic CAN only, as no CAN-FD support in embedded_can yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant