Reply
Thread Tools
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#1
Is there a way to show the idle current drain using a .py or .sh script?
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#2
I found that QmBattery has an attribute 'getBatteryCurrent', but I don't know the syntax to extract this attribute in a python script.
Could someone give me an idea?
Thanks
 

The Following 2 Users Say Thank You to fhutt For This Useful Post:
Posts: 230 | Thanked: 302 times | Joined on Oct 2009 @ Helsinki, Suomi (Finland)
#3
Open terminal and run:
Code:
$ (sleep 20 && bmestat | grep "battery current" > idle_current.txt &)
Close the terminal and push the power button to idle the phone. Wait for 20 seconds. Then activate the phone and open terminal again to read the results:
Code:
$ cat idle_current.txt
Results are in mAh.
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#4
Thanks ladoga. This gives the result I need, but I would like it in a script without saving the result in a file.
I tried:
(bmestat | grep "battery current")
This gave me:
battery current: -213
I had the phone charging at the time. How do I now extract just the result (-213)?
Thanks
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#5
Originally Posted by fhutt View Post
Thanks ladoga. This gives the result I need, but I would like it in a script without saving the result in a file.
I tried:
(bmestat | grep "battery current")
This gave me:
battery current: -213
I had the phone charging at the time. How do I now extract just the result (-213)?
Thanks
(bmestat | grep "battery current") | awk '{print $3}'
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#6
This now got me what I needed.
Now, I need to put this into a script. Do I start with this?
eco -n "(bmestat | grep "battery current") | awk '{print $3}' "

It's hard to do this on the phone. I create the file on the pc and copy it to the phone. Very hard to debug.
I need the script to be fairly right.
Thanks
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#7
I tried:
#!/bin/sh
current = ((bmestat | grep "battery current") | awk '{print $3}' )
echo -n $current

I get a syntax error: unexpected "("

Could someone please help with this script?
Thanks
 
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#8
Maybe this line:
current = ((bmestat | grep "battery current") | awk '{print $3}' )
is too complicated for someone like me, who knows very little about sh or python.
But maybe split the job up into 3 smaller pieces would be easier:

#!/bin/sh
#Place the output of bmestat into string bmestring
bmestring = bmestat

#Extract the 'battery current' element out of the string in bmestring
element = ($bmestring | grep "battery current")

#Extract the numeric value out of element
current = ($element | awk '{prit $3}')
echo -n $current

Now you can see my lack of knowledge.
Maybe it would be easier in python.
Can someone please help put me out of my misery with this?
Thanks
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#9
Originally Posted by fhutt View Post
Maybe this line:
current = ((bmestat | grep "battery current") | awk '{print $3}' )
is too complicated for someone like me, who knows very little about sh or python.
But maybe split the job up into 3 smaller pieces would be easier:

#!/bin/sh
#Place the output of bmestat into string bmestring
bmestring = bmestat

#Extract the 'battery current' element out of the string in bmestring
element = ($bmestring | grep "battery current")

#Extract the numeric value out of element
current = ($element | awk '{prit $3}')
echo -n $current

Now you can see my lack of knowledge.
Maybe it would be easier in python.
Can someone please help put me out of my misery with this?
Thanks
Just one set of braces is enough

current=$(bmestat | grep "battery current" | awk '{print $3}' )
 

The Following User Says Thank You to juiceme For This Useful Post:
Posts: 49 | Thanked: 8 times | Joined on Oct 2013
#10
juiceme I get an error in the scrip-

current: not found

Should current be initialized first or something?
Thanks
 
Reply


 
Forum Jump


All times are GMT. The time now is 13:19.