[Qgis-developer] Connect to GPS device
Josua S
josh-talk at hotmail.com
Thu Jun 27 10:49:44 PDT 2013
Or does anyone have other experiences with connecting to a GPS device in Python code?
I would be very grateful for any help.
Regards, Josua
From: josh-talk at hotmail.com
To: qgis-developer at lists.osgeo.org
Date: Wed, 26 Jun 2013 14:16:04 +0200
Subject: Re: [Qgis-developer] Connect to GPS device
Here's the code again, in case it is not displayed correctly: http://pastebin.com/sKfY2jDj
From: josh-talk at hotmail.com
To: qgis-developer at lists.osgeo.org
Date: Wed, 26 Jun 2013 14:12:20 +0200
Subject: [Qgis-developer] Connect to GPS device
Hello
I am working on a Python plugin for QGIS 1.8. My goal is to automatically connect to a gps device at
a COM port. I tried to clone some code of qgsgpsinformationwidget.cpp and looks like this:
---------------------------------------
from qgis.core import *
from qgis.utils import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
devices_combo_box = qgis.utils.iface.mainWindow().findChild(QComboBox, 'mCboDevices')
com_port = devices_combo_box.itemData(devices_combo_box.currentIndex()).toString()
detector = QgsGPSDetector(com_port)
QObject.connect(detector, SIGNAL("detected( QgsGPSConnection )"), self.connection_detected)
QObject.connect(detector, SIGNAL("detectionFailed()"), self.connection_detection_failed)
detector.advance()
def connection_detected(self, gps_connection):
QMessageBox.information(None, "Information", "Connection detected", QMessageBox.Ok)
def connection_detection_failed(self):
QMessageBox.information(None, "Information", "Connection detection failed", QMessageBox.Ok)
---------------------------------------
So I first choose the correct port in the QGIS GPS Information Widget (mCboDevices) and then run this
code but nothing happens.
If I initialize detector with something like QgsGPSDetector('test') than connection_detection_failed is
called (as expected). With QgsGPSDetector('COM5') or QgsGPSDetector('\\\\.\\COM5')
connection_detection_failed is not called but connection_detected either. Do you have any idea what
I am doing wrong? Thank you very much.
Regards, Josua
_______________________________________________ Qgis-developer mailing list Qgis-developer at lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________ Qgis-developer mailing list Qgis-developer at lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the Qgis-developer
mailing list