<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">Hello</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">I am working on a Python plugin for QGIS 1.8. My goal is to automatically connect to a gps device at</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">a COM port. I tried to clone some code of qgsgpsinformationwidget.cpp and looks like this:</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">---------------------------------------</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">from qgis.core import *</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">from qgis.utils import *</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">from PyQt4.QtCore import *</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">from PyQt4.QtGui import *</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">devices_combo_box = qgis.utils.iface.mainWindow().findChild(QComboBox, 'mCboDevices')</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">com_port = devices_combo_box.itemData(devices_combo_box.currentIndex()).toString()</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">detector = QgsGPSDetector(com_port)</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">QObject.connect(detector, SIGNAL("detected( QgsGPSConnection )"), self.connection_detected)</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">QObject.connect(detector, SIGNAL("detectionFailed()"), self.connection_detection_failed)</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">detector.advance()</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">def connection_detected(self, gps_connection):</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">    QMessageBox.information(None, "Information", "Connection detected", QMessageBox.Ok)</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">def connection_detection_failed(self):</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">    QMessageBox.information(None, "Information", "Connection detection failed", QMessageBox.Ok)</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">---------------------------------------</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">So I first choose the correct port in the QGIS GPS Information Widget (mCboDevices) and then run this</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">code but nothing happens.</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">If I initialize detector with something like QgsGPSDetector('test') than connection_detection_failed is</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">called (as expected). With QgsGPSDetector('COM5') or QgsGPSDetector('\\\\.\\COM5')</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">connection_detection_failed is not called but connection_detected either. Do you have any idea what</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">I am doing wrong? Thank you very much.</div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;"><br></div><div style="line-height: 21px; color: rgb(68, 68, 68); font-size: 15px;">Regards, Josua</div>                                           </div></body>
</html>