FSO resources, GPS-TTFF example (Was: is wifi-driver developed anymore?)

Rask Ingemann Lambertsen ccc94453 at vip.cybercity.dk
Thu Aug 13 15:34:37 CEST 2009

On Thu, Aug 13, 2009 at 11:15:31AM +0200, arne anka wrote:
> >> - the fso way of retrieving the resource is discouraged
> >
> > Hm, no? fsoraw does exactly that: manages access to resources the fso
> > way.
> it's not that i know all these fso dbus commands by heart, but
> mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage  
> org.freesmartphone.Usage.SetResourcePolicy WiFi enabled
> which you called "in this particular case harmful", looks pretty much like  
> the fso way to me. am i wrong?

   Yes. :-( You should not use SetResourcePolicy if you can at all avoid
it. If an app needs a resource, it should call RequestResource instead.
If the app doesn't have FSO support, use fsoraw to request the resource.

   There is a bit of trickery in using fsoraw with a shell script. You can
either make the script call itself with fsoraw except if given a command
line option such as --no-fsoraw, or use a here-document. Example of the


# GPS-TTFF - Find GPS time to first fix using all the important buzz-words
# such as D-bus, Gypsy, freedesktop.org and freesmartphone.org.

# Destinations and paths are listed in /etc/dbus-1/system.d/*.
# Interfaces are "documented" at <URL:http://docs.freesmartphone.org/>.

fsoraw -r GPS -- sh <<"__end_of_script"

DBUSCALL_='dbus-send --print-reply=undocumented --system --type=method_call --dest='

if [ "--coldstart" = "$1" ]; then
	rm -f /var/lib/freesmartphone/ogpsd.pickle

START=$(date +%s)

# Where is the first return value from GetPosition documented?
while ${DBUSCALL_}org.freedesktop.Gypsy /org/freedesktop/Gypsy org.freedesktop.Gypsy.Position.GetPosition \
	| head -n 1 | grep -q -v -F -e 'int32 15' -e 'int32 7'; do
	sleep 1

FINISH=$(date +%s)

echo "Time to first fix: $((${FINISH} - ${START})) s"

${DBUSCALL_}org.freedesktop.Gypsy /org/freedesktop/Gypsy org.freedesktop.Gypsy.Position.GetPosition

   Please compare with how it should not be done, by a clueless newbie:

> why is simply requesting the resource like openmoko-panel-plugin does,  
> sufficient?

   Requesting the resource tells FSO that an app wants to use the resource.
If the policy permits, FSO will arrange for the resource to be available.

> which is the rationale for fsoraw here?

   To request resources for apps that don't have FSO support themselves.

> why using fsoraw, why isn't fso sufficient?

   You are confused. Fsoraw uses FSO.

Rask Ingemann Lambertsen
Danish law requires addresses in e-mail to be logged and stored for a year

More information about the community mailing list