From: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] Multiple Batteries
Date: Sat, 24 Nov 2012 17:41:21 +0300 [thread overview]
Message-ID: <20121124144120.GC7100@swordfish> (raw)
In-Reply-To: CAKZK7uy6QP7xHvUpbhzz-Yh+SK2rBdzVNDcsBTgHG+=eiqGp4w@mail.gmail.com
[-- 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)
next reply other threads:[~2012-11-24 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-24 14:41 Sergey Senozhatsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-11-27 7:35 [Powertop] Multiple Batteries 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121124144120.GC7100@swordfish \
--to=powertop@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.