Subject: pkg/26438: asapm doesn't handle Ampere-based sysmon battery info
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <mer@klockrike.net>
List: pkgsrc-bugs
Date: 07/26/2004 23:48:58
>Number:         26438
>Category:       pkg
>Synopsis:       asapm doesn't handle Ampere-based sysmon battery info
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 26 21:50:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Michael Eriksson
>Release:        NetBSD 2.0_BETA
>Organization:
>Environment:
Architecture: i386
Machine: i386
>Description:

The patches for asapm to try sysmon if APM fails, only support battery
info in units of Watts and Watt hours. However, some machines like my
Compaq Presario X1007EA laptop uses units of Amperes and Ampere hours.


>How-To-Repeat:

Try to use asapm on a machine that gives battery info in units of
Amperes and Ampere hours.

>Fix:

Index: patches/patch-af
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/asapm/patches/patch-af,v
retrieving revision 1.4
diff -u -r1.4 patch-af
--- patches/patch-af	30 Jun 2004 14:22:49 -0000	1.4
+++ patches/patch-af	26 Jul 2004 21:29:17 -0000
@@ -10,7 +10,7 @@
  
  #include "state.h"
  extern struct apm_state state;
-@@ -136,18 +137,183 @@ void ReadAPMDevice( )		/* FreeBSD versio
+@@ -136,18 +137,185 @@
  	state.time_left = info.ai_batt_time / 60;
  }
  #elif defined(__NetBSD__)||defined(__OpenBSD__)
@@ -84,8 +84,9 @@
 +			continue;
 +
 +#ifdef HAVE_ENVSYS_SWATTHOUR
-+		if (etds.units == ENVSYS_SWATTHOUR) {
-+			/* Watt hours, this must be battery capacity info. */
++		if (etds.units == ENVSYS_SWATTHOUR ||
++		    etds.units == ENVSYS_SAMPHOUR) {
++			/* Watt or amp hours, this must be battery cap info. */
 +			if (match_end(ebis.desc, " design cap")) {
 +				design += etds.cur.data_s;
 +			} else if (match_end(ebis.desc, " charge")) {
@@ -108,8 +109,9 @@
 +
 +		}
 +#endif /* HAVE_ENVSYS_INDICATOR */
-+		if (etds.units == ENVSYS_SWATTS) {
-+			/* Watts, this must discharge rate. */
++		if (etds.units == ENVSYS_SWATTS ||
++		    etds.units == ENVSYS_SAMPS) {
++			/* Watts or apms, this must discharge rate. */
 +			if (match_end(ebis.desc, " discharge rate")) {
 +				discharge_rate += etds.cur.data_s;
 +			} else if (match_end(ebis.desc, " charge rate")) {

>Release-Note:
>Audit-Trail:
>Unformatted: