1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

OP-435 Optionally allow building of GPS without support for GPSSatellites and GPSTime UAVObjects to save memory

This commit is contained in:
Corvus Corax 2011-04-25 21:55:05 +02:00
parent 55fbb5413b
commit bce51d4258
2 changed files with 20 additions and 2 deletions

View File

@ -197,6 +197,7 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
rx_packet->data.speed_over_ground = swap4Bytes(rx_packet->data.speed_over_ground);
rx_packet->data.year = swap2Bytes(rx_packet->data.year);
#if !defined(PIOS_GPS_PURISTIC)
// set the gps time object
GPSTimeData GpsTime;
// GPSTimeGet(&GpsTime);
@ -208,6 +209,7 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
GpsTime.Month = rx_packet->data.month; // month
GpsTime.Year = rx_packet->data.year; // year
GPSTimeSet(&GpsTime);
#endif //PIOS_GPS_PURISTIC
// set the gps position object
GPSPositionData GpsData;
@ -231,12 +233,14 @@ int GTOP_BIN_update_position(uint8_t b, volatile uint32_t *chksum_errors, volati
GpsData.VDOP = 99.99; // not available in binary mode
GPSPositionSet(&GpsData);
#if !defined(PIOS_GPS_PURISTIC)
// set the number of satellites
// GPSSatellitesData SattelliteData;
//// GPSSatellitesGet(&SattelliteData);
// memset(&SattelliteData, 0, sizeof(SattelliteData));
// SattelliteData.SatsInView = rx_packet->data.satellites_used; //
// GPSSatellitesSet(&SattelliteData);
#endif //PIOS_GPS_PURISTIC
// remove the spent binary packet from the buffer
gps_rx_buffer_wr -= sizeof(t_gps_bin_packet);

View File

@ -74,8 +74,10 @@ struct nmea_parser {
static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam);
static bool nmeaProcessGPVTG(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam);
static bool nmeaProcessGPGSA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam);
#if !defined(PIOS_GPS_PURISTIC)
static bool nmeaProcessGPZDA(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam);
static bool nmeaProcessGPGSV(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam);
#endif //PIOS_GPS_PURISTIC
#endif
static bool nmeaProcessPGTOP(GPSPositionData * GpsData, bool* gpsDataUpdated, char* param[], uint8_t nbParam);
@ -103,6 +105,7 @@ struct nmea_parser {
.handler = nmeaProcessGPRMC,
.cnt = 0,
},
#if !defined(PIOS_GPS_PURISTIC)
{
.prefix = "GPZDA",
.handler = nmeaProcessGPZDA,
@ -113,6 +116,7 @@ struct nmea_parser {
.handler = nmeaProcessGPGSV,
.cnt = 0,
},
#endif //PIOS_GPS_PURISTIC
#endif
{
.prefix = "PGTOP",
@ -445,6 +449,7 @@ static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
*gpsDataUpdated = true;
#if !defined(PIOS_GPS_PURISTIC)
GPSTimeData gpst;
GPSTimeGet(&gpst);
@ -453,6 +458,7 @@ static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
gpst.Second = (int)hms % 100;
gpst.Minute = (((int)hms - gpst.Second) / 100) % 100;
gpst.Hour = (int)hms / 10000;
#endif //PIOS_GPS_PURISTIC
// get latitude [DDMM.mmmmm] [N|S]
if (!NMEA_latlon_to_fixed_point(&GpsData->Latitude, param[3], param[4][0] == 'S')) {
@ -470,6 +476,7 @@ static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
// get True course
GpsData->Heading = NMEA_real_to_float(param[8]);
#if !defined(PIOS_GPS_PURISTIC)
// get Date of fix
// TODO: Should really not use a float here to be safe
float date = NMEA_real_to_float(param[9]);
@ -478,6 +485,7 @@ static bool nmeaProcessGPRMC(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
gpst.Day = (int)(date / 10000);
gpst.Year += 2000;
GPSTimeSet(&gpst);
#endif //PIOS_GPS_PURISTIC
return true;
}
@ -505,6 +513,7 @@ static bool nmeaProcessGPVTG(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
return true;
}
#if !defined(PIOS_GPS_PURISTIC)
/**
* Parse an NMEA GPZDA sentence and update the @ref GPSTime object
* \param[in] A pointer to a GPSPosition UAVObject to be updated (unused).
@ -627,6 +636,7 @@ static bool nmeaProcessGPGSV(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
return true;
}
#endif //PIOS_GPS_PURISTIC
/**
* Parse an NMEA GPGSA sentence and update the given UAVObject
@ -687,16 +697,18 @@ static bool nmeaProcessPGTOP(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
if (nbParam != 17)
return false;
*gpsDataUpdated = true;
#if !defined(PIOS_GPS_PURISTIC)
GPSTimeData gpst;
GPSTimeGet(&gpst);
*gpsDataUpdated = true;
// get UTC time [hhmmss.sss]
float hms = NMEA_real_to_float(param[1]);
gpst.Second = (int)hms % 100;
gpst.Minute = (((int)hms - gpst.Second) / 100) % 100;
gpst.Hour = (int)hms / 10000;
#endif //PIOS_GPS_PURISTIC
// get latitude decimal degrees
GpsData->Latitude = NMEA_real_to_float(param[2])*1e7;
@ -746,10 +758,12 @@ static bool nmeaProcessPGTOP(GPSPositionData * GpsData, bool* gpsDataUpdated, ch
// to m/s
GpsData->Groundspeed /= 3.6;
#if !defined(PIOS_GPS_PURISTIC)
gpst.Day = atoi(param[14]);
gpst.Month = atoi(param[15]);
gpst.Year = atoi(param[16]);
GPSTimeSet(&gpst);
#endif //PIOS_GPS_PURISTIC
return true;
}