View Single Post
Posts: 5 | Thanked: 0 times | Joined on Mar 2011 @ Canada
#1
Hi,

I am developing a GPS tracking application.
I have been following the location API on this page:
http://wiki.maemo.org/PyMaemo/Using_Location_API

The problem is, I couldn't run it in a simple Qt application

Code:
import location as gps
import logging

class myGPS:

    def __init__(self):
        self.control = gps.GPSDControl.get_default()
        self.device = gps.GPSDevice()
        self.control.set_properties(preferred_method=gps.METHOD_CWP,
                                    preferred_interval=gps.INTERVAL_5S)
        
        self.control.connect("error-verbose", self.onGPSError)
        self.device.connect("changed", self.onGPSData, self.control)
        self.control.connect("gpsd-stopped", self.onGPSStop)
    
    def start(self):
        logging.debug("GPS started")
        try:
            self.control.start()
        except Exception, err:
            logging.exception("start:")
    
    def stop(self):
        self.control.stop()
    
    def onGPSError(self, control, error, data):
        logging.debug("GPS Error: " + str(error))
    
    def onGPSData(self, device, data):
        if not device:
            return
        
        lat = device.fix[4]
        lng = device.fix[5]
        alt = device.fix[7]
        speed = float(device.fix[11])
        accuracy = float(device.fix[12])
        
        logging.info("Input: received")
        logging.info(lat, lng, alt, speed, accuracy)
    
    def onGPSStop(self, control):
        logging.debug("GPS Stopped")
When I trigger using start, the GPS symbol appears for a moment (blinking for 1~2s) then the application terminates.
In the log, I could only find "GPS started"

Any help is appreciated, Thank You.

Last edited by hezillion; 2011-03-19 at 04:41. Reason: Solved