Reply
Thread Tools
Posts: 156 | Thanked: 90 times | Joined on Jan 2010
#1
It has to be possible. Probably someone already posted it, but I couldn't google it properly. The closest comes this python script:

Code:
import location
import gobject

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

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

def on_stop(control, data):
    print "quitting"
    data.quit()

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

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_error, loop)
device.connect("changed", on_changed, control)
control.connect("gpsd-stopped", on_stop, loop)

gobject.idle_add(start_location, control)

loop.run()
Which actually prints out the location but after that it does not refresh it, even if it is run multiple times. Is python really needed? If so, I'd like a python script which actually re-polls GPS. But I would prefer shell script. Is it possible?
 
Posts: 318 | Thanked: 735 times | Joined on Oct 2009
#2
Originally Posted by rooted View Post
It has to be possible. Probably someone already posted it, but I couldn't google it properly. The closest comes this python script:

Code:
import location
import gobject

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

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

def on_stop(control, data):
    print "quitting"
    data.quit()

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

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_error, loop)
device.connect("changed", on_changed, control)
control.connect("gpsd-stopped", on_stop, loop)

gobject.idle_add(start_location, control)

loop.run()
Which actually prints out the location but after that it does not refresh it, even if it is run multiple times. Is python really needed? If so, I'd like a python script which actually re-polls GPS. But I would prefer shell script. Is it possible?
try to comment the data.stop() call, this should be sufficient.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 09:00.