Jump to content


Photo

Who's keeping the battery i2c busy?


  • Please log in to reply
4 replies to this topic

#1 tcumming

tcumming

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 22 March 2015 - 09:00 PM

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


#2 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 22 March 2015 - 09:11 PM

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.



#3 tcumming

tcumming

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 23 March 2015 - 07:02 PM

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



#4 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 23 March 2015 - 07:45 PM

Your welcome. I have a python script floating around that reads some of what you want and would not be hard to extend it.

#5 gssmahadevan

gssmahadevan

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 14 August 2016 - 06:51 PM

 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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users