Jump to content
tcumming

Who's keeping the battery i2c busy?

Recommended Posts

I'm trying to write a python script using the smbus module to manage the battery.

 

If I run i2cdetect 0, I get;

 

    WARNING! This program can confuse your I2C bus, cause data loss and worse!

I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  
 
The "UU" at 0x34 means it's unprobed, i.e., someone else is using it.
 
I noticed that the script that's going around uses i2cget with the force option (i.e., i2cget -y -f) and the script doesn't work w/o -f. This also suggests someone else is talking to the battery port at 0x34. I understand that you are misusing the i2c with the -f switch, and would rather find who's using it and so there's no conflict.
 
An lsmod shows no modules that I know of that would be talking to it, and there are no scripts running that should be talking to it.
 
I am attempting to write a python script using the smbus module, and it's giving me a, "Device or resource busy", meaning somebody somewhere has the battery port open. Who?
 
thx, tom

Share this post


Link to post
Share on other sites

There is a driver loaded in the kernel that gets information from the AXP209. You can force control of the i2c bus.

 

I searched the forums for AXP209 and came of with this.

 

You might find some useful information in there.

Share this post


Link to post
Share on other sites

Ah, yes. Thanks for that.

 

The better answer is to use the files in /sys/class/power_supply/{ac, battery}. In fact, the i2cget -f scripts that are going around seem to screw up the module that, "owns" the AXP209 i2c interface. If that's the case, the bash script that uses i2cget -f that's floating around should be tossed, and people warned NOT TO USE IT and use the /sys/class/power_supply/ac interface.

 

Thanks again!

 

tom

Share this post


Link to post
Share on other sites

 I had similar issue with my 9$ chip's i2c module axp209 (power management IC).


By default i2-tools/py-smbus module does not provide an option to forcefully open a i2c-device-address( for safe reasons). But i2get command gives option '-y' to read/write.


So i forked i2c-tools/py-smbus in github to allow python code also to have similar option. I have changed 3 lines in python module code.


One can see example of my modified python module code at py-smbus github.


This modified py-smbus modules can be used for raspberry also


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×