[Gta04-owner] Detecting cable/discharing on USB

Radek Polak psonek2 at seznam.cz
Tue Apr 3 17:17:21 CEST 2012


Hi,
in the latest QtMoko i have added code that detects if GTA04 is plugged to USB 
and according to it, you can set suspend interval.

It's done by reading /sys/class/power_supply/twl4030_usb/status and checking 
for "Not charging" string. You can find the source here [1].

It works nice until the battery is fully charged. Then you start to get "Not 
charging" and QtMoko switches to "On Battery" mode and starts with suspending 
each 20s.

So the question. How to correctly detect On cable/On Battery? And btw after 
checking the battery charge, it was only like 70% full. I guess it would have 
completely discharged if i didnt replug the USB.

This is log from ssh:

radek at rp-core:~$ ssh root at 192.168.0.202
Linux neo 3.2.13-gta04+ #3 PREEMPT Sun Apr 1 13:55:21 UTC 2012 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jan  1 01:11:23 2000 from 192.168.0.200
root at neo:~# cat /sys/class/power_supply/twl4030_usb/status
Not charging
root at neo:~# cat /sys/class/power_supply/twl4030_usb/online 
0
root at neo:~# cat /sys/class/power_supply/twl4030_usb/current_now 
cat: /sys/class/power_supply/twl4030_usb/current_now: No data available

Regards

Radek

[1] 
https://github.com/radekp/qtmoko/blob/master/devices/gta04/server/neohardware.cpp


More information about the Gta04-owner mailing list