Using gps from command line

David Fokkema dfokkema at ileos.nl
Wed Jul 22 00:13:05 CEST 2009


On Sat, 2009-07-18 at 20:13 +0200, Laszlo KREKACS wrote:

> So anybody can show me a working code using the gps through frameworkd?

Like this?


import dbus
import time

bus = dbus.SystemBus()
usage = bus.get_object('org.freesmartphone.ousaged',
                       '/org/freesmartphone/Usage')

gps = bus.get_object('org.freedesktop.Gypsy', '/org/freedesktop/Gypsy')
gps_device = dbus.Interface(gps, 'org.freedesktop.Gypsy.Device')
gps_position = dbus.Interface(gps, 'org.freedesktop.Gypsy.Position')

print usage.GetResourcePolicy('GPS')
print usage.GetResourceState('GPS')

usage.RequestResource('GPS')
print usage.GetResourceState('GPS')

t = time.time()
while True:
    print 'Connection:', gps_device.GetConnectionStatus()
    print 'Fix:', gps_device.GetFixStatus()
    print 'Position:', gps_position.GetPosition()
    time.sleep(2)
    if time.time() - t > 10:


        break

usage.ReleaseResource('GPS')
print usage.GetResourceState('GPS')


David




More information about the community mailing list