Get positionSource with GPS receiver and serial port com
-
Hi! First check if there is a backend plugin available for your GPS receiver:
[static] QStringList QGeoPositionInfoSource::availableSources()
-
Hi !
I did what you asked and I have one available source plugin which is named geoclue.
How to know if it is the one corresponding to my device ?If it is the one, what to do next ?
Because my code is only in QML, so I have to add C++ files to keep back position from device and send a signal to QML file where there is the positionSource ? -
@Lulu31 said:
so I have to add C++ files to keep back position from device and send a signal to QML file where there is the positionSource ?
No. I just wanted to make sure that there is a plugin for your device. You can use the plugin like this:
PositionSource { id: src name: "geoclue" updateInterval: 1000 active: true onPositionChanged: { var coord = src.position.coordinate; console.log("Coordinate:", coord.longitude, coord.latitude); } }
-
@Wieland Ok I tried but I never receive a position and so never receive the PositionChanged signal ...
How do you know that geoclue is the plugin for my external device ? Because we can have the gps position with internet too ... -
@Lulu31 Oh. Looks like "geoclue" is this: https://www.freedesktop.org/wiki/Software/GeoClue/ :-/
-
Thank you !
I am not sure this is the thing that I need.
I can receive my gps position inside terminal using the following command : sudo stty -F /dev/ttyUSB0 ispeed 4800 && cat < /dev/ttyUSB0.
So I will try to read from QT directly.
Perhaps, there is a class in QT to do that ?
Anyway, I will search.
-
Okay, unfortunately the
nmeaSource
property of QML PositionSource only support simulation mode. So you'll need some C++ stuff to use your device. Take a look at this: QNmeaPositionInfoSource. If you create your own class, derived from QNmeaPositionInfoSource, and make this available to your QtQuick environment then things should work. Another possibility would be to follow the Log File Position Source (C++) example and subclassQGeoPositionInfoSource
to create a custom positioning source for your device. -
OP, could you explain how you integrated the QGeoPositionInfoSource code into your QML code?
I have created a plugin using
QGeoPositionInfoSourceFactory
that returns my subclass fromQGeoPositionInfoSource
.
Then I have created a qmldir file like so:module MyPositionModule plugin MyPositionPlugin
And tried:
positionSource: PositionSource { id: positionSrc updateInterval: 100 //ms name: "MyPositionPlugin" onPositionChanged: { console.log(positionSrc.position.coordinate.latitude, " ", positionSrc.position.coordinate.longitude); }
When I call
positionSrc.start()
thesourceError
property does not change (NoError). But I do not receive updates andpositionSrc.supportedPositioningMethods
prints garbage.P.S.: My plugin metadata is in the json:
{ "Keys": ["MyPositionPlugin"], "Provider": "Me", "Position": true, "Satellite": false, "Monitor": false, "Priority": 1000, "Testable": true }
-
@Lulu31 "I am using a positionSource in QML project.
It works in simulation mode when i put the positionSource.nmeasource = "nmealog.txt" "Hi ¿Lulu could you share this project with the nmealog.txt log file please?, i'm trying this but no success so far. Thank you
-
I am also trying to write a minimal qml app that uses the built in GPS to retrieve current position. I am not sure if I can use Qt positioning or if I should just parse the raw output of the GPS myself, like the OP did here, and extract the position manually. It seems very dirty to do it that way, I thought there would be a nice API in QML that I could use. Anyone can point to a simple example?