Problem Interfacing with Hal

Danny Budik dbudik at ist-traffic.com
Sun Feb 26 19:54:16 PST 2006


Thanks for all your help.

I realized that I wasn't calling the main wait loop properly.  I was 
just doing a while(1), whenI should've been creating a loop with 
g_main_loop_new() and then calling g_main_loop_run(). Adding those two 
calls made it work. Now I can just use libhal_device_get_property_int to 
get the info that I need from hal.

Thanks again,
Danny

Marko Anastasov wrote:
> On Fri, 2006-02-24 at 18:20 -0500, Danny Budik wrote:
>   
>> What I do is initialize Hal where the callbacks 
>> libhal_ctx_set_device_added and libhal_ctx_set_device_removed are 
>> called. Then I have a while loop which just waits for an event (such as 
>> my plugging in a device).
>>     
>
> Are you using glib? In that case, in the initialization code
> you should have something like:
>
> dbus_conn_ = dbus_bus_get(DBUS_BUS_SYSTEM, error);
> if (! (dbus_error_is_set(error)))
> {
>   dbus_connection_setup_with_g_main(dbus_conn_, NULL);
>   libhal_ctx_set_dbus_connection(hal_ctx_, dbus_conn_);
> }
>
> for the callbacks:
>
> libhal_ctx_set_device_added(hal_ctx_, on_hal_device_added);
> libhal_ctx_set_device_removed (hal_ctx_, on_hal_device_removed);
> libhal_ctx_set_device_property_modified(hal_ctx_,on_hal_property_modified);
>
> and then:
>
> static void
> on_hal_device_added(LibHalContext* ctx, const char* udi)
> { ... }
>
>
> Marko
>
>
>   


More information about the hal mailing list