x = 0
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 "%f, %f, %dm above sea level" % (device.fix[4:6] + (device.fix[7],))
print " satellites in use: %d" % (device.satellites_in_use)
global x
x = x + 1
if x == 6:
data.stop()