View Single Post
Posts: 1 | Thanked: 0 times | Joined on Jul 2010 @ Ontario
#8
would someone please update the example on the wiki??
yes, i'm another noob, especially when it comes to python. (and yes this is a whiney post)

I've been researching for weeks on how to access the GPS via the command line and I've gotten so close only to find a broken script.

edit:

dammit, I'll do it myself. I commented out the data.stop() in the wiki
but I'll add this here. (adds a loop to only check the GPS 6 times, plus gives an idea of accuracy from displaying how many sattelites are actually in use, 9 at a time is the maximum the n900 can do)


Code:
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()

Last edited by joel_c; 2010-07-17 at 02:35.