PMU daemon
I have extended my pmu daemon and Batmon to work on my new 1999 G3 powerbook. You can get it at ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz. It works on my old 3400 and I believe it should work on wallstreet powerbooks also.
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines
I have extended my pmu daemon and Batmon to work on my new 1999 G3 powerbook. You can get it at ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz.
I was going to ask you about the necessary magic :-) Thanks a lot!
Michael
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 6 lines · Paul Mackerras
I have extended my pmu daemon and Batmon to work on my new 1999 G3 powerbook. You can get it at ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz. It works on my old 3400 and I believe it should work on wallstreet powerbooks also.
Arg..
ncftpget ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz
Remote host has closed the connection.
ncftpget: cannot open ftp.linuxcare.com.au: remote host closed control connection.
Anyone got a mirror of this?
Signature · 7 lines
-------------------------------------------------------------------------- | Troy Benjegerdes | [email protected] | [email protected] | | Unix is user friendly... You just have to be friendly to it first. | | This message composed with 100% free software. http://www.gnu.org | -------------------------------------------------------------------------- ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines · Troy Benjegerdes
ncftpget ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz
Remote host has closed the connection.
ncftpget: cannot open ftp.linuxcare.com.au: remote host closed control connection.
Not again...
Fixed now.
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 11 lines · Paul Mackerras
Quoted 4 lines · Troy Benjegerdes
ncftpget ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz
Remote host has closed the connection.
ncftpget: cannot open ftp.linuxcare.com.au: remote host closed control connection.Not again...
Fixed now.
Thanks, I wound up getting a copy from someone else.
Now that I've had a chance to try it, I've got a couple of comments.
You have a typo at the end of 'pwrctl'.. pwrctl_3400 $i instead of pwrctl_3400 $1
I have a 3400 set up to use DHCP, and the pump client gets quite unhappy when the pwrctl scrips do the ifconfig up and ifconfig down. I changed the scripts to do 'ifup eth0' and 'ifdown eth0' so that the Red-hat style scripts are called instead, which take care of starting a stopping pump. This is also handy if you move to multiple places, and each has a DH CP server. Just close the lid, and when you open it back up, you'll automagically get a new working IP. Of course this plays havoc with any open connections, or using the machine as a server, but I would suspect very few (if any) powerbook users leave open connections or use the machine as a server.
Is there a way to read the battery voltage from the console using pmud?
Finally, does anyone know how feasable it would be to make pmud have the same API as the intel-ish APMD, since there are a bunch of nice X apps/applets for various window managers that talk to APMD?
Signature · 7 lines
-------------------------------------------------------------------------- | Troy Benjegerdes | [email protected] | [email protected] | | Unix is user friendly... You just have to be friendly to it first. | | This message composed with 100% free software. http://www.gnu.org | -------------------------------------------------------------------------- ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
(simple /proc/apm support for pmud) Re: PMU daemon
Quoted 5 lines · Troy Benjegerdes
[...]
Finally, does anyone know how feasable it would be to make pmud have the same API as the intel-ish APMD, since there are a bunch of nice X apps/applets for various window managers that talk to APMD?
Well, I threw together a quick patch to pmud that does this. Here is the message that I sent to Paul Mackerras the other day.
From: David King <[email protected]>
To: [email protected]
Subject: /proc/apm compatability using pmud (patch)
Hi,
pmud-0.2 has been working great on my Lombard 333. The only feature that I have missed is the ability to use the apm battery monitoring utilities (Batmon is nice but I'd like something in my windowmaker dock).
This patch extends pmud to update a apm formated file with every polling pass. I have managed to compile and use both wmbattery and wmapm by just changing the /proc/apm path to /var/spool/pmud/apm.
This isn't exactly clean - the thresholds are hard-coded, it does not correctly handle multiple batteries with the exception of time remaining, does not handle the 3400 style battery lookup, and it does not handle updating the remaining time when recharging - but it does work.
My original plan was to add this functionality to pmud and then move it into the kernel as /proc/apm but this works well enough for me that I'm not going to worry about it for now.
My next plan is to write a apm command which talks with pmud's telnet port. This should enable the sleep functionality of wmapm and some other tools (they generally just do a system call to apm to force a sleep).
Thanks for the wonderful work,
-David
*** pmud.c.19991021 Sun Sep 26 05:31:57 1999
--- pmud.c Fri Oct 22 13:51:22 1999
***************
*** 29,34 ****
--- 29,40 ----
#define PMUD_VERSION "0.2"
+ #define APMFILE "/var/spool/pmud/apm"
+ #define APMFAKEFLAGS 0x02
+ #define APMCRITICAL 10
+ #define APMLOW 30
+ #define APMSEC2MINTHRESHOLD 600
+
#define POWERLEVEL_SCRIPT "/sbin/pwrctl"
#define POWER_FILE "/etc/powerlevels"
#define PORT 879
***************
*** 310,315 ****
--- 316,342 ----
struct timeval now;
int timeleft = -1;
+ #ifdef APMFILE
+ static FILE *fapm = NULL;
+ struct pmu_apm_compat {
+ int ac_avail; + int battery_status; + int battery_flags; + int remain_percent; + int remain_time; + char* time_unit;
+ } pac;
+
+ /* init structure */
+ pac.ac_avail = 0;
+ pac.battery_status = 0;
+ pac.battery_flags = 0;
+ pac.remain_percent = 0;
+ pac.remain_time = 0;
+ pac.time_unit = "sec";
+
+ #endif
+
if (pmu_op(PMU_GET_INPUT, 0, 0, &switches, 1, "switch req") < 0)
return;
***************
*** 358,363 ****
--- 385,418 ----
sprintf(p, " %d", batt[j]); p += strlen(p);
}
+
+ #ifdef APMFILE
+ /* prepare the apm structure */
+ if (batt[0] & 0x04) {
+ pac.ac_avail = batt[0] & 0x01;
+
+ /* determine a percent remaining
+ and a charge level */
+ pac.remain_percent =
+ (batt[1] * 100) / batt[2];
+ if (pac.remain_percent <= APMCRITICAL) {
+ pac.battery_status = 0x02;
+ pac.battery_flags = 0x04;
+ } else if (pac.remain_percent <= APMLOW) {
+ pac.battery_status = 0x01;
+ pac.battery_flags = 0x02;
+ } else {
+ pac.battery_status = 0x00;
+ pac.battery_flags = 0x01;
+ }
+
+ /* now we determine if we are charging */
+ if (batt[0] & 0x02) {
+ pac.battery_status = 0x03;
+ pac.battery_flags |= 0x08;
+ }
+ }
+ #endif
}
*p++ = '}';
}
***************
*** 365,371 ****
--- 420,460 ----
*p = 0;
if (current < 0)
timeleft = charge * 3552 / -current;
+
+ #ifdef APMFILE
+ if (timeleft > APMSEC2MINTHRESHOLD) {
+ pac.remain_time = timeleft / 60;
+ pac.time_unit = "min";
+ } else {
+ pac.remain_time = timeleft;
+ }
+ #endif
}
+
+ #ifdef APMFILE
+ /* now we output the data */
+
+ /* open or reset the file */
+ if (fapm == NULL) {
+ /* open the new one for writing */
+ fapm = fopen(APMFILE, "w");
+ } else {
+ rewind(fapm);
+ }
+
+ /* rewrite the file */
+ if (fapm != NULL) {
+ fprintf(fapm, "%s %d.0 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n%s",
+ PMUD_VERSION, + pmu_version, + APMFAKEFLAGS, + pac.ac_avail, pac.battery_status, pac.battery_flags, + pac.remain_percent, pac.remain_time, pac.time_unit, + " ");
+ fflush(fapm);
+ }
+
+ #endif
n = strlen(status);
for (ss = all_sockets; ss != 0; ss = ssnext) {** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Re: (simple /proc/apm support for pmud) Re: PMU daemon
Quoted 7 lines
Quoted 4 lines
Finally, does anyone know how feasable it would be to make pmud have the same API as the intel-ish APMD, since there are a bunch of nice X apps/applets for various window managers that talk to APMD?
Well, I threw together a quick patch to pmud that does this. Here is the message that I sent to Paul Mackerras the other day.
Just what I need to use the Gnome applet :-) Thanks for implementing this. Please take care with the 'pmud sleeps machine at low power' feature, the write to stderr should be omitted or replaced by a syslog write there. At least on my machine, writing to stderr kills pmud in the least 'convenient' moment.
Michael
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines · Troy Benjegerdes
ncftpget ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz
Remote host has closed the connection.
ncftpget: cannot open ftp.linuxcare.com.au: remote host closed control connection.
I found that the linuxcare site refuses all connections made with ncftp. Other ftp clients seem to work fine.
Brad Boyer
[email protected]
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 8 lines · Brad Boyer
Quoted 4 lines · Troy Benjegerdes
ncftpget ftp://ftp.linuxcare.com.au/pmud-0.2.tar.gz
Remote host has closed the connection.
ncftpget: cannot open ftp.linuxcare.com.au: remote host closed control connection.I found that the linuxcare site refuses all connections made with ncftp. Other ftp clients seem to work fine.
I'm using ncftp 3.0 BETA (18-21) and can connect and grab files just fine. In fact I just grabbed pmud. Maybe it's because the only copy of pmud I found was in /pub/ppclinux, not in the root directory.
However, ncftpget is throwing "ncftpget: file retrieval error: PORT failed."
Signature · 3 lines
Shaw Terwilliger ([email protected]) ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/