From 1279352a956e8660f09f8e328b737c8b253badac Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Wed, 22 May 2019 20:18:44 +0200 Subject: [PATCH] LP-457 Call set_fc_baud_from_settings only from/to DJI == avoid trouble for Ubxautoconfig. --- flight/modules/GPS/DJI.c | 2 ++ flight/modules/GPS/GPS.c | 26 +++++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/flight/modules/GPS/DJI.c b/flight/modules/GPS/DJI.c index a178e1cf2..07e8d85d6 100644 --- a/flight/modules/GPS/DJI.c +++ b/flight/modules/GPS/DJI.c @@ -382,6 +382,8 @@ uint32_t parse_dji_message(struct DJIPacket *dji, GPSPositionSensorData *gpsPosi gpsPosition->HDOP = 99.99f; gpsPosition->PDOP = 99.99f; gpsPosition->VDOP = 99.99f; + // clear out satellite data because DJI doesn't provide it + GPSSatellitesSetDefaults(GPSSatellitesHandle(), 0); djiInitialized = true; } diff --git a/flight/modules/GPS/GPS.c b/flight/modules/GPS/GPS.c index fd7eb9a05..31a174bae 100644 --- a/flight/modules/GPS/GPS.c +++ b/flight/modules/GPS/GPS.c @@ -571,15 +571,14 @@ static void gps_set_fc_baud_from_settings() uint8_t speed; // Retrieve settings + HwSettingsGPSSpeedGet(&speed); + #if defined(PIOS_INCLUDE_GPS_DJI_PARSER) && !defined(PIOS_GPS_MINIMAL) if (gpsSettings.DataProtocol == GPSSETTINGS_DATAPROTOCOL_DJI) { speed = HWSETTINGS_GPSSPEED_115200; - } else { -#endif - HwSettingsGPSSpeedGet(&speed); -#if defined(PIOS_INCLUDE_GPS_DJI_PARSER) && !defined(PIOS_GPS_MINIMAL) -} + } #endif + // set fc baud gps_set_fc_baud_from_arg(speed); } @@ -663,16 +662,19 @@ void AuxMagSettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) #if defined(ANY_FULL_GPS_PARSER) void updateGpsSettings(__attribute__((unused)) UAVObjEvent *ev) { + GPSSettingsDataProtocolOptions previous_data_protocol = gpsSettings.DataProtocol; ubx_autoconfig_settings_t newconfig; GPSSettingsGet(&gpsSettings); #if defined(PIOS_INCLUDE_GPS_DJI_PARSER) - // each time there is a protocol change, set the baud rate - // so that DJI can be forced to 115200, but changing to another protocol will change the baud rate to the user specified value // note that changes to HwSettings GPS baud rate are detected in the HwSettings callback, - // but changing to/from DJI is effectively a baud rate change because DJI is forced to be 115200 - gps_set_fc_baud_from_settings(); // knows to force 115200 for DJI + // but changing to/from DJI in GPSSettings is effectively a baud rate change because DJI is forced to be 115200 + if (((gpsSettings.DataProtocol == GPSSETTINGS_DATAPROTOCOL_DJI) && (previous_data_protocol != GPSSETTINGS_DATAPROTOCOL_DJI)) || + ((gpsSettings.DataProtocol != GPSSETTINGS_DATAPROTOCOL_DJI) && (previous_data_protocol == GPSSETTINGS_DATAPROTOCOL_DJI))) { + // knows to force 115200 for DJI + gps_set_fc_baud_from_settings(); + } #endif // it's OK that ubx auto config is inited and ready to go, when GPS is disabled or running another protocol @@ -791,12 +793,6 @@ void updateGpsSettings(__attribute__((unused)) UAVObjEvent *ev) gps_ubx_autoconfig_set(&newconfig); } #endif -#if defined(PIOS_INCLUDE_GPS_DJI_PARSER) - if (gpsSettings.DataProtocol == GPSSETTINGS_DATAPROTOCOL_DJI) { - // clear out satellite data because DJI doesn't provide it - GPSSatellitesSetDefaults(GPSSatellitesHandle(), 0); - } -#endif } #endif /* defined(ANY_FULL_GPS_PARSER) */ /**