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

Transactional read/write via I2C_RDWR ioctl - take 2 #51

Merged
merged 6 commits into from
Nov 23, 2019

Conversation

eldruin
Copy link
Member

@eldruin eldruin commented Nov 8, 2019

This alternative is based on #50 but goes further and implements the I2CTransfer trait for I2CDevices.
With this proposal, it is possible to use the bus directly and send messages as well as send messages to a existing I2CDevice.
The most relevant change compared to #50 is in the I2CMessage trait, where the address has been separated into a separate method similar to with_flags() so that the same trait can be used for transfers with an I2CDevice without having to specify the address repeatedly as this is fixed for a given I2CDevice.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @posborne (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@eldruin eldruin changed the title Transactional read/write via I2CRWDR ioctl - alternative 1 Transactional read/write via I2CRWDR ioctl - take 2 Nov 8, 2019
@eldruin eldruin mentioned this pull request Nov 8, 2019
@eldruin eldruin changed the title Transactional read/write via I2CRWDR ioctl - take 2 Transactional read/write via I2C_RDWR ioctl - take 2 Nov 11, 2019
@eldruin
Copy link
Member Author

eldruin commented Nov 13, 2019

@andy-sdc confirmed that using this in the implementation of i2c::WriteRead in linux-embedded-hal solved the original issue (rust-embedded/linux-embedded-hal#25) and the hardware device works as expected with the driver.

@eldruin
Copy link
Member Author

eldruin commented Nov 18, 2019

Hi @posborne, did you have any chance to look at this?

@posborne
Copy link
Member

Hi @posborne, did you have any chance to look at this?

Sorry, will try to take a look later today, but bug me again if I haven't submitted a review by tomorrow.

@posborne posborne self-requested a review November 19, 2019 19:36
@eldruin
Copy link
Member Author

eldruin commented Nov 21, 2019

Hi @posborne, here is the reminder :)

src/ffi.rs Outdated Show resolved Hide resolved
src/ffi.rs Outdated

unsafe {
let n = ioctl::i2c_rdwr(fd, &i2c_data)?;
Ok(n as u32)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: move safe portions of code out of unsafe block.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Copy link
Member

@posborne posborne left a comment

Choose a reason for hiding this comment

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

Changes look very good overall. I left a couple nits to be cleaned up. I'll wait for those but otherwise, I'm happy moving forward with this and can give bors the go-ahead once those are in.

@eldruin
Copy link
Member Author

eldruin commented Nov 22, 2019

Great, I just fixed them.

@posborne
Copy link
Member

bors r+

@posborne
Copy link
Member

Ah, haven't set bors up on this one yet. Merging, thanks for the changes!

@posborne posborne merged commit 28c852d into rust-embedded:master Nov 23, 2019
bors bot added a commit to rust-embedded/linux-embedded-hal that referenced this pull request Nov 12, 2020
44: Implement transactional I2C interface and add example r=ryankurte a=eldruin

I implemented the transactional I2C interface from rust-embedded/embedded-hal#223 and added an example with a driver which does a combined Write/Read transaction.
This is based on previous work from #33 by @ryankurte, rust-embedded/rust-i2cdev#51 and is similar to #35.

Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
bors bot added a commit to rust-embedded/linux-embedded-hal that referenced this pull request Nov 14, 2020
44: Implement transactional I2C interface and add example r=ryankurte a=eldruin

I implemented the transactional I2C interface from rust-embedded/embedded-hal#223 and added an example with a driver which does a combined Write/Read transaction.
This is based on previous work from #33 by @ryankurte, rust-embedded/rust-i2cdev#51 and is similar to #35.

Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
bors bot added a commit to rust-embedded/wg that referenced this pull request Jan 24, 2021
533: Add eldruin to embedded linux team r=therealprof a=eldruin

I was approached by @ryankurte about joining the embedded linux team and I would be happy to.
So far I have contributed to `rust-i2cdev` and `linux-embedded-hal` adding support for transactional I2C among other smaller fixes. See:
- rust-embedded/rust-i2cdev#51
- rust-embedded/linux-embedded-hal#26

Other than that I guess everyone here knows me already.
Nevertheless, please feel free to raise any concerns.

Co-authored-by: Diego Barrios Romero <eldruin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants