From: Alexey Starikovskiy <aystarik@gmail.com>
To: Yves-Alexis Perez <corsac@debian.org>
Cc: linux-acpi@vger.kernel.org, Evgeni Golov <evgeni@debian.org>
Subject: Re: Battery information in sysfs for userspace tools
Date: Sun, 17 May 2009 01:06:52 +0400 [thread overview]
Message-ID: <4A0F2AEC.9060802@gmail.com> (raw)
In-Reply-To: <1242374864.3992.15.camel@miria>
Yves-Alexis Perez wrote:
> Hi,
>
> Evgeni Golov (CC:ed) is currently taking care of fixing acpitool wrt.
> sysfs support (which is badly broken).
>
> Using the files in /sys/class/power_supply/BAT*/ we have some wondering
> about units.
>
> For the current rate, for example, we have:
>
> corsac@hidalgo: grep . /sys/class/power_supply/BAT0/*now
> /sys/class/power_supply/BAT0/current_now:14415000
> /sys/class/power_supply/BAT0/energy_now:44170000
> /sys/class/power_supply/BAT0/voltage_now:12481000
> corsac@hidalgo: grep . /sys/devices/platform/smapi/BAT0/*now
> /sys/devices/platform/smapi/BAT0/current_now:1151
> /sys/devices/platform/smapi/BAT0/power_now:14365
>
> I'm a bit puzzled with the differences in current_now (the battery is
> charging at that time), and don't really know if we can trust the units.
>
> I would assume (in /sys/class/power_supply):
> current_now to be in uA
> energy_now to be in uWh
> voltage_now to be in uV
>
> as said in include/linux/power_supply.h
>
> /*
> * All voltages, currents, charges, energies, time and temperatures in uV,
> * µA, µAh, µWh, seconds and tenths of degree Celsius unless otherwise
> * stated. It's driver's job to convert its raw values to units in which
> * this class operates.
> */
>
>
> and the current (dis)charging rate in W to be
> (current_now/1.000.000)*(energy_now/1.000.000). But that gives, for an
> end of charge, a charging rate of:
>
>
Currently, sysfs interface repeats brokenness of /proc/acpi/battery
interface.
it is possible to have battery info in energy units and charge units.
If you see 'energy_now' variable, then 'current_now' and more
appropriate 'power_now'
will report in uW units.
But if you have 'charge_now', then 'current_now' will report in uA
units, and you will not see 'power_now'.
So, in short, 'charge_now' reports in same units (sans *h) as capacity,
either 'charge_now' or 'energy_now'.
The proper way to handle it is to check for 'energy_now' and if it is
present, look for 'power_now'. It should be
present in 2.6.30 and later kernels (remaining time
energy_now/power_now). If it is not present (as in 2.6.29), then you
should assume that 'current_now' has value in uW, and remaining time is
energy_now/current_now.
If you have 'charge_now', remaining time is charge_now/current_now
without any complications.
Regards,
Alex.
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-05-16 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-15 8:07 Battery information in sysfs for userspace tools Yves-Alexis Perez
2009-05-16 21:06 ` Alexey Starikovskiy [this message]
2009-05-18 10:57 ` Yves-Alexis Perez
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=4A0F2AEC.9060802@gmail.com \
--to=aystarik@gmail.com \
--cc=corsac@debian.org \
--cc=evgeni@debian.org \
--cc=linux-acpi@vger.kernel.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.