Skip to content

Add can custom timing #166

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

Merged
merged 1 commit into from
Nov 18, 2022
Merged

Conversation

elotom
Copy link
Contributor

@elotom elotom commented Nov 17, 2022

It would be nice if we could set custom CAN timings. I'm working on a project which uses a non-standard one.

This change requires deriving PartialEq and Eq for twai_timing_config_t. I'll make an additional pull request for esp-idf-sys to fix the compilation issue.

src/can.rs Outdated
@@ -132,6 +133,7 @@ pub mod config {
triple_sampling: false,
..Default::default()
},
Timing::Custom(twai_timing_config_t) => twai_timing_config_t,
Copy link
Collaborator

@ivmarkov ivmarkov Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than exposing the ESP IDF C structure twai_timing_config_t can you implement a custom Rust structure - say - CustomTimingConfig and then also conversion implement code (might be just impl From<CustomTimingConfig> for twai_timing_config_t)?

Alternatively, and perhaps even better - you can implement the custom field members directly on the Custom variant of the Timing enum, and then impl From<Timing> for twai_timing_config_t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added the custom field members directly on the Custom variant.

@elotom elotom force-pushed the add-can-custom-timing branch from 3af7c7e to eec65c3 Compare November 18, 2022 12:14
@elotom elotom force-pushed the add-can-custom-timing branch from eec65c3 to f22556c Compare November 18, 2022 12:17
@ivmarkov
Copy link
Collaborator

Thanks!

@ivmarkov ivmarkov merged commit 0124676 into esp-rs:master Nov 18, 2022
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.

2 participants