diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index 8497027eb2..e7dbab947a 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -84,9 +84,11 @@ using namespace device; using namespace time_literals; -#define TIMEOUT_1HZ 1300 //!< Timeout time in mS, 1000 mS (1Hz) + 300 mS delta for error -#define TIMEOUT_5HZ 500 //!< Timeout time in mS, 200 mS (5Hz) + 300 mS delta for error -#define TIMEOUT_DUMP_ADD 450 //!< Additional time in mS to account for RTCM3 parsing and dumping +#define TIMEOUT_1HZ 1300 //!< Timeout time in mS, 1000 mS (1Hz) + 300 mS delta for error +#define TIMEOUT_5HZ 500 //!< Timeout time in mS, 200 mS (5Hz) + 300 mS delta for error +#define TIMEOUT_INIT_1HZ (3 * TIMEOUT_1HZ) //!< Timeout time in mS, used until GPS is healthy +#define TIMEOUT_INIT_5HZ (3 * TIMEOUT_5HZ) //!< Timeout time in mS, used until GPS is healthy +#define TIMEOUT_DUMP_ADD 450 //!< Additional time in mS to account for RTCM3 parsing and dumping enum class gps_driver_mode_t { None = 0, @@ -996,19 +998,26 @@ GPS::run() } int helper_ret; - unsigned receive_timeout = TIMEOUT_5HZ; + + /* After being configured (especially in combination with FLASH wipes) the GPS may require + * additional time before outputting the first navigation data. To account for this, there is + * an init timeout. As soon as the GPS is healthy, the timeout is decreased. This allows for + * a quick reaction to a connection loss. */ + unsigned receive_timeout = TIMEOUT_INIT_5HZ; + unsigned healthy_timeout = TIMEOUT_5HZ; if ((ubx_mode == GPSDriverUBX::UBXMode::RoverWithMovingBase) || (ubx_mode == GPSDriverUBX::UBXMode::RoverWithMovingBaseUART1)) { /* The MB rover will wait as long as possible to compute a navigation solution, * possibly lowering the navigation rate all the way to 1 Hz while doing so. */ - receive_timeout = TIMEOUT_1HZ; + receive_timeout = TIMEOUT_INIT_1HZ; + healthy_timeout = TIMEOUT_1HZ; } if (_dump_communication_mode != gps_dump_comm_mode_t::Disabled) { /* Dumping the RTCM3/UBX data requires additional parsing and storing of data via uORB. * Without additional time this can lead to timeouts. */ - receive_timeout += TIMEOUT_DUMP_ADD; + healthy_timeout += TIMEOUT_DUMP_ADD; } while ((helper_ret = _helper->receive(receive_timeout)) > 0 && !should_exit()) { @@ -1068,6 +1077,7 @@ GPS::run() // // PX4_WARN("module found: %s", mode_str); _healthy = true; + receive_timeout = healthy_timeout; } /* Do not wipe the FLASH config multiple times. */