Skip to contentSkip to conversation

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

DISCUSSION Horms 1 participant 1 message Nov 10, 2005 2 messages not in the archive ACPI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 20050309202119.GA8086-z9AggUaaQxwjA1nC/[email protected]

Horms

author
#2 lore raw
Quoted 6 lines · Marco Innocenti

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.

Signature · 36 lines
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 <[email protected]> 5/29/2003 to poll less and
    *   use ACPI events. */
   if (using_acpi && acpiinfo.event_fd >= 0) {
+    /* By Marco Innocenti <[email protected]> 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. */


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php