Display device location with NMEA data sources(QT,100.11,C++)

746
1
05-18-2021 10:59 AM
cwaller
New Contributor

I have tried to implement your newer tools regarding NMEA sources. Using QSerialPort I am able to read the port etc., but when I push the data back using NmeaLocationDataSource::pushData nothing happens. I have tried a lot of different ways to parse the data and update the location but the location never changes. Could someone make an example using realtime mode (not simulation) and for C++/QML . I'm sure the developers that make the GIT Samples are working on one, or at least hopefully are. But I am in need of an answer sooner than later. Thanks!
 

0 Kudos
1 Reply
MartonFeigl
Esri Contributor

Hello @cwaller 

I have created a quick sample code which exercises the QSerialPort on Windows and it works for me. In this code snippet I hard-coded the port parameters, but it should be fine since you said you can read the port without problems:

void nmeaTestClass::startGpsLocationReading()
{
  QSerialPort* serialPort = new QSerialPort();
  NmeaLocationDataSource* nmeaLocationDataSource = new NmeaLocationDataSource(this);
  m_mapview->locationDisplay()->setDataSource(nmeaLocationDataSource);

  connect(serialPort, &QSerialPort::readyRead, this, [serialPort, nmeaLocationDataSource]()
          {
            const QByteArray locData = serialPort->readLine(1024);
            nmeaLocationDataSource->pushData(locData);
          });
  serialPort->setPortName("COM4");
  serialPort->setBaudRate(9600);
  serialPort->setDataBits(QSerialPort::DataBits::Data8);
  serialPort->setParity(QSerialPort::Parity::NoParity);
  serialPort->setStopBits(QSerialPort::StopBits::OneStop);
  serialPort->setFlowControl(QSerialPort::FlowControl::NoFlowControl);

  serialPort->open(QIODevice::ReadWrite);

  m_mapview->locationDisplay()->start();
}

May I ask if you were following similar steps? If so, and still doesn't work, then if you could share your code-snippet that would be great help. Also, may I ask what platform are you trying to run your application?

Also, unfortunately QML does not support QSerialPort, but QBluetoothSocket is supported on both C++ and QML.

0 Kudos