diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index 97151f2fb..8f78f9061 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -91,7 +91,12 @@ void updateGpsSettings(UAVObjEvent *ev); #else #if defined(PIOS_GPS_MINIMAL) #define GPS_READ_BUFFER 32 - #define STACK_SIZE_BYTES 500 + +#ifdef PIOS_INCLUDE_GPS_NMEA_PARSER + #define STACK_SIZE_BYTES 580 // NMEA +#else + #define STACK_SIZE_BYTES 440 // UBX +#endif // PIOS_INCLUDE_GPS_NMEA_PARSER #else #define STACK_SIZE_BYTES 650 #endif // PIOS_GPS_MINIMAL @@ -203,9 +208,11 @@ int32_t GPSInitialize(void) GPSSettingsInitialize(); GPSSettingsDataProtocolGet(&gpsProtocol); switch (gpsProtocol) { +#if defined(PIOS_INCLUDE_GPS_NMEA_PARSER) case GPSSETTINGS_DATAPROTOCOL_NMEA: gps_rx_buffer = pios_malloc(NMEA_MAX_PACKET_LENGTH); break; +#endif case GPSSETTINGS_DATAPROTOCOL_UBX: gps_rx_buffer = pios_malloc(sizeof(struct UBXPacket)); break; @@ -459,12 +466,12 @@ static void updateHwSettings() } } -#ifdef PIOS_INCLUDE_GPS_UBX_PARSER +#if defined(PIOS_INCLUDE_GPS_UBX_PARSER) && !defined(PIOS_GPS_MINIMAL) void AuxMagSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { load_mag_settings(); } -#if defined(PIOS_INCLUDE_GPS_UBX_PARSER) && !defined(PIOS_GPS_MINIMAL) + void updateGpsSettings(__attribute__((unused)) UAVObjEvent *ev) { uint8_t ubxAutoConfig; @@ -537,7 +544,6 @@ void updateGpsSettings(__attribute__((unused)) UAVObjEvent *ev) ubx_autoconfig_set(newconfig); } #endif /* if defined(PIOS_INCLUDE_GPS_UBX_PARSER) && !defined(PIOS_GPS_MINIMAL) */ -#endif /* ifdef PIOS_INCLUDE_GPS_UBX_PARSER */ /** * @} * @} diff --git a/flight/modules/GPS/NMEA.c b/flight/modules/GPS/NMEA.c index 34eba2f9f..7c33edf11 100644 --- a/flight/modules/GPS/NMEA.c +++ b/flight/modules/GPS/NMEA.c @@ -40,14 +40,13 @@ #include "GPS.h" // #define ENABLE_DEBUG_MSG ///< define to enable debug-messages -#define DEBUG_PORT PIOS_COM_TELEM_RF ///< defines which serial port is ued for debug-messages - +#define DEBUG_PORT PIOS_COM_TELEM_RF ///< defines which serial port is used for debug-messages // Debugging #ifdef ENABLE_DEBUG_MSG // #define DEBUG_MSG_IN ///< define to display the incoming NMEA messages // #define DEBUG_PARAMS ///< define to display the incoming NMEA messages split into its parameters -// #define DEBUG_MGSID_IN ///< define to display the the names of the incoming NMEA messages +// #define DEBUG_MSGID_IN ///< define to display the names of the incoming NMEA messages // #define NMEA_DEBUG_PKT ///< define to enable debug of all NMEA messages // #define NMEA_DEBUG_GGA ///< define to enable debug of GGA messages // #define NMEA_DEBUG_VTG ///< define to enable debug of VTG messages @@ -68,40 +67,40 @@ struct nmea_parser { bool (*handler)(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); }; -static bool nmeaProcessGPGGA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); -static bool nmeaProcessGPRMC(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); -static bool nmeaProcessGPVTG(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); -static bool nmeaProcessGPGSA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); +static bool nmeaProcessGxGGA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); +static bool nmeaProcessGxRMC(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); +static bool nmeaProcessGxVTG(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); +static bool nmeaProcessGxGSA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); #if !defined(PIOS_GPS_MINIMAL) -static bool nmeaProcessGPZDA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); -static bool nmeaProcessGPGSV(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); +static bool nmeaProcessGxZDA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); +static bool nmeaProcessGxGSV(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam); #endif // PIOS_GPS_MINIMAL static const struct nmea_parser nmea_parsers[] = { { - .prefix = "GPGGA", - .handler = nmeaProcessGPGGA, + .prefix = "GGA", + .handler = nmeaProcessGxGGA, }, { - .prefix = "GPVTG", - .handler = nmeaProcessGPVTG, + .prefix = "VTG", + .handler = nmeaProcessGxVTG, }, { - .prefix = "GPGSA", - .handler = nmeaProcessGPGSA, + .prefix = "GSA", + .handler = nmeaProcessGxGSA, }, { - .prefix = "GPRMC", - .handler = nmeaProcessGPRMC, + .prefix = "RMC", + .handler = nmeaProcessGxRMC, }, #if !defined(PIOS_GPS_MINIMAL) { - .prefix = "GPZDA", - .handler = nmeaProcessGPZDA, + .prefix = "ZDA", + .handler = nmeaProcessGxZDA, }, { - .prefix = "GPGSV", - .handler = nmeaProcessGPGSV, + .prefix = "GSV", + .handler = nmeaProcessGxGSV, }, #endif // PIOS_GPS_MINIMAL }; @@ -373,6 +372,8 @@ bool NMEA_update_position(char *nmea_sentence, GPSPositionSensorData *GpsData) // Sample NMEA message: "GPRMC,000131.736,V,,,,,0.00,0.00,060180,,,N*43" // The first parameter starts at the beginning of the message + // Skip first two character, allow GL, GN, GP... + p += 2; params[0] = p; nbParams = 1; while (*p != 0) { @@ -406,11 +407,13 @@ bool NMEA_update_position(char *nmea_sentence, GPSPositionSensorData *GpsData) parser = NMEA_find_parser_by_prefix(params[0]); if (!parser) { // No parser found + #ifdef DEBUG_MSGID_IN DEBUG_MSG(" NO PARSER (\"%s\")\n", params[0]); + #endif return false; } - #ifdef DEBUG_MGSID_IN + #ifdef DEBUG_MSGID_IN DEBUG_MSG("%s %d ", params[0]); #endif // Send the message to the parser and get it update the GpsData @@ -422,7 +425,9 @@ bool NMEA_update_position(char *nmea_sentence, GPSPositionSensorData *GpsData) if (!parser->handler(GpsData, &gpsDataUpdated, params, nbParams)) { // Parse failed + #ifdef DEBUG_MSGID_IN DEBUG_MSG("PARSE FAILED (\"%s\")\n", params[0]); + #endif if (gpsDataUpdated && (GpsData->Status == GPSPOSITIONSENSOR_STATUS_NOFIX)) { GPSPositionSensorSet(GpsData); } @@ -432,13 +437,13 @@ bool NMEA_update_position(char *nmea_sentence, GPSPositionSensorData *GpsData) // All is fine :) Update object if data has changed if (gpsDataUpdated) { - #ifdef DEBUG_MGSID_IN + #ifdef DEBUG_MSGID_IN DEBUG_MSG("U"); #endif GPSPositionSensorSet(GpsData); } - #ifdef DEBUG_MGSID_IN + #ifdef DEBUG_MSGID_IN DEBUG_MSG("\n"); #endif return true; @@ -446,11 +451,11 @@ bool NMEA_update_position(char *nmea_sentence, GPSPositionSensorData *GpsData) /** - * Parse an NMEA GPGGA sentence and update the given UAVObject + * Parse an NMEA GxGGA sentence and update the given UAVObject * \param[in] A pointer to a GPSPositionSensor UAVObject to be updated. * \param[in] An NMEA sentence with a valid checksum */ -static bool nmeaProcessGPGGA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) +static bool nmeaProcessGxGGA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) { if (nbParam != 15) { return false; @@ -499,11 +504,11 @@ static bool nmeaProcessGPGGA(GPSPositionSensorData *GpsData, bool *gpsDataUpdate } /** - * Parse an NMEA GPRMC sentence and update the given UAVObject + * Parse an NMEA GxRMC sentence and update the given UAVObject * \param[in] A pointer to a GPSPositionSensor UAVObject to be updated. * \param[in] An NMEA sentence with a valid checksum */ -static bool nmeaProcessGPRMC(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) +static bool nmeaProcessGxRMC(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) { if (nbParam != 13) { return false; @@ -567,11 +572,11 @@ static bool nmeaProcessGPRMC(GPSPositionSensorData *GpsData, bool *gpsDataUpdate } /** - * Parse an NMEA GPVTG sentence and update the given UAVObject + * Parse an NMEA GxVTG sentence and update the given UAVObject * \param[in] A pointer to a GPSPositionSensor UAVObject to be updated. * \param[in] An NMEA sentence with a valid checksum */ -static bool nmeaProcessGPVTG(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) +static bool nmeaProcessGxVTG(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) { if (nbParam != 9 && nbParam != 10 /*GTOP GPS seems to gemnerate an extra parameter...*/) { return false; @@ -592,11 +597,11 @@ static bool nmeaProcessGPVTG(GPSPositionSensorData *GpsData, bool *gpsDataUpdate #if !defined(PIOS_GPS_MINIMAL) /** - * Parse an NMEA GPZDA sentence and update the @ref GPSTime object + * Parse an NMEA GxZDA sentence and update the @ref GPSTime object * \param[in] A pointer to a GPSPositionSensor UAVObject to be updated (unused). * \param[in] An NMEA sentence with a valid checksum */ -static bool nmeaProcessGPZDA(__attribute__((unused)) GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) +static bool nmeaProcessGxZDA(__attribute__((unused)) GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) { if (nbParam != 7) { return false; @@ -636,7 +641,7 @@ static uint8_t gsv_processed_mask; static uint16_t gsv_incomplete_error; static uint16_t gsv_duplicate_error; -static bool nmeaProcessGPGSV(__attribute__((unused)) GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) +static bool nmeaProcessGxGSV(__attribute__((unused)) GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) { if (nbParam < 4) { return false; @@ -723,7 +728,7 @@ static bool nmeaProcessGPGSV(__attribute__((unused)) GPSPositionSensorData *GpsD * \param[in] A pointer to a GPSPositionSensor UAVObject to be updated. * \param[in] An NMEA sentence with a valid checksum */ -static bool nmeaProcessGPGSA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) +static bool nmeaProcessGxGSA(GPSPositionSensorData *GpsData, bool *gpsDataUpdated, char *param[], uint8_t nbParam) { if (nbParam != 18) { return false; diff --git a/flight/targets/boards/coptercontrol/firmware/Makefile b/flight/targets/boards/coptercontrol/firmware/Makefile index 799013726..d58b57e64 100644 --- a/flight/targets/boards/coptercontrol/firmware/Makefile +++ b/flight/targets/boards/coptercontrol/firmware/Makefile @@ -30,6 +30,12 @@ USE_DSP_LIB ?= NO # Set to YES to build a FW version that will erase data flash memory ERASE_FLASH ?= NO +# Set to yes to include Gcsreceiver module +GCSRECEIVER ?= NO + +# Enable Diag tasks ? +DIAG_TASKS ?= NO + # List of mandatory modules to include MODULES += Attitude MODULES += Stabilization @@ -103,7 +109,6 @@ ifndef TESTAPP SRC += $(OPUAVSYNTHDIR)/gyrostate.c SRC += $(OPUAVSYNTHDIR)/attitudestate.c SRC += $(OPUAVSYNTHDIR)/manualcontrolcommand.c - SRC += $(OPUAVSYNTHDIR)/i2cstats.c SRC += $(OPUAVSYNTHDIR)/watchdogstatus.c SRC += $(OPUAVSYNTHDIR)/manualcontrolsettings.c SRC += $(OPUAVSYNTHDIR)/flightmodesettings.c @@ -116,15 +121,23 @@ ifndef TESTAPP SRC += $(OPUAVSYNTHDIR)/gpsvelocitysensor.c SRC += $(OPUAVSYNTHDIR)/gpssettings.c SRC += $(OPUAVSYNTHDIR)/hwsettings.c - SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c SRC += $(OPUAVSYNTHDIR)/receiveractivity.c - SRC += $(OPUAVSYNTHDIR)/taskinfo.c - SRC += $(OPUAVSYNTHDIR)/callbackinfo.c SRC += $(OPUAVSYNTHDIR)/mixerstatus.c SRC += $(OPUAVSYNTHDIR)/ratedesired.c SRC += $(OPUAVSYNTHDIR)/txpidsettings.c SRC += $(OPUAVSYNTHDIR)/mpu6000settings.c - SRC += $(OPUAVSYNTHDIR)/perfcounter.c + # Command line option for Gcsreceiver module + ifeq ($(GCSRECEIVER), YES) + SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c + endif + # Enable Diag tasks and UAVOs needed + ifeq ($(DIAG_TASKS), YES) + CDEFS += -DDIAG_TASKS + SRC += $(OPUAVSYNTHDIR)/taskinfo.c + SRC += $(OPUAVSYNTHDIR)/callbackinfo.c + SRC += $(OPUAVSYNTHDIR)/perfcounter.c + SRC += $(OPUAVSYNTHDIR)/i2cstats.c + endif else ## Test Code SRC += $(OPTESTS)/test_common.c diff --git a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h index 9450a6781..aabc651a7 100644 --- a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h +++ b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h @@ -97,10 +97,10 @@ /* PIOS receiver drivers */ #define PIOS_INCLUDE_PWM #define PIOS_INCLUDE_PPM -#define PIOS_INCLUDE_PPM_FLEXI +/* #define PIOS_INCLUDE_PPM_FLEXI */ #define PIOS_INCLUDE_DSM #define PIOS_INCLUDE_SBUS -#define PIOS_INCLUDE_GCSRCVR +/* #define PIOS_INCLUDE_GCSRCVR */ /* #define PIOS_INCLUDE_OPLINKRCVR */ /* PIOS abstract receiver interface */ @@ -142,7 +142,7 @@ /* #define PIOS_TELEM_PRIORITY_QUEUE */ #define PIOS_INCLUDE_GPS #define PIOS_GPS_MINIMAL -#define PIOS_INCLUDE_GPS_NMEA_PARSER +/* #define PIOS_INCLUDE_GPS_NMEA_PARSER */ #define PIOS_INCLUDE_GPS_UBX_PARSER /* #define PIOS_GPS_SETS_HOMELOCATION */