[PATCH] lib: fwts_battery: fix incorrect strings for a battery with unit of mWh

Alex Hung alex.hung at canonical.com
Thu May 24 02:34:08 UTC 2012


Hi Colin,

It was actually one bug that led to another topics

== Topic 1 ==

The one that is related to fwts is simple: when I was testing the the 
trip point patch, I found fwts_battery_get_capacity_sys_fs always 
returns 0 for remaining capacity. After some digging in, it is because 
the strings mismatch as the patch.

The below is the output from my thinkpad x200
========================================================
@x200:~$ cat /sys/class/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=14400000
POWER_SUPPLY_VOLTAGE_NOW=16684000
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=28800000
POWER_SUPPLY_ENERGY_FULL=24430000
POWER_SUPPLY_ENERGY_NOW=24430000
POWER_SUPPLY_MODEL_NAME=42T4646
POWER_SUPPLY_MANUFACTURER=SANYO
POWER_SUPPLY_SERIAL_NUMBER= 1720
========================================================

== Topic 2 ==

The led to the discussion we had - I was testing on x220 which has such 
problem, and then it turns on thinkpad sometimes returns power unit as 
mAh and sometimes as mWh, and this seems to be a BIOS bug - I will send 
Lenovo for their feedbacks.

Cheers,
Alex Hung

On 05/24/2012 01:19 AM, Colin Ian King wrote:
> Although we did discuss this on irc today, I'm still struggling to
> understand why this is required, can explain it a little more for me.
> Thanks Alex.
>
> Colin
>
>
> On 23/05/12 14:44, Alex Hung wrote:
>> Signed-off-by: Alex Hung <alex.hung at canonical.com>
>> ---
>> src/lib/src/fwts_battery.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/lib/src/fwts_battery.c b/src/lib/src/fwts_battery.c
>> index 5f21dfa..468c616 100644
>> --- a/src/lib/src/fwts_battery.c
>> +++ b/src/lib/src/fwts_battery.c
>> @@ -45,11 +45,11 @@ static int
>> fwts_battery_get_capacity_sys_fs(fwts_framework *fw,
>> switch (type) {
>> case FWTS_BATTERY_DESIGN_CAPACITY:
>> field_mAh = "POWER_SUPPLY_CHARGE_FULL_DESIGN=";
>> - field_mWh = "ENERGY_SUPPLY_CHARGE_FULL_DESIGN=";
>> + field_mWh = "POWER_SUPPLY_ENERGY_FULL_DESIGN=";
>> break;
>> case FWTS_BATTERY_REMAINING_CAPACITY:
>> field_mAh = "POWER_SUPPLY_CHARGE_NOW=";
>> - field_mWh = "ENERGY_SUPPLY_CHARGE_NOW=";
>> + field_mWh = "POWER_SUPPLY_ENERGY_NOW=";
>> break;
>> default:
>> return FWTS_ERROR;
>>
>
>





More information about the fwts-devel mailing list