maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Brainstorm (https://talk.maemo.org/forumdisplay.php?f=47)
-   -   How to record gpsr data from CLI ? (https://talk.maemo.org/showthread.php?t=81491)

saponga 2012-01-10 13:37

How to record gpsr data from CLI ?
 
i'm wondering about how can i start the n900 GPS and register the raw data using a command on CLI. I would like to insert that command in a script. :confused:
Thanks :)

anthonie 2012-01-10 13:44

Re: How to record gpsr data from CLI ?
 
I think you're looking for this, correct?

https://github.com/andrei1089/canola...gps-service.py

saponga 2012-01-10 15:03

Re: How to record gpsr data from CLI ?
 
Thanks for reply... i'm not sure if it's what i'm searching for... i run the python script and all i get was 2 messages that says "GPS service running" and "running on Maemo5"... Actually, what i need is a code that starts the gps unit on the n900 and store the gpsr data for future use.
Thanks again !!! :)

jedi 2012-01-10 15:24

Re: How to record gpsr data from CLI ?
 
The 'Complete Example' on http://wiki.maemo.org/PyMaemo/Using_Location_API this page worked for me...

saponga 2012-01-10 18:51

Re: How to record gpsr data from CLI ?
 
That's it !!! :D Now is just find a way to store all data because the x-term shows only the last ones.
Thanx Jedi !

jedi 2012-01-11 09:48

Re: How to record gpsr data from CLI ?
 
This is my script, based on the 'complete example'.

It waits for the GPS lock to be < 500 meters, then exists printing the lattitude, longitude and accuracy.

You could run this in a loop and 'record' the info using:
$ script.sh > logfile.txt
Code:

#!/usr/bin/python
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

    #Uncomment line below to show progress...
    #print "Accuracy: ",device.fix[6]," Lat/Long: ",device.fix[4:6] 
 
    if not device.fix[6] == device.fix[6]:
        return

    if device.fix[6] > 50000:
        return

    if device.fix:
        if device.fix[1] & location.GPS_DEVICE_LATLONG_SET:
            print device.fix[4]," ",device.fix[5]," ",device.fix[6]
            data.stop()

def on_stop(control, data):
    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()


saponga 2012-01-13 01:08

Re: How to record gpsr data from CLI ?
 
I just used the write function with -append instead print command. works well !
Thanks jedi !


All times are GMT. The time now is 12:06.

vBulletin® Version 3.8.8