1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-52 Ground/GPS Display: some updates, ZDA&VTG

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2048 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
sambas 2010-10-31 08:01:56 +00:00 committed by sambas
parent 206700830e
commit 634543dc27
2 changed files with 43 additions and 0 deletions

View File

@ -43,6 +43,7 @@
#define NMEA_GPGSV 4 // GPS satellites in view
#define NMEA_GPGSA 5 // GPS DOP and active satellites
#define NMEA_GPRMC 6 // Recommended minimum specific GPS data
#define NMEA_GPZDA 7 // Time and Date
#define NMEA_UNKNOWN 0xFF// Packet received but not known
#define GPS_TIMEOUT_MS 500
@ -58,6 +59,7 @@
#define NMEA_DEBUG_VTG ///< define to enable debug of VTG messages
#define NMEA_DEBUG_RMC ///< define to enable debug of RMC messages
#define NMEA_DEBUG_GSA ///< define to enable debug of GSA messages
#define NMEA_DEBUG_ZDA ///< define to enable debug of ZDA messages
#endif
/**
@ -255,6 +257,13 @@ uint8_t NMEAParser::nmeaProcess(cBuffer* rxBuffer)
// rerpot packet type
foundpacket = NMEA_GPGSV;
}
else if(!strncmp(NmeaPacket, "GPZDA", 5))
{
// Process packet of this type
nmeaProcessGPZDA(NmeaPacket);
// rerpot packet type
foundpacket = NMEA_GPZDA;
}
}
else if(rxBuffer->datalength >= rxBuffer->size)
{
@ -412,6 +421,11 @@ void NMEAParser::nmeaProcessGPVTG(char* packet)
QString nmeaString( packet );
QStringList tokenslist = nmeaString.split(",");
GpsData.Heading = tokenslist.at(1).toDouble();
GpsData.Groundspeed = tokenslist.at(7).toDouble();
GpsData.Groundspeed = GpsData.Groundspeed/3.6;
emit speedheading(GpsData.Groundspeed,GpsData.Heading);
}
/**
@ -471,3 +485,31 @@ void NMEAParser::nmeaProcessGPGSA(char* packet)
GpsData.VDOP = tokenslist.at(17).toDouble();
emit dop(GpsData.HDOP, GpsData.VDOP, GpsData.PDOP);
}
/**
* Prosesses NMEA GPZDA sentences
* \param[in] Buffer for parsed nmea GPZDA sentence
*/
void NMEAParser::nmeaProcessGPZDA(char* packet)
{
// start parsing just after "GPZDA,"
// attempt to reject empty packets right away
if(packet[6]==',' && packet[7]==',')
return;
if(!nmeaChecksum(packet)) {
// checksum not valid
return;
}
nmeaTerminateAtChecksum(packet);
QString nmeaString( packet );
QStringList tokenslist = nmeaString.split(",");
GpsData.GPStime = tokenslist.at(1).toDouble();
int day = tokenslist.at(2).toInt();
int month = tokenslist.at(3).toInt();
int year = tokenslist.at(4).toInt();
GpsData.GPSdate = day*10000+month*100+(year-2000);
emit datetime(GpsData.GPSdate,GpsData.GPStime);
}

View File

@ -72,6 +72,7 @@ public:
void nmeaProcessGPVTG(char* packet);
void nmeaProcessGPGSA(char* packet);
void nmeaProcessGPGSV(char* packet);
void nmeaProcessGPZDA(char* packet);
GpsData_t GpsData;
cBuffer gpsRxBuffer;
char gpsRxData[512];