21 changes: 18 additions & 3 deletions src/core/gps/qgsnmeaconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
//from libnmea
#include "parse.h"
#include "gmath.h"
#include "info.h"

#define KNOTS_TO_KMH 1.852

Expand All @@ -48,7 +49,7 @@ void QgsNMEAConnection::parseData()

//print out the data as a test
qint64 numBytes = 0;
if ( mSource->isSequential() ) //necessary because of a bug in QExtSerialPort
if ( ! mSource->isSequential() ) //necessary because of a bug in QExtSerialPort //SLM - bytesAvailable() works on Windows, so I reversed the logic (added ! ); this is what QIODevice docs say to do; the orig impl of win_qextserialport had an (unsigned int)-1 return on error - it should be (qint64)-1, which was fixed by ?
{
numBytes = mSource->size();
}
Expand Down Expand Up @@ -130,6 +131,7 @@ void QgsNMEAConnection::processStringBuffer()
mStatus = GPSDataReceived;
QgsDebugMsg( "*******************GPS data received****************" );
}
emit nmeaSentenceReceived( substring ); // added to be able to save raw data
}
}
mStringBuffer.remove( 0, endSentenceIndex + 2 );
Expand All @@ -156,6 +158,8 @@ void QgsNMEAConnection::processGGASentence( const char* data, int len )
mLastGPSInformation.longitude = nmea_ndeg2degree( longitude );
mLastGPSInformation.latitude = nmea_ndeg2degree( latitude );
mLastGPSInformation.elevation = result.elv;
mLastGPSInformation.quality = result.sig;
mLastGPSInformation.satellitesUsed = result.satinuse;
}
}

Expand All @@ -178,10 +182,11 @@ void QgsNMEAConnection::processRMCSentence( const char* data, int len )
mLastGPSInformation.latitude = nmea_ndeg2degree( latitude );
mLastGPSInformation.speed = KNOTS_TO_KMH * result.speed;
mLastGPSInformation.direction = result.direction;
mLastGPSInformation.status = result.status; // A,V

//date and time
QDate date( result.utc.year + 1900, result.utc.mon + 1, result.utc.day );
QTime time( result.utc.hour, result.utc.min, result.utc.sec );
QTime time( result.utc.hour, result.utc.min, result.utc.sec, result.utc.msec ); // added msec part
if ( date.isValid() && time.isValid() )
{
mLastGPSInformation.utcDateTime.setTimeSpec( Qt::UTC );
Expand All @@ -206,14 +211,17 @@ void QgsNMEAConnection::processGSVSentence( const char* data, int len )
mLastGPSInformation.satellitesInView.clear();
}

// for determining when to graph sat info
mLastGPSInformation.satInfoComplete = ( result.pack_index == result.pack_count );

for ( int i = 0; i < NMEA_SATINPACK; ++i )
{
nmeaSATELLITE currentSatellite = result.sat_data[i];
QgsSatelliteInfo satelliteInfo;
satelliteInfo.azimuth = currentSatellite.azimuth;
satelliteInfo.elevation = currentSatellite.elv;
satelliteInfo.id = currentSatellite.id;
satelliteInfo.inUse = currentSatellite.in_use;
satelliteInfo.inUse = currentSatellite.in_use; // the GSA processing below does NOT set the sats in use
satelliteInfo.signal = currentSatellite.sig;
mLastGPSInformation.satellitesInView.append( satelliteInfo );
}
Expand All @@ -235,8 +243,15 @@ void QgsNMEAConnection::processGSASentence( const char* data, int len )
nmeaGPGSA result;
if ( nmea_parse_GPGSA( data, len, &result ) )
{
mLastGPSInformation.satPrn.clear();
mLastGPSInformation.hdop = result.HDOP;
mLastGPSInformation.pdop = result.PDOP;
mLastGPSInformation.vdop = result.VDOP;
mLastGPSInformation.fixMode = result.fix_mode;
mLastGPSInformation.fixType = result.fix_type;
for ( int i = 0; i < NMEA_MAXSAT; i++ )
{
mLastGPSInformation.satPrn.append( result.sat_prn[ i ] );
}
}
}
4 changes: 2 additions & 2 deletions src/core/gps/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void nmea_time_now( nmeaTIME *stm )
stm->hour = st.wHour;
stm->min = st.wMinute;
stm->sec = st.wSecond;
stm->hsec = st.wMilliseconds / 10;
stm->msec = st.wMilliseconds;
}

#else /* NMEA_WIN */
Expand All @@ -57,7 +57,7 @@ void nmea_time_now( nmeaTIME *stm )
stm->hour = tt->tm_hour;
stm->min = tt->tm_min;
stm->sec = tt->tm_sec;
stm->hsec = 0;
stm->msec = 0;
}

#endif
6 changes: 0 additions & 6 deletions src/ui/qgisapp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
<addaction name="mActionShowBookmarks"/>
<addaction name="mActionDraw"/>
<addaction name="mActionTileScale"/>
<addaction name="mActionGpsTool"/>
</widget>
<widget class="QMenu" name="mLayerMenu">
<property name="title">
Expand Down Expand Up @@ -1187,11 +1186,6 @@
<string>Tile scale slider</string>
</property>
</action>
<action name="mActionGpsTool">
<property name="text">
<string>Live GPS tracking</string>
</property>
</action>
<action name="mActionLayerProperties">
<property name="text">
<string>Properties...</string>
Expand Down
1,231 changes: 945 additions & 286 deletions src/ui/qgsgpsinformationwidgetbase.ui

Large diffs are not rendered by default.