[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Darwin support for lisp/battery.el.
From: |
Ken Raeburn |
Subject: |
Re: Darwin support for lisp/battery.el. |
Date: |
Mon, 4 Jul 2005 05:31:56 -0400 |
On Jul 4, 2005, at 03:39, Lute Kamstra wrote:
My patch tries to test whether pmset supports "-g ps" by looking at
the exit code. Does "pmset -g ps" return a non-zero exit code on your
system?
No, it looks like "pmset -g anything" will give a zero exit status; it
just doesn't print out anything unless you give it one of the supported
options. "pmset -g golf-ball" quite happily returns a zero exit
status.
Do you know of a way to get battery information on your system?
From the command line... not yet. From some poking around through
Google, it looks like the output of "ioreg -w0 -l | grep Capacity" may
have some or all of the data you'd want; I'm not sure yet.
I get:
| | | "IOBatteryInfo" = ({"Capacity"=4520,"Amperage"=0,"Cycle
Count"=139,"Current"=4278,"Voltage"=12368,"Flags"=1090519045,"AbsoluteMa
xCapacity"=5400})
| | | | "IOBatteryInfo" =
({"Capacity"=4520,"Amperage"=0,"Cycle
Count"=139,"Current"=4278,"Voltage"=12368,"Flags"=1090519045,"AbsoluteMa
xCapacity"=5400})
on AC current and
| | | "IOBatteryInfo" = ({"Capacity"=4520,"Amperage"=0,"Cycle
Count"=139,"Current"=4278,"Voltage"=12368,"Flags"=4,"AbsoluteMaxCapacity
"=5400})
| | | | "IOBatteryInfo" =
({"Capacity"=4520,"Amperage"=0,"Cycle
Count"=139,"Current"=4278,"Voltage"=12368,"Flags"=4,"AbsoluteMaxCapacity
"=5400})
on battery. (The leading vertical bars seem to be part of an ASCII
graphical diagram of a hierarchy of registry keys and values. "-w0"
seems to mean "width 0", i.e., don't truncate the output lines.)
The Flags field is described a little bit at
http://www.macosxhints.com/comment.php?
mode=display&sid=20030311220217671&title=Give+your+battery+a+thorough+ch
eckup&pid=0
as having value 0x004 on battery and 0x005 on AC (the value 1090519045
above is 0x41000005) and 0x08x or 0x09x values when power gets low. I
didn't find any mention of "battery" in the system header files, nor
any relevant mention of "power".
It also seems, from some of the other comments, that Current/Capacity
should be the current level of charge in the battery (so I'm at 94%,
kind of disappointing immediately after unplugging the power, but the
Mac GUI display agrees with it).
http://www.dssw.co.uk/sleepcentre/threads/
ioreg_bat_sh_was_re_10_3_6_what_.html
indicates that "ioreg -p IODeviceTree -n battery -w 0" may be a better
choice (it only produces 108 lines of output on my system, versus 4238
for "ioreg -l -w 0"), but the output still has to be filtered for the
IOBatteryInfo capacity line.
http://www.macosxhints.com/article.php?story=20030311220217671
has an awk script for reformatting the data, and a claim that
>> The results for "capacity" and "current" are in microamperes per
hour (mAh).
I always thought "mAh" was milliamp-hours (times hours, not per hour),
but some math suggests that 10**6 is probably the right scaling factor
in there somewhere.
I'm running 10.3.9, and at
http://www.mitt-eget.com/software/macosx/#battery it says that the
ioreg output format changed in 10.3.8, and again in 10.4, so parsing
this may be a little annoying. However, there's also a link to a
script which can parse the output, and comments describing what the
author thinks many of the flags are; following its logic shouldn't be
too hard. The tough part may be dealing with the amperage when it's
nonzero -- apparently it's a 64-bit value which can be negative, but is
displayed as unsigned. The emacs I've got on my system parses
"18446744073709549763" and comes up with "-1", when what we want is
"-1853".
I'll see if I can poke at this a little more, later...
Ken
- Re: Darwin support for lisp/battery.el., (continued)
- Re: Darwin support for lisp/battery.el., Richard M. Stallman, 2005/07/03
- Re: Darwin support for lisp/battery.el., David Kastrup, 2005/07/03
- Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/03
- Re: Darwin support for lisp/battery.el., David Kastrup, 2005/07/03
- Re: Darwin support for lisp/battery.el., Ken Raeburn, 2005/07/03
- Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/04
- Re: Darwin support for lisp/battery.el., Arne Jørgensen, 2005/07/04
- Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/04
- Message not available
- Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/04
- Re: Darwin support for lisp/battery.el.,
Ken Raeburn <=
- Re: Darwin support for lisp/battery.el., Ken Raeburn, 2005/07/04
- Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/06
- Re: Darwin support for lisp/battery.el., Sean O'Rourke, 2005/07/06
- Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/09
- Re: Darwin support for lisp/battery.el., Richard M. Stallman, 2005/07/04
- Re: Darwin support for lisp/battery.el., David Kastrup, 2005/07/04
- Re: Darwin support for lisp/battery.el., Richard M. Stallman, 2005/07/05
- Re: Darwin support for lisp/battery.el., Aidan Kehoe, 2005/07/05
Re: Darwin support for lisp/battery.el., Lute Kamstra, 2005/07/03