From 9b078c0b1f411ba65822b496e968703cd9744b90 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Thu, 28 Dec 2023 00:14:02 +0100 Subject: [PATCH] Fix arming when GPS included in build but no active GNSS device attached + revert msp request for SatInfo (#13244) * Fix arming when GPS included in build but not active * Fixes per review from Chris * Move PG change to new PR * Restore changing GPS PG version --- src/main/config/config.c | 3 --- src/main/fc/core.c | 3 ++- src/main/io/gps.c | 28 ++++++++++++++-------------- src/main/io/gps.h | 1 - src/main/msp/msp.c | 6 ------ src/main/msp/msp_protocol_v2_betaflight.h | 1 - src/main/pg/gps.c | 2 +- 7 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index d10d60c3f..beacf8bb8 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -484,9 +484,6 @@ if (systemConfig()->configurationState == CONFIGURATION_STATE_UNCONFIGURED) { #ifdef USE_DASHBOARD featureEnableImmediate(FEATURE_DASHBOARD); #endif -#ifdef USE_GPS - featureEnableImmediate(FEATURE_GPS); -#endif #ifdef USE_LED_STRIP featureEnableImmediate(FEATURE_LED_STRIP); #endif diff --git a/src/main/fc/core.c b/src/main/fc/core.c index e46e1d366..ef1898bf1 100644 --- a/src/main/fc/core.c +++ b/src/main/fc/core.c @@ -580,9 +580,10 @@ void tryArm(void) lastArmingDisabledReason = 0; #ifdef USE_GPS - GPS_reset_home_position(); //beep to indicate arming if (featureIsEnabled(FEATURE_GPS)) { + GPS_reset_home_position(); + if (STATE(GPS_FIX) && gpsSol.numSat >= gpsRescueConfig()->minSats) { beeper(BEEPER_ARMING_GPS_FIX); } else { diff --git a/src/main/io/gps.c b/src/main/io/gps.c index 01ed5feb5..ae0b7152a 100644 --- a/src/main/io/gps.c +++ b/src/main/io/gps.c @@ -329,9 +329,10 @@ typedef enum { UBLOX_MSG_STATUS, // 15: set STATUS MSG rate UBLOX_MSG_VELNED, // 16. set VELNED MSG rate UBLOX_MSG_DOP, // 17. MSG_NAV_DOP - UBLOX_SET_NAV_RATE, // 18. set to user requested GPS sample rate - UBLOX_MSG_CFG_GNSS, // 19. For not SBAS or GALILEO - UBLOX_CONFIG_COMPLETE // 20. Config finished, start receiving data + UBLOX_SAT_INFO, // 18. MSG_NAV_SAT message + UBLOX_SET_NAV_RATE, // 19. set to user requested GPS sample rate + UBLOX_MSG_CFG_GNSS, // 20. For not SBAS or GALILEO + UBLOX_CONFIG_COMPLETE // 21. Config finished, start receiving data } ubloxStatePosition_e; baudRate_e initBaudRateIndex; @@ -366,16 +367,6 @@ static void logErrorToPacketLog(void) } #endif // USE_DASHBOARD -// Enable sat info using MSP request -#ifdef USE_GPS_UBLOX -void gpsRequestSatInfo(void) -{ - if (!ARMING_FLAG(ARMED)) { - setSatInfoMessageRate(5); - } -} -#endif - static void gpsNewData(uint16_t c); #ifdef USE_GPS_NMEA static bool gpsNewFrameNMEA(char c); @@ -1108,6 +1099,11 @@ void gpsConfigureUblox(void) break; } + // Add delay to stabilize the connection + if (cmp32(gpsData.now, gpsData.state_ts) < 1000) { + return; + } + if (gpsData.ackState == UBLOX_ACK_IDLE) { // short delay before between commands, including the first command @@ -1232,6 +1228,10 @@ void gpsConfigureUblox(void) ubloxSetMessageRate(CLASS_NAV, MSG_NAV_DOP, 1); } break; + case UBLOX_SAT_INFO: + // enable by default, turned off when armed and receiving data to reduce in-flight traffic + setSatInfoMessageRate(5); + break; case UBLOX_SET_NAV_RATE: // set the nav solution rate to the user's configured update rate gpsData.updateRateHz = gpsConfig()->gps_update_rate_hz; @@ -2559,7 +2559,7 @@ void GPS_reset_home_position(void) #ifdef USE_GPS_UBLOX // disable Sat Info requests on arming - if (ARMING_FLAG(ARMED)) { + if (gpsConfig()->provider == GPS_UBLOX) { setSatInfoMessageRate(0); } #endif diff --git a/src/main/io/gps.h b/src/main/io/gps.h index fd5b26c91..1054b55cf 100644 --- a/src/main/io/gps.h +++ b/src/main/io/gps.h @@ -381,7 +381,6 @@ extern uint32_t dashboardGpsNavSvInfoRcvCount; // Count of time #ifdef USE_GPS_UBLOX ubloxVersion_e ubloxParseVersion(const uint32_t version); -void gpsRequestSatInfo(void); void setSatInfoMessageRate(uint8_t divisor); #endif diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index ecaf8a346..dab1e0eb0 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -4052,12 +4052,6 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP, break; #endif -#ifdef USE_GPS_UBLOX - case MSP2_UBLOX_REQUEST_SV_INFO: - gpsRequestSatInfo(); - break; -#endif - default: // we do not know how to handle the (valid) message, indicate error MSP $M! return MSP_RESULT_ERROR; diff --git a/src/main/msp/msp_protocol_v2_betaflight.h b/src/main/msp/msp_protocol_v2_betaflight.h index 97f63a798..b039defb7 100644 --- a/src/main/msp/msp_protocol_v2_betaflight.h +++ b/src/main/msp/msp_protocol_v2_betaflight.h @@ -29,7 +29,6 @@ #define MSP2_GET_LED_STRIP_CONFIG_VALUES 0x3008 #define MSP2_SET_LED_STRIP_CONFIG_VALUES 0x3009 #define MSP2_SENSOR_CONFIG_ACTIVE 0x300A -#define MSP2_UBLOX_REQUEST_SV_INFO 0x300B // MSP2_SET_TEXT and MSP2_GET_TEXT variable types #define MSP2TEXT_PILOT_NAME 1 diff --git a/src/main/pg/gps.c b/src/main/pg/gps.c index e90af7b5a..750e43530 100644 --- a/src/main/pg/gps.c +++ b/src/main/pg/gps.c @@ -29,7 +29,7 @@ #include "gps.h" -PG_REGISTER_WITH_RESET_TEMPLATE(gpsConfig_t, gpsConfig, PG_GPS_CONFIG, 4); +PG_REGISTER_WITH_RESET_TEMPLATE(gpsConfig_t, gpsConfig, PG_GPS_CONFIG, 3); PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig, .provider = GPS_UBLOX, -- 2.11.4.GIT