Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    new python GPS wrapper (liblocation.py)

    Reply
    Page 2 of 2 | Prev |   1   2 |
    rbrewer123 | # 11 | 2009-12-03, 13:53 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    hypnotik | # 12 | 2009-12-15, 21:07 | Report

    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....

    Edit | Forward | Quote | Quick Reply | Thanks

     
    hypnotik | # 13 | 2009-12-16, 01:48 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by hypnotik; 2009-12-16 at 01:56.

     
    dhcmega | # 14 | 2010-03-18, 18:50 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    lizardo | # 15 | 2010-03-22, 18:02 | Report

    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 .

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to lizardo For This Useful Post:
    dhcmega

     
    dhcmega | # 16 | 2010-04-01, 20:38 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 2 of 2 | Prev |   1   2 |
vBulletin® Version 3.8.8
Normal Logout