All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] Multiple Batteries
@ 2012-11-24  4:55 Justin Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Justin Brown @ 2012-11-24  4:55 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]

Hello,

I'm using Powertop 2.1, and I've noticed a somewhat minor bug. (I couldn't
find a public bug tracker, but would be more than happy to move this
discussion to one if someone could send me a URL.)

I have two batteries in my laptop, but Powertop does not recognize both
when calculating battery life remaining. For example Gnome-Shell reports
that my batteries are at 66% and 100% (85% combined) giving me 10 hours and
11 minutes of estimated time remaining. On the other hand, Powertop reports
just 3 hours 17  minutes of time. Both programs are reporting the proper
discharge rate. It just seems like Powertop is only using my smaller
battery (the currently active one).

I'm not sure if this issue has been reported, or if the developers even
have equipment with which to test. I'm more than willing to provide any
sort of debugging output or testing as needed. I could also probably create
a patch, but that's likely to take a lot longer for me to get setup with
development on this project.
It may be as simple as iterating over a directory in /sys/ or /proc to
gather stats on multiple batteries. An experienced dev might be able to fix
it quickly.

Cheers,
Justin

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 1321 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] Multiple Batteries
@ 2012-11-24 12:29 Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-11-24 12:29 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]

On (11/23/12 22:55), Justin Brown wrote:
>    Hello,
>    I'm using Powertop 2.1, and I've noticed a somewhat minor bug. (I couldn't
>    find a public bug tracker, but would be more than happy to move this
>    discussion to one if someone could send me a URL.)

Hello, Justin
thanks for reporting.

>    I have two batteries in my laptop, but Powertop does not recognize both
>    when calculating battery life remaining. For example Gnome-Shell reports
>    that my batteries are at 66% and 100% (85% combined) giving me 10 hours
>    and 11 minutes of estimated time remaining. On the other hand, Powertop
>    reports just 3 hours 17 �minutes of time. Both programs are reporting the
>    proper discharge rate. It just seems like Powertop is only using my
>    smaller battery (the currently active one).

can you please post files

cat /sys/class/power_supply/BAT0/uevent
cat /sys/class/power_supply/BAT1/uevent

while on battery.

thanks,
	-ss

>    I'm not sure if this issue has been reported, or if the developers even
>    have equipment with which to test. I'm more than willing to provide any
>    sort of debugging output or testing as needed. I could also probably
>    create a patch, but that's likely to take a lot longer for me to get setup
>    with development on this project.�
>    It may be as simple as iterating over a directory in /sys/ or /proc to
>    gather stats on multiple batteries. An experienced dev might be able to
>    fix it quickly.
>    Cheers,
>    Justin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] Multiple Batteries
@ 2012-11-24 12:50 Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-11-24 12:50 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]

On (11/23/12 22:55), Justin Brown wrote:
>    Hello,
>    I'm using Powertop 2.1, and I've noticed a somewhat minor bug. (I couldn't
>    find a public bug tracker, but would be more than happy to move this
>    discussion to one if someone could send me a URL.)
>    I have two batteries in my laptop, but Powertop does not recognize both
>    when calculating battery life remaining. For example Gnome-Shell reports
>    that my batteries are at 66% and 100% (85% combined) giving me 10 hours
>    and 11 minutes of estimated time remaining. On the other hand, Powertop
>    reports just 3 hours 17 �minutes of time. Both programs are reporting the
>    proper discharge rate. It just seems like Powertop is only using my
>    smaller battery (the currently active one).
>    I'm not sure if this issue has been reported, or if the developers even
>    have equipment with which to test. I'm more than willing to provide any
>    sort of debugging output or testing as needed. I could also probably
>    create a patch, but that's likely to take a lot longer for me to get setup
>    with development on this project.�
>    It may be as simple as iterating over a directory in /sys/ or /proc to
>    gather stats on multiple batteries. An experienced dev might be able to
>    fix it quickly.
>    Cheers,
>    Justin


can you please test the following patch?


----

power_supply rate could be 0.00, so we need to take care in power_meter::time_left() 
while perform dev_capacity()/joules_consumed() == inf operation.


Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

diff --git a/src/measurement/measurement.cpp b/src/measurement/measurement.cpp
index 4a33db9..f65cb0c 100644
--- a/src/measurement/measurement.cpp
+++ b/src/measurement/measurement.cpp
@@ -65,12 +65,13 @@ double power_meter::time_left(void)
 	if (cap < 0.001)
 		return 0.0;
 
-	left = cap / rate;
+	if (rate < 0.001)
+		rate = 1.0;
 
+	left = cap / rate;
 	return left;
 }
 
-
 vector<class power_meter *> power_meters;
 
 void start_power_measurement(void)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Powertop] Multiple Batteries
@ 2012-11-24 14:41 Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-11-24 14:41 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 2726 bytes --]

On (11/23/12 22:55), Justin Brown wrote:
>    Hello,
>    I'm using Powertop 2.1, and I've noticed a somewhat minor bug. (I couldn't
>    find a public bug tracker, but would be more than happy to move this
>    discussion to one if someone could send me a URL.)
>    I have two batteries in my laptop, but Powertop does not recognize both
>    when calculating battery life remaining. For example Gnome-Shell reports
>    that my batteries are at 66% and 100% (85% combined) giving me 10 hours
>    and 11 minutes of estimated time remaining. On the other hand, Powertop
>    reports just 3 hours 17 �minutes of time. Both programs are reporting the
>    proper discharge rate. It just seems like Powertop is only using my
>    smaller battery (the currently active one).
>    I'm not sure if this issue has been reported, or if the developers even
>    have equipment with which to test. I'm more than willing to provide any
>    sort of debugging output or testing as needed. I could also probably
>    create a patch, but that's likely to take a lot longer for me to get setup
>    with development on this project.�
>    It may be as simple as iterating over a directory in /sys/ or /proc to
>    gather stats on multiple batteries. An experienced dev might be able to
>    fix it quickly.
>    Cheers,
>    Justin


after a cup of coffee,
please ignore previous patch. let's start with this one.


Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>

---

 src/measurement/measurement.cpp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/measurement/measurement.cpp b/src/measurement/measurement.cpp
index 4a33db9..dcb9b65 100644
--- a/src/measurement/measurement.cpp
+++ b/src/measurement/measurement.cpp
@@ -65,12 +65,13 @@ double power_meter::time_left(void)
 	if (cap < 0.001)
 		return 0.0;
 
-	left = cap / rate;
+	if (rate < 0.001)
+		rate = 1.0;
 
+	left = cap / rate;
 	return left;
 }
 
-
 vector<class power_meter *> power_meters;
 
 void start_power_measurement(void)
@@ -101,12 +102,18 @@ double global_joules_consumed(void)
 
 double global_time_left(void)
 {
-	double total = 0.0;
+	double total_capacity = 0.0;
+	double total_rate = 0.0;
 	unsigned int i;
-	for (i = 0; i < power_meters.size(); i++)
-		total += power_meters[i]->time_left();
+	for (i = 0; i < power_meters.size(); i++) {
+		total_capacity += power_meters[i]->dev_capacity();
+		total_rate += power_meters[i]->joules_consumed();
+	}
 
-	return total;
+	if (total_rate < 0.001)
+		total_rate = 1.0;
+
+	return total_capacity/total_rate;
 }
 
 void sysfs_power_meters_callback(const char *d_name)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Powertop] Multiple Batteries
@ 2012-11-27  6:09 Justin Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Justin Brown @ 2012-11-27  6:09 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 5050 bytes --]

On Sat, Nov 24, 2012 at 8:41 AM, Sergey Senozhatsky <
sergey.senozhatsky(a)gmail.com> wrote:

> On (11/23/12 22:55), Justin Brown wrote:
> >    Hello,
> >    I'm using Powertop 2.1, and I've noticed a somewhat minor bug. (I
> couldn't
> >    find a public bug tracker, but would be more than happy to move this
> >    discussion to one if someone could send me a URL.)
> >    I have two batteries in my laptop, but Powertop does not recognize
> both
> >    when calculating battery life remaining. For example Gnome-Shell
> reports
> >    that my batteries are at 66% and 100% (85% combined) giving me 10
> hours
> >    and 11 minutes of estimated time remaining. On the other hand,
> Powertop
> >    reports just 3 hours 17 �minutes of time. Both programs are reporting
> the
> >    proper discharge rate. It just seems like Powertop is only using my
> >    smaller battery (the currently active one).
> >    I'm not sure if this issue has been reported, or if the developers
> even
> >    have equipment with which to test. I'm more than willing to provide
> any
> >    sort of debugging output or testing as needed. I could also probably
> >    create a patch, but that's likely to take a lot longer for me to get
> setup
> >    with development on this project.�
> >    It may be as simple as iterating over a directory in /sys/ or /proc to
> >    gather stats on multiple batteries. An experienced dev might be able
> to
> >    fix it quickly.
> >    Cheers,
> >    Justin
>
>
> after a cup of coffee,
> please ignore previous patch. let's start with this one.
>
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
>
> ---
>
>  src/measurement/measurement.cpp | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/src/measurement/measurement.cpp
> b/src/measurement/measurement.cpp
> index 4a33db9..dcb9b65 100644
> --- a/src/measurement/measurement.cpp
> +++ b/src/measurement/measurement.cpp
> @@ -65,12 +65,13 @@ double power_meter::time_left(void)
>         if (cap < 0.001)
>                 return 0.0;
>
> -       left = cap / rate;
> +       if (rate < 0.001)
> +               rate = 1.0;
>
> +       left = cap / rate;
>         return left;
>  }
>
> -
>  vector<class power_meter *> power_meters;
>
>  void start_power_measurement(void)
> @@ -101,12 +102,18 @@ double global_joules_consumed(void)
>
>  double global_time_left(void)
>  {
> -       double total = 0.0;
> +       double total_capacity = 0.0;
> +       double total_rate = 0.0;
>         unsigned int i;
> -       for (i = 0; i < power_meters.size(); i++)
> -               total += power_meters[i]->time_left();
> +       for (i = 0; i < power_meters.size(); i++) {
> +               total_capacity += power_meters[i]->dev_capacity();
> +               total_rate += power_meters[i]->joules_consumed();
> +       }
>
> -       return total;
> +       if (total_rate < 0.001)
> +               total_rate = 1.0;
> +
> +       return total_capacity/total_rate;
>  }
>
>  void sysfs_power_meters_callback(const char *d_name)
>
>

Sergey,

Thanks for the quick reply and patch.

I'm wondering if you can walk me through building PowerTop from source.
I've spent way too much time with Python and Ruby, and I don't know how to
build this project.

I've cloned the Git repository and applied your patch.
I'm having trouble generating "configure" from configure.ac.

$ autoconf configure.ac  > configure
configure.ac:13: error: possibly undefined macro: AC_LTDL_DLLIB
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:16: error: possibly undefined macro: AM_GNU_GETTEXT
configure.ac:17: error: possibly undefined macro: AM_GNU_GETTEXT_VERSION

I'm using Fedora 17.

I did install libtool-ltdl-devel, but that didn't have any effect. Sorry
for the newbie problem

Here is the battery information that you originally requested.

POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12465000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=43290000
POWER_SUPPLY_ENERGY_FULL=45240000
POWER_SUPPLY_ENERGY_NOW=45240000
POWER_SUPPLY_CAPACITY=100
POWER_SUPPLY_MODEL_NAME=45N1039
POWER_SUPPLY_MANUFACTURER=Panasonic
POWER_SUPPLY_SERIAL_NUMBER= 2913

POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
POWER_SUPPLY_VOLTAGE_NOW=11772000
POWER_SUPPLY_POWER_NOW=10971000
POWER_SUPPLY_ENERGY_FULL_DESIGN=31320000
POWER_SUPPLY_ENERGY_FULL=33700000
POWER_SUPPLY_ENERGY_NOW=27000000
POWER_SUPPLY_CAPACITY=80
POWER_SUPPLY_MODEL_NAME=45N1041
POWER_SUPPLY_MANUFACTURER=SONY
POWER_SUPPLY_SERIAL_NUMBER= 2106

Thanks,

Justin

[-- Attachment #2: attachment.html --]
[-- Type: text/html, Size: 6699 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Powertop] Multiple Batteries
@ 2012-11-27  7:35 Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2012-11-27  7:35 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 677 bytes --]

On (11/27/12 00:09), Justin Brown wrote:
>    Sergey,
>    Thanks for the quick reply and patch. 
>    I'm wondering if you can walk me through building PowerTop from source.
>    I've spent way too much time with Python and Ruby, and I don't know how to
>    build this project.
>    I've cloned the Git repository and applied your patch.
>

Sure,

we have "Building & Installing PowerTOP" section in README file.


please install required packages

autoconf
automake
m4

pciutils-devel (is only required if you have PCI) 
ncurses-devel  (required) 
libnl-devel    (required)


then

./autogen.sh 
./configure
make


hope it helps.


	-ss

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-27  7:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-24 14:41 [Powertop] Multiple Batteries Sergey Senozhatsky
  -- strict thread matches above, loose matches on Subject: below --
2012-11-27  7:35 Sergey Senozhatsky
2012-11-27  6:09 Justin Brown
2012-11-24 12:50 Sergey Senozhatsky
2012-11-24 12:29 Sergey Senozhatsky
2012-11-24  4:55 Justin Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.