GNOME Bugzilla – Bug 562576
profile is not saved correctly
Last modified: 2009-01-23 10:53:26 UTC
Please describe the problem: Instead of just one profile there are many profiles stored as e.g. profile-901-47533-charging.csv. The 2nd number varies between approx. 47500 and 55000. Therefore the profile is not correct and statistics are drawn around 0%. Steps to reproduce: everytime I restart my system a new file is created. Actual results: Expected results: Just one profile should be stored. Does this happen every time? yes Other information: I've found in source code, that the hal key "battery.charge_level.design" is used to create the file id. A better key would be imho "battery.reporting.design", which doesn't change on my system. hal: 0.5.11 distri: ubuntu 0.8.10 (eeepc) gpm: 2.24.0 I've patched and recompiled successfully as follows: --- gnome-power-manager-2.24.0/src/gpm-cell.c 2008-09-04 12:05:15.000000000 +0200 +++ gnome-power-manager-2.24.0-jb1/src/gpm-cell.c 2008-11-28 13:48:51.000000000 +0100 @@ -103,7 +103,10 @@ return FALSE; } - hal_gdevice_get_uint (device, "battery.charge_level.design", + hal_gdevice_get_uint (device, "battery.reporting.design", + &unit->reporting_design, NULL); + + hal_gdevice_get_uint (device, "battery.charge_level.design", &unit->charge_design, NULL); hal_gdevice_get_uint (device, "battery.charge_level.last_full", &unit->charge_last_full, NULL); @@ -139,13 +142,7 @@ if (exists == FALSE && (unit->is_discharging || unit->is_charging == TRUE)) { egg_warning ("could not read your battery's charge rate"); } - /* sanity check to less than 100W */ - if (unit->rate > 100*1000) { - egg_warning ("sanity checking rate from %i to 0", unit->rate); - unit->rate = 0; - } - /* The ACPI spec only allows this for primary cells, but in the real - world we also see it for rechargeables. Sigh */ + if (unit->rate == 0) { guint raw_last_charge; hal_gdevice_get_uint (device, "battery.reporting.last_full", @@ -472,19 +469,20 @@ { GString *string; gchar *id = NULL; - + g_return_val_if_fail (cell != NULL, NULL); g_return_val_if_fail (GPM_IS_CELL (cell), NULL); string = g_string_new (""); - + + /* in an ideal world, model-capacity-serial */ if (cell->priv->model != NULL && strlen (cell->priv->model) > 2) { g_string_append (string, cell->priv->model); g_string_append_c (string, '-'); } - if (cell->priv->unit.charge_design > 0) { - g_string_append_printf (string, "%i", cell->priv->unit.charge_design); + if (cell->priv->unit.reporting_design > 0) { + g_string_append_printf (string, "%i", cell->priv->unit.reporting_design); g_string_append_c (string, '-'); } if (cell->priv->serial != NULL && strlen (cell->priv->serial) > 2) { --- gnome-power-manager-2.24.0/src/gpm-cell-unit.h 2008-09-04 12:05:15.000000000 +0200 +++ gnome-power-manager-2.24.0-jb1/src/gpm-cell-unit.h 2008-11-28 13:43:44.000000000 +0100 @@ -44,6 +44,7 @@ typedef struct { GpmCellUnitKind kind; GpmCellUnitMeasure measure; + guint reporting_design; guint charge_design; guint charge_last_full; guint charge_current;
My battery.charge_level.design also changes as the battery percentage changes, and I get a new battery profile every time I log in, never building any profile accuracy. I also see that battery.reporting.design does not change even as battery.charge_level.design does. This makes me think there is a bug in HAL that keeps changing battery.charge_level.design. In any case, it looks like the change suggested by the original bug reporter would work for me. A more robust change might be to use the design capacity in the config_id only when the model name and serial number are not set.
I guess your laptop reports charge in mAh, and you don't have design.voltage. Can you please attach the output of gnome-power-bugreport.sh please.
Created attachment 124117 [details] output of gnome-power-bugreport.sh Richard, you're right, charge is reported in mAh, but I do have voltage.design. Attached the output of gnome-power-bugreport.sh
My laptop also reports charge in mAh and also has a voltage.design. As long as voltage.current stays at or above voltage.design, my charge_level.design stays the same, and I'm okay. But when voltage.current drops below voltage.design, charge_level.design varies, and then I get multiple battery profiles.
I think it's important to get this regression from 2.22 fixed for 2.26, so I'd like to propose another way forward, perhaps a simpler way. I find that I do not share my ~/.gnome2/ directory across multiple laptops, so fancy measures for telling batteries apart are not useful to me. And when these measures fail to recognize the one battery at all, they do actual harm. If this is the most common use case, then this bug can be fixed simply by reverting r2809. This is the change from last May that added the problematic "capacity" parameter to a battery's id.
Joe, why remove "sanity check to less than 100W"? There's also a ton of whitespace in our patch. Stephen, we have to include capacity as some vendors create different sized batteries with the same serial number (0000000) -- so it's really difficult to do the right thing either way. Joe's patch might help your case tho.
Created attachment 127064 [details] [review] updated patch I've updated Joe's patch for current SVN and to not remove the rate sanity check. I've also added fixes for misspellings in debug messages. I've been running with this patch, and it fixes the bug nicely for me.
2009-01-23 Richard Hughes <richard@hughsie.com> * src/gpm-cell-unit.h: * src/gpm-cell.c: (gpm_cell_refresh_hal_all), (gpm_cell_get_id): We have to include capacity in the profile name as some vendors create different sized batteries with the same serial number. This break batteries that use the current voltage for the mAh to mWh conversion when the design voltage is also invalid. In this case use the reporting string as we don't care about units. Patch from Stephen Gildea and Joe, many thanks. Fixes #562576