From owner-freebsd-acpi@FreeBSD.ORG Thu May 20 15:29:52 2004 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 979C416A4CE for ; Thu, 20 May 2004 15:29:52 -0700 (PDT) Received: from moutvdomng.kundenserver.de (moutvdom.kundenserver.de [212.227.126.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id 60DA143D5A for ; Thu, 20 May 2004 15:29:52 -0700 (PDT) (envelope-from liamfoy@sepulcrum.org) Received: from [212.227.126.221] (helo=mrvdomng.kundenserver.de) by moutvdomng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BQw2n-00065o-00; Fri, 21 May 2004 00:29:41 +0200 Received: from [217.42.210.204] (helo=liamfoy.ath.cx) by mrvdomng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BQw2n-0000G3-00; Fri, 21 May 2004 00:29:41 +0200 Date: Thu, 20 May 2004 23:28:47 +0100 From: "Liam J. Foy" To: "Grover, Andrew" Message-Id: <20040520232847.7ec1cbb2.liamfoy@sepulcrum.org> In-Reply-To: References: X-Mailer: Sylpheed version 0.9.10 (GTK+ 1.2.10; i386-portbld-freebsd5.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: freebsd-acpi@freebsd.org Subject: Re: apm code X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 May 2004 22:29:52 -0000 On Thu, 20 May 2004 15:03:56 -0700 "Grover, Andrew" wrote: > > Just writing to the list to make sure am correct here. The > > issue concerns /usr/src/usr.sbin/apm/apm.c. > > > > --- /usr/src/usr.sbin/apm/apm.c Thu May 20 20:30:57 2004 > > +++ /hd2/apm.c Thu May 20 20:44:36 2004 > > @@ -174,7 +174,7 @@ > > printf("Remaining battery life: "); > > if (aip->ai_batt_life == 255) > > printf("unknown\n"); > > - else if (aip->ai_batt_life <= 100) > > + else if (aip->ai_batt_life >= 0 && aip->ai_batt_life <= 100) > > printf("%d%%\n", aip->ai_batt_life); > > else > > printf("invalid value (0x%x)\n", aip->ai_batt_life); > > > > The above patch will make apm print invalid value when > > ai_batt_life does not equal 0-100. The reason for this was > > the the current code was printing -1 as a so called valid > > value(normally when acline is connected). I dont think > > printing -1 is correct, and really it should be printing > > invalid value since that is what it is. Do you guys agree > > with me or does -1 symbolise something? > > if (aip->ai_batt_life == 255) > printf("unknown\n"); > > The above line should catch the -1 case. There's a uint/uchar sign > extension problem. Changing the 255 to -1 will probably fix things. > > Regards -- Andy > Hmm, 255 would incline that it is not supported by the device, not that an invalid value has been returned in which -1 is. I have been looking into it, and -1 is returned from apm -l when the acline is connected, and the actual percentage when it is not(showing the device supports it and 255 does not catch the returned -1). I think we need to test the percentage like my patch does. What do you think? Best regards, Liam Foy