In QGIS I would like to establish a connection to my GPS device programmatically (not via button in the GPS control panel)
I found out how to get available ports with QgsGPSDetector i.e.
QgsGPSDetector.availablePorts()
[(u'localhost:2947:', u'Lokaler GPSD'), (u'\\\\.\\COM4', 'COM4:')]
and how to get information via QgsGPSConnection to a connected device (cp. Accessing GPS from QGIS 2.14.1/Python 2.7 /Windows10).
Via
connectionRegistry = QgsGPSConnectionRegistry().instance()
connectionList = connectionRegistry.connectionList()
i can do
connectionList[0].close() rp. .connect()
But if no device is initially connected via the GPS control panel, the .connectionList() return nothing, so I'm not shure how to connect / disconnect to a GPS device.
ADD/EDIT
tried
con = QgsGpsdConnection('localhost',2947,'local gpsd')
# or con = QgsGpsdConnection('localhost',2947,''), rsp.
con.connect()
>>> True
con.status()
>>> 1
cr = QgsGPSConnectionRegistry().instance()
cr.connectionList()
>>> []
I'd like to try this 'COM4', but the port parameter is an integer.
Connecting via GPS Information panel does not work with gpsd, only Autodetect and serial (COM4:):
Do I have to construct a QgsGPSConnection that i can
.connect()
and
.close()
?
