Thread
:
help me for start gps shell script
View Single Post
xsmabbs
2012-03-18 , 08:15
Banned | Posts: 34 | Thanked: 3 times | Joined on Jul 2011
#
2
Thank you, I have found
The following is a reference to use
import location
import gobject
nn = 0
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:
print "lat = %f, long = %f" % device.fix[4:6]
# data.stop() commented out to allow continuous loop for a reliable fix - press ctrl c to break the loop, or program your own way of exiting)
def on_stop(control, data):
print "quitting"
data.quit()
def start_location(data):
data.start()
return False
while nn < 5:
loop = gobject.MainLoop()
control = location.GPSDControl.get_default()
device = location.GPSDevice()
control.set_properties(preferred_method=location.M ETHOD_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)
nn = nn + 1
if nn > 5:
break
gobject.timeout_add(8000,exit)
loop.run()
Last edited by xsmabbs; 2012-03-21 at
13:14
.
Quote & Reply
|
xsmabbs
View Public Profile
Find all posts by xsmabbs