From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.devel Subject: Re: Darwin support for lisp/battery.el. Date: Mon, 4 Jul 2005 05:31:56 -0400 Message-ID: References: <8764vtxusp.fsf@xs4all.nl> <85mzp3a8am.fsf@lola.goethe.zz> <87d5pz8qoq.fsf@xs4all.nl> <851x6fa4pa.fsf@lola.goethe.zz> <87y88nvx36.fsf@xs4all.nl> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1120470643 29949 80.91.229.2 (4 Jul 2005 09:50:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2005 09:50:43 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 04 11:50:38 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DpNaa-0001CN-H1 for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2005 11:50:09 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DpNbm-0004Yb-R0 for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2005 05:51:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DpNKP-0007Yn-JR for emacs-devel@gnu.org; Mon, 04 Jul 2005 05:33:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DpNKN-0007Xs-2W for emacs-devel@gnu.org; Mon, 04 Jul 2005 05:33:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DpNKM-0007Xf-QA for emacs-devel@gnu.org; Mon, 04 Jul 2005 05:33:22 -0400 Original-Received: from [207.172.4.63] (helo=smtp04.mrf.mail.rcn.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DpNOp-0002y3-7n for emacs-devel@gnu.org; Mon, 04 Jul 2005 05:37:59 -0400 Original-Received: from 65-78-24-4.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com (HELO raeburn.org) (65.78.24.4) by smtp04.mrf.mail.rcn.net with ESMTP; 04 Jul 2005 05:32:02 -0400 X-IronPort-AV: i="3.93,255,1115006400"; d="scan'208"; a="54761608:sNHT64519010" Original-Received: from [18.101.0.226] (laptop.raeburn.org [18.101.0.226]) by raeburn.org (8.12.11/8.12.11) with ESMTP id j649W0q0009316; Mon, 4 Jul 2005 05:32:00 -0400 (EDT) In-Reply-To: <87y88nvx36.fsf@xs4all.nl> Original-To: Lute Kamstra X-Mailer: Apple Mail (2.622) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:40320 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40320 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