Reply
Thread Tools
Posts: 155 | Thanked: 69 times | Joined on Apr 2008
#11
Pity that liblocation API must have changed. I went with that since it seemed to be the most "officially documented" way of accessing the GPS in maemo and therefore the least likely to change.

I not going to attempt to migrate the code because I don't have an n900 device to test with. If someone else would like to try it, it should involve making the python ctypes structures and function calls line up with whatever is now changed in the C API. This would involve chasing through the new liblocation docs and header files. The python wrapper is very thin so there's not a whole lot that can be going wrong, unless the new API is radically different.
 
Posts: 486 | Thanked: 153 times | Joined on Sep 2009 @ New York City
#12
Originally Posted by yerga View Post
The GPS module is being worked by the Pymaemo guys. They have something in the SVN and they will be pushing a package to the repository soon enough.

http://wiki.maemo.org/PyMaemo/Using_Location_API
https://bugs.maemo.org/show_bug.cgi?id=5748#c2
I finally had a chance to look at this, and it seems there are some problems:

using the example code:
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:
            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()
it runs, however, the result returns immediately with:

Code:
Nokia-N900-42-11:~# python test-location.py
lat = 39.400000, long = 0.000000
quitting
No matter what I change the preferred_method= to it always returns instantaneously - even if I reboot the phone to force a cold-start.

Lat is 1.4 degrees south of my current position, and Long is zero which isn't right either....
 
Posts: 486 | Thanked: 153 times | Joined on Sep 2009 @ New York City
#13
Follow up to this (I got it working)

I posted my question to the pymaemo developer list and one of the developers, David, pointed out the problem with the code exiting the first time on_changed() gets called when it hasn't fulling acquired a fix. Commenting out the data.stop() line allows a 2nd call to acquire the full fix:

Code:
Nokia-N900-42-11:~# python test-location2.py
lat = 39.400000, long = 0.000000
lat = 40.796683, long = -73.922741
Also, I had updated my location server from supl.nokia.com to supl.google.com per this post: http://talk.maemo.org/showpost.php?p...3&postcount=14

Allowed me to get a quick network-based fix in the Ovi Maps app indoors. Before using the old server I could never get a fix.

Last edited by hypnotik; 2009-12-16 at 01:56.
 
Posts: 217 | Thanked: 20 times | Joined on Jan 2010
#14
Hi
Do you have and example like this but using ctypes?
I need a faster refresh and this wrapper only allows 1 sec or higher

thanks
 
Posts: 53 | Thanked: 90 times | Joined on Nov 2009 @ Manaus, Brazil
#15
Originally Posted by dhcmega View Post
Hi
Do you have and example like this but using ctypes?
I need a faster refresh and this wrapper only allows 1 sec or higher
thanks
Have you tried playing with the python-location? See http://wiki.maemo.org/PyMaemo/Using_Location_API for an example .
__________________
Anderson Lizardo
 

The Following User Says Thank You to lizardo For This Useful Post:
Posts: 217 | Thanked: 20 times | Joined on Jan 2010
#16
lizardo, that is the one i have used. but it only allows a max rate of 1 position refresh per second and i need a position refresh of at least 0.1 of second.
thanks
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 20:59.