Comment 57 for bug 531190

Revision history for this message
tlindvall (tarmo-lindvall) wrote :

Sorry for the previous post. I didn't fully realize how the system works. But back to the problem itself. I took a look about figures kernel reports in sysfs. Looks like current_now is always same figure as power_now, meaning current_now is insane, but power_now is reasonable. I'm on upower 0.9.1 and hp 2133.

I took a look at sourcecode of upower 0.9.1. With knowledge of just one c-course, I came to an idea that the problem might be the following piece of code in up-device-supply.c:

 /* get rate; it seems odd as it's either in uVh or uWh */
 energy_rate = fabs (sysfs_get_double (native_path, "current_now") / 1000000.0);

 /* convert charge to energy */
 if (energy == 0) {
  energy = sysfs_get_double (native_path, "charge_now") / 1000000.0;
  if (energy == 0)
   energy = sysfs_get_double (native_path, "charge_avg") / 1000000.0;
  energy *= voltage_design;
  energy_rate *= voltage_design;
 }

energy_rate rate gets converted from Ampere to Watts only when energy is zero (bug?). But in addition to correcting this we could use power_now as primary source of information. How about changing this code to:

 /* get rate; it seems odd as it's either in uVh or uWh */
 energy_rate = fabs (sysfs_get_double (native_path, "power_now") / 1000000.0);
 if (energy_rate == 0) {
  energy_rate = fabs (sysfs_get_double (native_path, "current_now") / 1000000.0);
  energy_rate *= voltage_design;
 }

 /* convert charge to energy */
 if (energy == 0) {
  energy = sysfs_get_double (native_path, "charge_now") / 1000000.0;
  if (energy == 0)
   energy = sysfs_get_double (native_path, "charge_avg") / 1000000.0;
  energy *= voltage_design;
 }

I would like to test this idea in my netbook, but couldn't figure out how to build ubuntu version of upower 0.9.1. There are some source packages in
http://packages.ubuntu.com/source/lucid/upower
but when extrating package upower_0.9.1.orig.tar.gz, it creates a directory UPower-0.9.1. When trying to apply upower_0.9.1-1.diff.gz by
patch -p0 < upower_0.9.1-1.diff
I get another directory upower-0.9.1 with debian subdirectory.
Could anyone explain in layman terms the whole ubuntu version of upower build and installation process??