[Qgis-developer] Connect to GPS device

Josua S josh-talk at hotmail.com
Wed Jun 26 05:16:04 PDT 2013


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 ata 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 thiscode but nothing happens.
If I initialize detector with something like QgsGPSDetector('test') than connection_detection_failed iscalled (as expected). With QgsGPSDetector('COM5') or QgsGPSDetector('\\\\.\\COM5')connection_detection_failed is not called but connection_detected either. Do you have any idea whatI 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 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130626/ce0469e7/attachment-0001.html>


More information about the Qgis-developer mailing list