<div dir="ltr">I have done it before.  <a href="https://github.com/NathanW2/qmap/blob/master/src/qmap/gps_action.py#L37">https://github.com/NathanW2/qmap/blob/master/src/qmap/gps_action.py#L37</a><div><br></div><div style>

Although it's pretty much the same as what you have there.</div><div><br></div><div style>- Nathan</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 28, 2013 at 3:49 AM, Josua S <span dir="ltr"><<a href="mailto:josh-talk@hotmail.com" target="_blank">josh-talk@hotmail.com</a>></span> wrote:<br>

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


<br>
_______________________________________________ Qgis-developer mailing list <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a> <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>


_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</div></div></blockquote></div><br></div>