Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improved tokio async implementation#67

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

dlips
Copy link
Contributor

@dlipsdlips commentedJun 1, 2024
edited
Loading

Hello,

I was studying the tokio async implementation for theCanSocket/CanFdSocket and noticed that the implementation seems out of date compared to what the current tokio API offers (using theAsyncFd). Instead of having the intermediateEventedCanSocket wrapper, which implements a mio event source, I directly used the appropriate functions on theAsyncFd. I could not figure out why the mio event source was used as an intermediate wrapper. My only guess is that the code was merged from the tokio-socketcan crate, which wasn't updated for a long time, and was written against an older API of tokio/mio. If I am wrong here and the code was necessary for some reason, please let me know!

When working on it, I also added a new method for reading a single frame asynchronously, which was only possible through theStream trait before.

I added two new test for theread_frame functions ofCanSocket andCanFdSocket and renamed the old one to reflect that they use the Stream interface.

This PR includes a breaking change because the return type of thewrite_frame function changes, see code in the examples.

@fpagliughi
Copy link
Collaborator

fpagliughi commentedJun 1, 2024
edited
Loading

Awesome! Thanks you. I was meaning to look at this for a while now, but haven't haven't been able to find the time.

Your guess is correct: We had just merged in the oldtokio-socketcan crate, which hadn't been updated in a few years. So it definitely needed an update.

I'll test this out ASAP.

@dlips
Copy link
ContributorAuthor

I have seen that there is a std::io::{Read, Write} implementation for the sync CanSocket. Would it be beneficial to also have the corresponding AsyncRead and AsyncWrite implementation for tokio?

Futhermore I can move the tests for the tokio module to the integration tests folder like it is done for the async_io implementation. Is this ok?

@EliteTK
Copy link
Contributor

EliteTK commentedJun 5, 2024
edited
Loading

This is great!

It's a breaking change and if it gets considered I might as well make my change breaking.

To that end, I've included these commits in my PR so I can base my changes off of them.

Also:

I have seen that there is a std::io::{Read, Write} implementation for the sync CanSocket. Would it be beneficial to also have the corresponding AsyncRead and AsyncWrite implementation for tokio?

This would be wonderful as it would support doing atokio::io::copy and would make my life easier.

👍

Happy to keep rebasing my changes on top of anything which happens in this PR.

@dlips
Copy link
ContributorAuthor

dlips commentedJun 5, 2024
edited
Loading

I just pushed the implementation ofAsyncRead andAsyncWrite. I also added the missing implementation ofRead andWrite for the synchronousCanFdSocket as a separate commit. However, there are no tests for the sync implementation. But it is just a pass-through to the innersocket2::Socket, maybe its not necessary.

The tests for the tokio module could need some refactoring, and maybe moving to the tests folder because these are technically integration test.

Copy link
Collaborator

@fpagliughifpagliughi left a comment

Choose a reason for hiding this comment

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

LGTM

@fpagliughifpagliughi merged commit0663b93 intosocketcan-rs:masterAug 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fpagliughifpagliughifpagliughi approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@dlips@fpagliughi@EliteTK

[8]ページ先頭

©2009-2025 Movatter.jp