smbus2
smbus2 copied to clipboard
Add read()/write() to the SMBus class
The i2c_rdwr() function is really nice as some kind of i2c transfers can only be achieved with it and not with other smbus available commands.
However, to use this function, one need knowledge of the i2c_msg class so it cannot decouple as much from the bus type as for the other smbus functions.
With these two new functions, a device class can receive a bus object and do simple reads and writes without having a hard coupling to this library by having to import i2c_msg.
See this example: https://github.com/fgervais/Si7021/commit/e0f407ca0c6f97c866ddfc2932c57796610917ee
In that case, the device class receives a bus instance and need no knowledge of the implementation other than the functions it needs to use on it.
I also think these functions can be a nice add-on in any case.
I hope this makes sense.
These I good requests, I will do the changes as soon as I put the setup back together for testing.
I use this code for my air conditioning control so I should get back to it in a few months as summer is coming for me.
Thanks
Works fine. Very useful for sending non-standard messages, or intentionally corrupted messages (negative testing).
The linked issue #63 indicates this PR is required for passing buffers larger than 32 bytes over i2c. That's not really the case as per earlier comments.