View Single Post
Posts: 458 | Thanked: 783 times | Joined on Jan 2010 @ France
#533
Originally Posted by pali View Post
As I wrote, I cannot change informations exported to HAL. HAL is userspace application which does not have anythink with my patches.

If you have problem with incorrect battery values, check first what kernel driver are reporting. It is in folder /sys/class/power_supply/bq27200-0 and in file uevent.
Well I don't understand why you ask me to check here :

Code:
-bash-2.05b# cat /sys/class/power_supply/bq27200-0/uevent 
PHYSDEVPATH=/class/i2c-adapter/i2c-2/2-0055
PHYSDEVBUS=i2c
PHYSDEVDRIVER=bq27x00-battery
POWER_SUPPLY_NAME=bq27200-0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_VOLTAGE_NOW=4103000
POWER_SUPPLY_CURRENT_NOW=-449463
POWER_SUPPLY_CAPACITY=47
POWER_SUPPLY_TEMP=323
POWER_SUPPLY_TIME_TO_EMPTY_NOW=0
POWER_SUPPLY_TIME_TO_EMPTY_AVG=0
POWER_SUPPLY_TIME_TO_FULL_NOW=9720
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CHARGE_FULL=1531708
POWER_SUPPLY_CHARGE_NOW=715785
POWER_SUPPLY_CHARGE_FULL_DESIGN=2056320
Then, so ?

Correct me if I'm wrong ...

If I understand properly your patch at http://atrey.karlin.mff.cuni.cz/~pali/battery.patch

Code:
--- battery.c.orig	2011-01-17 13:39:36.000000000 +0100
+++ battery.c	2011-01-18 18:42:10.000000000 +0100
@@ -5,6 +5,7 @@
 #include <dbus/dbus.h>
 
 #include <stdio.h>
+#include <stdlib.h>
  
 #include <libhildondesktop/libhildondesktop.h>
 
@@ -55,7 +56,12 @@ static gboolean battery_plugin_on_timeou
 	}
 	else
 	{
-		battery->percent = libhal_device_get_property_int(ctx, "/org/freedesktop/Hal/devices/bme", "battery.charge_level.percentage", NULL);
+		if ( libhal_device_property_exists(ctx, "/org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0", "battery.charge_level.percentage", NULL) )
+			battery->percent = libhal_device_get_property_int(ctx, "/org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0", "battery.charge_level.percentage", NULL);
+		else if ( system("pgrep -f ^/usr/sbin/bme_RX-51") == 0 )
+			battery->percent = libhal_device_get_property_int(ctx, "/org/freedesktop/Hal/devices/bme", "battery.charge_level.percentage", NULL);
+		else
+			battery->percent = 0;
 	}
 	
 	//GtkWidget *widget = GTK_WIDGET(data);
The patch say :

Code:
+		if ( libhal_device_property_exists(ctx, "/org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0", "battery.charge_level.percentage", NULL) )
+			battery->percent = libhal_device_get_property_int(ctx, "/org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0", "battery.charge_level.percentage", NULL);
Translate in human language :

If Kernel module driver 'bq27x00_battery' IS loaded, then we can access '/org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0' values and we use the value from the field 'battery.charge_level.percentage'.

After that :

Code:
+		else if ( system("pgrep -f ^/usr/sbin/bme_RX-51") == 0 )
+			battery->percent = libhal_device_get_property_int(ctx, "/org/freedesktop/Hal/devices/bme", "battery.charge_level.percentage", NULL);
Translate in human language :

Else, Kernel module driver 'bq27x00_battery' IS NOT loaded, and we cannot access '/org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0', so we check if bme IS loaded, and if so, then we can access '/org/freedesktop/Hal/devices/bme' values and we use the value from the field 'battery.charge_level.percentage'.

And finally :

Code:
+		else
+			battery->percent = 0;
Translate in human language :

Else, we cannot access any parameters, so just report battery percent as '0%'

Do you agree with my analyze of your patch ?

If so, how can you explain that :

Code:
-bash-2.05b# lshal -u /org/freedesktop/Hal/devices/computer_power_supply_battery_bq27200_0 | grep battery.charge_level.percentage && lshal -u /org/freedesktop/Hal/devices/bme | grep battery.charge_level.percentage
  battery.charge_level.percentage = 56  (0x38)  (int)
  battery.charge_level.percentage = 95  (0x5f)  (int)
And what is your opinion about the right and the false value ???

You can trust me, the right is the one reported by bme !!!

A++
 

The Following 2 Users Say Thank You to colin.stephane For This Useful Post: