Denis 'GNUtoo' Carikli | 21 Mar 2012 00:12
Favicon

Impossibility to handle resources at boot in oeventsd

Hi,

I wrote a gta04 GPS handler.
I also modified oeventsd to handle resource events
I made a recipe for the gta04 GPS handler.
And finally I added the following to /etc/freesmartphone/oevents/rules.yaml :
-                               
    trigger: ResourceState()    
    filters: And(HasAttr(resource, "GPS"),HasAttr(power_state, "enabled"))
    actions: Command('/usr/bin/gps_handler.py start')     
-
    trigger: ResourceState()         
    filters: And(HasAttr(resource, "GPS"),HasAttr(power_state, "disabled"))           
    actions: Command('/usr/bin/gps_handler.py stop')                                   

That was a clean way to integrate gta04 GPS according to Simon Busch.
However the way it is done has a major flaw:
At boot the GPS state is unknown.
And the Command in rules.yaml is not run at all at boot, only on resource 
change. (when the user slide the slider in shr-settings or automatically when 
an application request GPS(for instance with fso-raw)).

In /usr/lib/python2.7/site-
packages/framework/subsystems/oeventsd/fso_triggers.py, 
I added a ResourceStateTrigger class for listenning to that resource:
[SIGNAL]   org.freesmartphone.Usage.ResourceChanged(s:name, b:state, 
a{sv}:attributes)

Is that right? did I do something wrong? or is Simon Busch implementation idea 
wrong?
(Continue reading)

Simon Busch | 21 Mar 2012 08:45
Picon

Re: Impossibility to handle resources at boot in oeventsd


On 21.03.2012 00:12, Denis 'GNUtoo' Carikli wrote:
> Hi,
> 
> I wrote a gta04 GPS handler. I also modified oeventsd to handle
> resource events I made a recipe for the gta04 GPS handler. And
> finally I added the following to
> /etc/freesmartphone/oevents/rules.yaml : -
>  trigger: ResourceState() filters: And(HasAttr(resource,
> "GPS"),HasAttr(power_state, "enabled")) actions:
> Command('/usr/bin/gps_handler.py start') - trigger: ResourceState()
>  filters: And(HasAttr(resource, "GPS"),HasAttr(power_state,
> "disabled")) actions: Command('/usr/bin/gps_handler.py stop')
> 
> 
> That was a clean way to integrate gta04 GPS according to Simon
> Busch. However the way it is done has a major flaw: At boot the GPS
> state is unknown. And the Command in rules.yaml is not run at all
> at boot, only on resource change. (when the user slide the slider
> in shr-settings or automatically when an application request
> GPS(for instance with fso-raw)).

Thats the correct behaviour. oeventsd enables you only to execute
actions on different events. Maybe we need just an
SystemStartupCompleted event which is triggered when the system
startup is completed so we can handle different actions then.

> In /usr/lib/python2.7/site- 
> packages/framework/subsystems/oeventsd/fso_triggers.py, I added a
> ResourceStateTrigger class for listenning to that resource: 
(Continue reading)


Gmane