Uploaded image for project: 'Qt Mobility'
  1. Qt Mobility
  2. QTMOBILITY-2054

positionUpdated signal not emitted on QNmeaPositionInfoSource using SerialPort device.



    • Type: Bug
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: Location
    • Labels:
    • Environment:
      Ubuntu 12.04 x86


      P.s.: I'm using Qt Mobility to Desktop. I compile it form this source code http://get.qt.nokia.com/qt/add-ons/qt-mobility-opensource-src-1.2.0.tar.gz (without problem).

      1. Problem:
        I'm using a SerialPort (http://qt-project.org/wiki/QtSerialPort) as QIODevice for QNmeaPositionInfoSource, and the positionUpdated(const QGeoPositionInfo) signal is NOT being emited when it should.
      1. Tests:
        The SerialPort class is emiting QIODevice::readyRead() signal as expected (http://doc.qt.nokia.com/qtmobility/qnmeapositioninfosource.html#setDevice), and the data (NMEA string from a GPS) is comming as it should. I test it both things.
      1. My Solution:
        I went into to the QNmeaPositionInfoSource source code and I think I find out why this is happening.
        At this fucniton "void QNmeaRealTimeReader::readAvailableData()" (qnmeapositioninfosource.cpp:57) it is made this test:

      qint64 size = m_proxy->m_device->readLine(buf, sizeof(buf));
      while (size > 0)

      { ... }

      As expected from the documentation the readLine(...) function reads ALL buffer data even if there is no "\n" in it. I quote the documentation:
      "Data is read until either of the following conditions are met: ... * The end of the device data is detected." (http://doc.qt.nokia.com/4.7-snapshot/qiodevice.html#readLine)
      It reads all device buffer data without being a actual LINE on it. In other words, it gets the data even if in this particulary case when canReadLine() would returns FALSE (because that is no actual LINE in buffer).

      Then, after reading this "incomplete line", it trys unsuccessfully to parse the data anyway and dump the readed content.

      I made this change (below) and it works:

      void QNmeaRealTimeReader::readAvailableData()
      if (m_proxy->m_device->canReadLine())

      { QGeoPositionInfo update; bool hasFix = false; char buf[1024]; qint64 size = m_proxy->m_device->readLine(buf, sizeof(buf)); if (m_proxy->parsePosInfoFromNmeaData(buf, size, &update, &hasFix)) m_proxy->notifyNewUpdate(&update, hasFix); memset(buf, 0, size); }



        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            korva Jaakko Koskenkorva
            gstabel Gabriel C. Stabel
            1 Vote for this issue
            4 Start watching this issue



                Gerrit Reviews

                There are no open Gerrit changes