NetBSD Problem Report #17179

Received: (qmail 5373 invoked by uid 605); 6 Jun 2002 00:54:34 -0000
Message-Id: <20020606005436.ABAEC11137@www.netbsd.org>
Date: Wed,  5 Jun 2002 17:54:36 -0700 (PDT)
From: snoonan@tbearsiberians.com
Sender: gnats-bugs-owner@netbsd.org
Reply-To: snoonan@tbearsiberians.com
To: gnats-bugs@gnats.netbsd.org
Subject: apm dosn't show different battery levels
X-Send-Pr-Version: www-1.0

>Number:         17179
>Category:       bin
>Synopsis:       apm dosn't show different battery levels
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 06 00:55:01 +0000 2002
>Closed-Date:    
>Last-Modified:  
>Originator:     Shelby
>Release:        1.5ZC
>Organization:
>Environment:
NetBSD psudodragon 1.5ZC NetBSD 1.5ZC (PSUDODRAGON) #0: Mon May 13 13:53:36 PDT 2002     
>Description:
I have 2 batteries in my notebook..  apm dosn't show battery status for both, just combined.  kernel apm knows the difference.
>How-To-Repeat:
get a notebook with 2 batteries...  type apm   note you only get the total battery information not individual
>Fix:
This patch only works with apm -d   apmd's socket dosen't have a way to ask for a specific battery still.


*** apm.c       Wed Jun  5 13:37:22 2002
--- apm.c.org   Wed Jun  5 17:44:14 2002
***************
*** 161,170 ****
        enum apm_action action = NONE;
        int ch, doac, dobstate, domin, dopct, dostatus, fd, nodaemon,
!           rval, verbose, use_ioctl;
!         int i;

        doac = dobstate = domin = dopct = dostatus = nodaemon =
            verbose = FALSE;
-         use_ioctl = 0;
        while ((ch = getopt(argc, argv, "lmbvadsSzf:d")) != -1)
                switch (ch) {
--- 161,168 ----
        enum apm_action action = NONE;
        int ch, doac, dobstate, domin, dopct, dostatus, fd, nodaemon,
!           rval, verbose;

        doac = dobstate = domin = dopct = dostatus = nodaemon =
            verbose = FALSE;
        while ((ch = getopt(argc, argv, "lmbvadsSzf:d")) != -1)
                switch (ch) {
***************
*** 249,253 ****
                            &reply.batterystate) == -1)
                                err(1, "ioctl(APM_IOC_GETPOWER)");
-                         use_ioctl = 1;
                        goto printval;
                }
--- 247,250 ----
***************
*** 284,322 ****
  printval:
                        if (verbose) {
!                               for(i = 0; i <= api->nbattery; i++) {
!                                         if(i == 0) {
!                                           printf("Total for all battery:\n");
!                                         } else {
!                                            printf("Battery %d:\n",i);
!                                         }
!                                         memset(&reply, 0, sizeof(reply));
!                                         reply.batterystate.batteryid = i;
!                                         if(use_ioctl) {
!                                           if (ioctl(fd, APM_IOC_GETPOWER,
!                                                     &reply.batterystate) == -1)
!                                           err(1, "ioctl(APM_IOC_GETPOWER)");
!                                         } else {
!                                           fd = open_socket(sockname);
!                                           if ((rval = send_command(fd, &command, &reply)) != 0) {
!                                            errx(rval, "cannot get reply from APM daemon\n");
!                                           }
!                                         }
!                                       if (dobstate)
!                                               printf("Battery charge state: %s\n",
!                                                   battstate(api->battery_state));
!                                       if (dopct || domin) {
!                                                 printf("Battery remaining: ");
!                                                 if (dopct)
!                                                       printf("%d percent",
!                                                           api->battery_life);
!                                                 if (dopct && domin)
!                                                       printf(" (");
!                                                 if (domin)
!                                                       printf("%d minutes",
!                                                           api->minutes_left);
!                                                 if (dopct && domin)
!                                                       printf(")");
!                                                 printf("\n");
!                                                }
                                }
                                if (doac)
--- 281,300 ----
  printval:
                        if (verbose) {
!                               if (dobstate)
!                                       printf("Battery charge state: %s\n",
!                                           battstate(api->battery_state));
!                               if (dopct || domin) {
!                                       printf("Battery remaining: ");
!                                       if (dopct)
!                                               printf("%d percent",
!                                                   api->battery_life);
!                                       if (dopct && domin)
!                                               printf(" (");
!                                       if (domin)
!                                               printf("%d minutes",
!                                                   api->minutes_left);
!                                       if (dopct && domin)
!                                               printf(")");
!                                       printf("\n");
                                }
                                if (doac)




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

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.