8devices Community
https://www.8devices.com/community/

smbus problem with reading registries
https://www.8devices.com/community/viewtopic.php?f=13&t=972
Page 1 of 1

Author:  patryk_g [ 11 Oct 2016, 09:06 ]
Post subject:  smbus problem with reading registries

Hello,
I have strange problem with reading registries using python-smbus library. Im working with device that have two (important for me) registries (0x00 and 0x01). The problem is that "bus.read_byte_data(i2cAddr , 0x01)" returns always conntent of register 0x00 insted register 0x01. It is easy to see with simple python example:

#-----------------simple python example---------------------
import smbus
bus = smbus.SMBus(0)
i2cAddr = 0x23
register00 = bus.read_byte_data(i2cAddr , 0x00)
print register00
register01 = bus.read_byte_data(i2cAddr , 0x01)
print register01 # <--- print the same value as "print register00"
#-----------------simple python example---------------------

I have to mention that registries 0x00 and 0x01 have completely different meaning(0x00 is a status register, 0x01 is a commands register) and they should hold different values in most cases.
I tested the same program on RaspberryPi and it was working simply correct.

On the other hand tool i2cget in terminal on Carambola2 works properly. With "i2cget -y 0 0x23 0x00 c" i can read 0x00 register and with "i2cget -y 0 0x23 0x01 c" i can read also 0x01 register. So my question is what i must do to be able to read other register than 0x00 using "read_byte_data" function on Carambola2?

Below are some installed packages:
i2c-tools - 3.1.2-1
kmod-i2c-algo-bit - 4.1.23-1
kmod-i2c-core - 4.1.23-1
kmod-i2c-gpio - 4.1.23-1
kmod-i2c-gpio-custom - 4.1.23-2
python-smbus - 3.1.2-1


#uname -a
Linux Carambola2 4.1.23 #33 Mon Oct 10 13:09:36 UTC 2016 mips GNU/Linux

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/