Hi,
on my Clevo D410J laptop the the "present voltage" is always unknown. The
attached patch detects this situation and tries to fetch the "design voltage"
parameter instead.
$ cat /proc/acpi/battery/BAT0/state
present: yes
capacity state: ok
charging state: discharging
present rate: unknown
remaining capacity: 3882 mAh
present voltage: unknown
$ cat /proc/acpi/battery/BAT0/info
present: yes
design capacity: 4400 mAh
last full capacity: 4368 mAh
battery technology: rechargeable
design voltage: 11100 mV
design capacity warning: 160 mAh
design capacity low: 100 mAh
capacity granularity 1: 64 mAh
capacity granularity 2: 64 mAh
model number: D470K
serial number: 40131
battery type: LION
OEM info: SMP
Regards,
Márton Németh
--- powertop-1.10/powertop.c.orig 2008-06-10 22:18:45.000000000 +0200
+++ powertop-1.10/powertop.c 2008-09-23 22:04:45.000000000 +0200
@@ -538,12 +538,34 @@
}
fclose(file);
-
+
+ if (voltage == 0.0) {
+ /* Present voltage is unknown, try to fetch the design voltage instead */
+ sprintf(filename, "/proc/acpi/battery/%s/info", dirent->d_name);
+ file = fopen(filename, "r");
+ if (file) {
+ memset(line, 0, 1024);
+ while (fgets(line, 1024, file) != NULL) {
+ char *c;
+ if (strstr(line, "present:") && strstr(line, "no"))
+ break;
+
+ c = strchr(line, ':');
+ if (!c)
+ continue;
+ c++;
+
+ if (strstr(line, "design voltage") && strstr(c, "mV"))
+ voltage = strtoull(c, NULL, 10) / 1000.0;
+ }
+ fclose(file);
+ }
+ }
+
if (!dontcount) {
rate += watts_drawn + voltage * amperes_drawn;
}
cap += watts_left + voltage * amperes_left;
-
}
closedir(dir);
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power