On Mon, Sep 01, 2008 at 02:14:46PM -0400, Joey Hess wrote:
> The patch is better than nothing, though I don't trust the values it
> reports when on battery. This is what I see when discharging:

I have just found out that vanilla kernel (as I have mentioned in the
original email with the patch) worked only because
CONFIG_ACPI_PROCFS_POWER=y while debian kernel disables this option.
So that I have checked the print_batter_sysfs again and it seems that
the problem is on another place:

powertop.c:648
        sprintf(filename, "/sys/class/power_supply/%s/current_now", 
dirent->d_name);
        file = fopen(filename, "r");
        if (!file)
                continue;
        memset(line, 0, 1024);
        if (fgets(line, 1024, file) != NULL) {
                watts_drawn = strtoull(line, NULL, 10) / 1000000.0;
        }
        fclose(file);

        if (!dontcount) {
                rate += watts_drawn + voltage * amperes_drawn;
        }

current rate (later used for the remaining time calculation:
display.c:201
        sprintf(buffer, _("Power usage (ACPI estimate): %3.1fW (%3.1f hours)"), 
rate, cap/rate);
)

is calculated as watts_drawn + voltage which is not correct, because
current_* values are in ľA and not in ľW (according to
linux-src/Documentation/power/power_supply_class.txt).

Updated patch will come in the next post.

> 
> Power usage (ACPI estimate): 2.4W (23.0 hours)
> 
> Obviously, I'm not really that lucky.
> 
> [EMAIL PROTECTED]:~/tmp/powertop-1.10>acpi
>      Battery 0: Discharging, 87%, 00:04:51 remaining
> 
> That's closer to right.
> 
> [EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat 
> /sys/class/power_supply/CMB1/charge_now 
> 6790000
> [EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat 
> /sys/class/power_supply/CMB1/voltage_now 
> 8038000
> [EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat 
> /sys/class/power_supply/CMB1/current_now
> 1249000
> [EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat 
> /sys/class/power_supply/CMB1/charge_full
> 7800000

Just for record:

remaining energy = voltage * charge = 54 Wh
current consumption = voltage * current = 10 W
remaining time = remaining_energy/current_consumption = 5.4 h
-- 
Michal Hocko



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to