ACPI/PMU procfs HAL test program. Version 002.

Paul Ionescu i_p_a_u_l at yahoo.com
Mon Jan 24 14:42:28 PST 2005


Hi,

On Mon, 24 Jan 2005 07:26:40 +0000, Richard Hughes wrote:
> If you have a few minutes, and you are feeling
> athletic, could you add properties for your machine that I have not
> covered like:
> 
> system.processor.maximum_speed
> battery.type
> battery.charge_level.maximum.real
> battery.charge_level.current
> battery.charge_level.unit
> 
> Thanks, Richard.

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.


--- procfs.c.1  2005-01-24 09:36:16.000000000 +0200
+++ procfs.c    2005-01-25 00:28:21.677673358 +0200
@@ -310,18 +310,37 @@
        if ( procfs_getbool(path, "present:", "yes", &value) )
                hal_device_property_set_bool(d, "system.battery.present", value);
 
-       /* add string [system.battery.is_rechargable] */
-       if ( procfs_getbool(path, "battery technology:", "rechargeable", &value) )
-               hal_device_property_set_bool(d, "system.battery.is_rechargable", value);
-
-       /* add string [system.battery.serial] */
-       if ( procfs_getvalue(path, "serial number:", buffer) )
-               hal_device_property_set_string(d, "system.battery.serial", buffer);
-
-       /* add string [system.battery.model] */
-       if ( procfs_getvalue(path, "model number:", buffer) )
-               hal_device_property_set_string(d, "system.battery.model", buffer);
+       /* only check if there is actually a battery present */
+       if (value == TRUE ) {
 
+               /* add string [system.battery.is_rechargable] */
+               if ( procfs_getbool(path, "battery technology:", "rechargeable", &value) )
+                       hal_device_property_set_bool(d, "system.battery.is_rechargable", value);
+
+               /* add string [system.battery.serial] */
+               if ( procfs_getvalue(path, "serial number:", buffer) )
+                       hal_device_property_set_string(d, "system.battery.serial", buffer);
+
+               /* add string [system.battery.model] */
+               if ( procfs_getvalue(path, "model number:", buffer) )
+                       hal_device_property_set_string(d, "system.battery.model", buffer);
+
+               /* add string [system.battery.type] */
+               if ( procfs_getvalue(path, "battery type:", buffer) )
+                       hal_device_property_set_string(d, "system.battery.type", buffer);
+
+               /* add string [system.battery.vendor] */
+               if ( procfs_getvalue(path, "OEM info:", buffer) )
+                       hal_device_property_set_string(d, "system.battery.vendor", buffer);
+
+               /* change to /proc/acpi/battery/BAT0/state */
+               path = g_strjoin("/", procfspath, "state", NULL);
+
+               /* add string [system.battery.rechargeable.is_charging] */
+               if ( procfs_getbool(path, "charging state:", "charging", &value) )
+                       hal_device_property_set_bool(d, "system.battery.rechargeable.is_charging", value);
+
+       }
        /* Free allocated buffers */
        g_free(buffer);
        g_free(path);


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



More information about the Hal mailing list