After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 562576 - profile is not saved correctly
profile is not saved correctly
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: gnome-power-statistics
2.24.x
Other All
: Normal normal
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2008-11-28 15:13 UTC by Joe
Modified: 2009-01-23 10:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
output of gnome-power-bugreport.sh (2.21 KB, text/plain)
2008-12-07 18:49 UTC, Joe
  Details
updated patch (1.86 KB, patch)
2009-01-23 04:43 UTC, Stephen Gildea
none Details | Review

Description Joe 2008-11-28 15:13:29 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;
Comment 1 Stephen Gildea 2008-12-07 02:43:28 UTC
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.
Comment 2 Richard Hughes 2008-12-07 17:35:31 UTC
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.
Comment 3 Joe 2008-12-07 18:49:06 UTC
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
Comment 4 Stephen Gildea 2008-12-31 06:00:35 UTC
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.
Comment 5 Stephen Gildea 2009-01-19 00:16:38 UTC
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.
Comment 6 Richard Hughes 2009-01-19 12:32:50 UTC
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.
Comment 7 Stephen Gildea 2009-01-23 04:43:47 UTC
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.
Comment 8 Richard Hughes 2009-01-23 10:53:26 UTC
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