19 #include "qextserialport.h"
23 #include <QApplication>
24 #include <QStringList>
32 #define KNOTS_TO_KMH 1.852
52 if ( !
mSource->isSequential() )
58 numBytes =
mSource->bytesAvailable();
61 QgsDebugMsg(
"numBytes:" + QString::number( numBytes ) );
79 int endSentenceIndex = 0;
82 while (( endSentenceIndex =
mStringBuffer.indexOf(
"\r\n" ) ) && endSentenceIndex != -1 )
87 if ( endSentenceIndex == -1 )
93 if ( endSentenceIndex >= dollarIndex )
95 if ( dollarIndex != -1 )
97 QString substring =
mStringBuffer.mid( dollarIndex, endSentenceIndex );
98 QByteArray ba = substring.toLocal8Bit();
99 if ( substring.startsWith(
"$GPGGA" ) )
104 QgsDebugMsg(
"*******************GPS data received****************" );
106 else if ( substring.startsWith(
"$GPRMC" ) )
111 QgsDebugMsg(
"*******************GPS data received****************" );
113 else if ( substring.startsWith(
"$GPGSV" ) )
118 QgsDebugMsg(
"*******************GPS data received****************" );
120 else if ( substring.startsWith(
"$GPVTG" ) )
125 QgsDebugMsg(
"*******************GPS data received****************" );
127 else if ( substring.startsWith(
"$GPGSA" ) )
132 QgsDebugMsg(
"*******************GPS data received****************" );
147 double longitude = result.
lon;
148 if ( result.
ew ==
'W' )
150 longitude = -longitude;
152 double latitude = result.
lat;
153 if ( result.
ns ==
'S' )
155 latitude = -latitude;
171 double longitude = result.
lon;
172 if ( result.
ew ==
'W' )
174 longitude = -longitude;
176 double latitude = result.
lat;
177 if ( result.
ns ==
'S' )
179 latitude = -latitude;
190 if ( date.isValid() && time.isValid() )
223 satelliteInfo.
id = currentSatellite.
id;
225 satelliteInfo.
signal = currentSatellite.
sig;