Subject: bin/17179: apm dosn't show different battery levels
To: None <gnats-bugs@gnats.netbsd.org>
From: None <snoonan@tbearsiberians.com>
List: netbsd-bugs
Date: 06/05/2002 17:54:36
>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:   Wed Jun 05 17:55:01 PDT 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: