[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qgis-developer
Subject:    Re: [Qgis-developer] Connect to GPS device
From:       Nathan Woodrow <madmanwoo () gmail ! com>
Date:       2013-06-27 22:56:53
Message-ID: CAAi8Yg97jiq-spxn2XrJ4qwb5FK0ZBqcgSTz=6o0QxWWTZyiQQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@hotmail.com
> To: qgis-developer@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@hotmail.com
> To: qgis-developer@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@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> _______________________________________________ Qgis-developer mailing
> list Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>

[Attachment #5 (text/html)]

<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&#39;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">&lt;<a href="mailto:josh-talk@hotmail.com" \
target="_blank">josh-talk@hotmail.com</a>&gt;</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&#39;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, \
&#39;mCboDevices&#39;)<br> com_port = \
devices_combo_box.itemData(devices_combo_box.currentIndex()).toString()<br> detector \
= QgsGPSDetector(com_port)<br> QObject.connect(detector, SIGNAL(&quot;detected( \
QgsGPSConnection )&quot;), self.connection_detected)<br> QObject.connect(detector, \
SIGNAL(&quot;detectionFailed()&quot;), self.connection_detection_failed)<br> \
detector.advance()<br> <br>
def connection_detected(self, gps_connection):<br>
    QMessageBox.information(None, &quot;Information&quot;, &quot;Connection \
detected&quot;, QMessageBox.Ok)<br> <br>
def connection_detection_failed(self):<br>
    QMessageBox.information(None, &quot;Information&quot;, &quot;Connection detection \
                failed&quot;, 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(&#39;test&#39;) than \
connection_detection_failed is<br> called (as expected). With \
QgsGPSDetector(&#39;COM5&#39;) or QgsGPSDetector(&#39;\\\\.\\COM5&#39;)<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>



_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic