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;
char ns
[N]orth or [S]outh
void nmeaSentenceReceived(const QString &substring)
Information about satellite.
int nmea_parse_GPVTG(const char *buff, int buff_sz, nmeaGPVTG *pack)
int azimuth
Azimuth, degrees from true north, 000 to 359.
char ns
[N]orth or [S]outh
Status mStatus
Connection status.
void processRMCSentence(const char *data, int len)
double nmea_ndeg2degree(double val)
int hour
Hours since midnight - [0,23].
int mon
Months since January - [0,11].
int id
Satellite PRN number.
double lon
Longitude in NDEG - [degree][min].
GGA packet information structure (Global Positioning System Fix Data)
double lat
Latitude in NDEG - [degree][min].
int year
Years since 1900.
double spk
Ground speed, kilometers per hour.
VTG packet information structure (Track made good and ground speed)
int satinuse
Number of satellites in use (not those in view)
int nmea_parse_GPRMC(const char *buff, int buff_sz, nmeaGPRMC *pack)
double lat
Latitude in NDEG - [degree][min].
void processStringBuffer()
Splits mStringBuffer into sentences and calls libnmea.
double direction
Track angle in degrees True.
QString mStringBuffer
Store data from the device before it is processed.
char status
Status (A = active or V = void)
int elv
Elevation in degrees, 90 maximum.
void processGSASentence(const char *data, int len)
int day
Day of the month - [1,31].
double VDOP
Vertical dilution of precision.
Abstract base class for connection to a GPS device.
QgsNMEAConnection(QIODevice *dev)
double elv
Antenna altitude above/below mean sea level (geoid)
QgsGPSInformation mLastGPSInformation
Last state of the gps related variables (e.g.
double speed
Speed over the ground in knots.
void parseData()
Parse available data source content.
int nmea_parse_GPGGA(const char *buff, int buff_sz, nmeaGPGGA *pack)
void processGGASentence(const char *data, int len)
char fix_mode
Mode (M = Manual, forced to operate in 2D or 3D; A = Automatic, 3D/2D)
int nmea_parse_GPGSV(const char *buff, int buff_sz, nmeaGPGSV *pack)
QIODevice * mSource
Data source (e.g.
GSA packet information structure (Satellite status)
int pack_index
Message number.
nmeaTIME utc
UTC of position.
void stateChanged(const QgsGPSInformation &info)
void processGSVSentence(const char *data, int len)
void processVTGSentence(const char *data, int len)
double lon
Longitude in NDEG - [degree][min].
int pack_count
Total number of messages of this type in this cycle.
int sig
GPS quality indicator (0 = Invalid; 1 = Fix; 2 = Differential, 3 = Sensitive)
GSV packet information structure (Satellites in view)
int sec
Seconds after the minute - [0,59].
nmeaSATELLITE sat_data[NMEA_SATINPACK]
int msec
Thousandths part of second - [0,999].
int sat_prn[NMEA_MAXSAT]
PRNs of satellites used in position fix (null for unused fields)
int min
Minutes after the hour - [0,59].
int in_use
Used in position fix.
int fix_type
Type, used for navigation (1 = Fix not available; 2 = 2D; 3 = 3D)
double HDOP
Horizontal dilution of precision.
RMC packet information structure (Recommended Minimum sentence C)
double PDOP
Dilution of precision.
int nmea_parse_GPGSA(const char *buff, int buff_sz, nmeaGPGSA *pack)