ACPI/PMU procfs HAL test program. Version 002.

Paul Ionescu i_p_a_u_l at yahoo.com
Tue Jan 25 03:28:51 PST 2005


Hi,

On Mon, 24 Jan 2005 23:55:54 +0000, Richard Hughes wrote:
> On Tue, 25 Jan 2005 00:42:28 +0200, Paul Ionescu wrote:
>> I made a patch to add some more battery values, and I now need a
>> function to parse a string like "present rate: 14547 mW" and extract the
>> integer from the string.
> 
> 14547 mW, what about searching for a space and then doing a g_ascii_strtod
> on the string?
> It might be worth writing a generic function, give me a shout if you get
> stuck.
>  
>> --- procfs.c.1  2005-01-24 09:36:16.000000000 +0200 +++ procfs.c
>> 2005-01-25 00:28:21.677673358 +0200
> 
> Brilliant, thanks. I've patched the file. I think the small test file
> idea is working well, I'm looking at merging some of the main
> functionality in soon.

I have some more comments:

1) I have put in system.battery.type key the real type of the battery from
the info file (LION), and not "primary" or "laptop" as per HAL specs. Is
this ok ? Should we add another key for this value ?

2) Now we are reading /proc/acpi/battery/BAT0/info or state every time we
search for a value which leads to increase load due to executing acpi
methods . A better approach would be IMHO to read that file in a buffer,
and look for the wanted values in that buffer.
The code readability and beauty should be the same, but maybe we need an
extra function for this.

3) My patch only reads battery options if there is actually a battery in
that slot. Is this ok ?

4) For processors we need info about it from both /procfs and /sysfs, so
maybe we need to add a separate key like linux.acpi.sysfs_path .

5) We have a BOOL system.battery.rechargeable.is_charging, and the state
of the battery can be: charging, discharging, charged. How do we represent
these three states ?


_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list