How to get GPS data from serialPort?
Solved
General and Desktop
-
I can't get GPS data.
I am able to receive the data via serial communication, but no data is coming in using QGeoPositionInfoSource.TestGps::TestGps() { qDebug() << "Start Gps"; QVariantMap params; params["serialnmea.serial_port"] = "COM3"; QGeoPositionInfoSource *myGps = QGeoPositionInfoSource::createSource("serialnmea", params, this); qDebug() << myGps; if ( myGps ) { connect(myGps, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(fnTest(QGeoPositionInfo))); connect(myGps, SIGNAL(updateTimeout()), this, SLOT(fnTest2())); myGps->setUpdateInterval(1000); myGps->startUpdates(); } } void TestGps::fnTest(const QGeoPositionInfo &info) { qDebug() << "Pos Update: " << info; } void TestGps::fnTest2() { qDebug() << "Time Out!"; }
This code outputs [TimeOut].
Is it a timeout because the GPS data is not being received properly at the moment ?
The data received by the currently connected GPS is shown in the image. -
@w-tkm Please use "new" Qt5 connect syntax!
I don't see any signal called updateTimeout in https://doc.qt.io/qt-6/qgeopositioninfosource.html
You also should connect a slot to https://doc.qt.io/qt-6/qgeopositioninfosource.html#errorOccurred and print the error when it is called.