View Single Post
Posts: 217 | Thanked: 20 times | Joined on Jan 2010
#1
Ok, here is the code:


PHP Code:
import location
import gobject

def on_error
(controlerrordata):
    print 
"location error: %d... quitting" error
    data
.quit()

def on_changed(devicedata):
    if 
not device:
        return
    if 
device.fix:
        if 
device.fix[1] & location.GPS_DEVICE_LATLONG_SET:
            print 
"lat = %f, long = %f" device.fix[4:6]
            
#data.stop()

def on_stop(controldata):
    print 
"quitting"
    
data.quit()

def start_location(data):
    
data.start()
    return 
False

def get_speed
(devicedata):
    if 
not device:
        return
    if 
device.fix:
        if 
device.fix[1] & location.GPS_DEVICE_SPEED_SET:
            print 
"lat = %f, Speed %s Km/h" device.fix[speed]
            
on_changed
            
#data.stop()

#i = 0
loop gobject.MainLoop()
control location.GPSDControl.get_default()
device location.GPSDevice()
control.set_properties(preferred_method=location.METHOD_USER_SELECTED,
                       
preferred_interval=location.INTERVAL_DEFAULT)

control.connect("error-verbose"on_errorloop)
#while i < 2:
    #device.connect("changed", get_speed, control)
device.connect("changed"on_changedcontrol)
    
#print i,
#    i = i + 1
control.connect("gpsd-stopped"on_stoploop)

gobject.idle_add(start_locationcontrol)

loop.run() 
I am trying to understand it.
I have read:
http://pymaemo.garage.maemo.org/pyth...ual/index.html
http://wiki.maemo.org/PyMaemo/Using_Location_API

I can not get the speed.
My goal is to create a table with speed captured every 1 second, preferently, every 0,1 if it is posible.
I can not full understand how loop works, is it a eternal loop?

I will be more than happy only with someone pointing me in the right direction.

Thanks