Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get GPS data from serialPort?
Qt 6.11 is out! See what's new in the release blog

How to get GPS data from serialPort?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 744 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    w.tkm
    wrote on last edited by w.tkm
    #1

    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.

    cap2.PNG

    jsulmJ 1 Reply Last reply
    0
    • W w.tkm

      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.

      cap2.PNG

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      W 1 Reply Last reply
      2
      • jsulmJ jsulm

        @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.

        W Offline
        W Offline
        w.tkm
        wrote on last edited by
        #3

        @jsulm
        Use Qt5 connect syntax, could get.
        Thanks!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved