[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#298766: gnome-applets: battstat don't show correct values at startup on some hardware



On Wed, Mar 09, 2005 at 09:21:19PM +0100, Marco Innocenti wrote:
> Battstat on my laptop (Toshiba P20-311) don't show the correct value
> of the charge of the battery at startup. I have to wait several
> minutes to get it.  I've made some test and discoveded that "cat
> /proc/acpi/battery/BAT1/*" give the wrong value the first few time.
> So I patched battstat_applet.c to get acpiinfo 10 times at startup.
> It works for me and don't think would harm others.

[snip]

Hi Marco,

As discussed breifly on http://bugs.debian.org/298766, this is probably
a problem better solved in the kernel than in user-space.  I have CCed
the ACPI maintainers on this message for their consideration, including
your patch, which is below.

-- 
Horms

diff -r -u gnome-applets-2.8.2.orig/battstat/battstat_applet.c gnome-applets-2.8.2/battstat/battstat_applet.c
--- gnome-applets-2.8.2.orig/battstat/battstat_applet.c	2005-03-09 20:58:00.302510520 +0100
+++ gnome-applets-2.8.2/battstat/battstat_applet.c	2005-03-09 17:24:47.000000000 +0100
@@ -232,7 +232,7 @@
 
 #ifdef __linux__
 struct acpi_info acpiinfo;
-gboolean using_acpi;
+gboolean using_acpi, started_now=TRUE;
 int acpi_count;
 #endif
 
@@ -310,6 +310,14 @@
    * Updated by David Moore <dcm@acm.org> 5/29/2003 to poll less and
    *   use ACPI events. */
   if (using_acpi && acpiinfo.event_fd >= 0) {
+    /* By Marco Innocenti <m.innocenti@cineca.it> 09/03/2005
+     * Some hardware need several requests to warm up and give correct results. */
+    if (started_now) {
+	started_now=FALSE;
+	for (acpi_count=1; acpi_count < 10; acpi_count++) {
+	    acpi_linux_read(&apminfo, &acpiinfo);
+	}
+    }
     if (acpi_count <= 0) {
       /* Only call this one out of 30 calls to apm_readinfo() (every 30 seconds)
        * since reading the ACPI system takes CPU cycles. */



Reply to: