kplindegaard / smbus2

A drop-in replacement for smbus-cffi/smbus-python in pure Python
MIT License
243 stars 68 forks source link

read requests when over I2C_SMBUS_BLOCK_MAX #35

Closed cyphunk closed 5 years ago

cyphunk commented 5 years ago

I'm not entirely certain the reason for the I2C_SMBUS_BLOCK_MAX being 32 bytes and curious if I could investigate how to modify this. If you have suggestions of what requires this hard limit please let me know. I have some time to investigate. Currently trying to emulate an i2C touch screen that results in reads well over 32 bytes

thanks

kplindegaard commented 5 years ago

@cyphunk: smbus2 uses the drivers provided by the Linux kernel, and it's kind of difficult to bypass if you insist to use the read_i2c_block_data method. Explanation given for example here. Right off the bat I don't remember if that limitation is actually there in the SMBus specification, but it doesn't really matter as long as we're limited by the kernel driver's struct definition anyway.

However, doing i2c reads in larger chunks than 32 bytes is not a problem. Straight forward if don't need to provide an offset address where to start reading from, as a matter of fact. Just check out example 5 and 7 in the project readme.

cyphunk commented 5 years ago

I think indeed you are right about having to dig into smbus. I banged my head against pigpio (https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=236351). If I have another week I may dig further into smbus

thank you for the references!