kplindegaard / smbus2

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

i2c_rdwr(msg) performing read only operation #91

Open diegohernando opened 1 year ago

diegohernando commented 1 year ago

Hi there,

I can use i2c_rdwr(msg) method to implement a write only transaction, by passing just a msg argument create with the write method. Here I specify the i2c address, the command (reg address) and the data (flags).

I want to do something similar but just to read. I know when creating i2c_msg with read command I have to pass the i2c address and the length of the data to receive. How can I also specify the address of the register to read from? Is it by passing the flags argument too?

I'm trying to access the extended register map of a device (0xFEXX is the address of these registers). I was able to write to them, but I cannot read from them.

Many thanks in advance.

kplindegaard commented 1 year ago

Hi there. I didn't understand the full context of what you intend to do... Was it to read from a specific offset you meant? If it's an 8 bit offset, there are functions available such as read_byte_data and its siblings.