[Qgis-developer] Connect to GPS device

Nathan Woodrow madmanwoo at gmail.com
Thu Jun 27 15:56:53 PDT 2013


I have done it before.
https://github.com/NathanW2/qmap/blob/master/src/qmap/gps_action.py#L37

Although it's pretty much the same as what you have there.

- Nathan


On Fri, Jun 28, 2013 at 3:49 AM, Josua S <josh-talk at hotmail.com> wrote:

> 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
> _______________________________________________
> 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/20130628/a3871675/attachment-0001.html>


More information about the Qgis-developer mailing list