I can't understand AP_GPS_Blended::get_lag() function

bool AP_GPS_Blended::get_lag(float &lag_sec) const
{
        lag_sec = _blended_lag_sec;
        // auto switching uses all GPS receivers, so all must be configured
        uint8_t inst; // we don't actually care what the number is, but must pass it
        return gps.first_unconfigured_gps(inst);
}

bool AP_GPS::first_unconfigured_gps(uint8_t &instance) const
{
    for (int i = 0; i < GPS_MAX_RECEIVERS; i++) {
        if (params[i].type != GPS_TYPE_NONE && (drivers[i] == nullptr || !drivers[i]->is_configured())) {
            instance = i;
            return true;
        }
    }
    return false;
}

This is code, my arducopter version is 4.6.1, but I see master and 4.7 also like too.

In my understanding, If the GPS is not initialized, first_unconfigured_gps will return true, then get_lag also return true. However, I think get_lag should return false when GPS is not initialized.

So is it my misunderstanding, or is the code error?

However, I think get_lag should return false when GPS is not initialized.

Why?

(The documentation is not great, but I found some clues that true is the intended value… suggesting you’re just misunderstanding. But I am not sure.)

In bool NavEKF3_core::setup_core(uint8_t _imu_index, uint8_t _core_index) function

    // GPS sensing can have large delays and should not be included if disabled
    if (frontend->sources.usingGPS()) {
        // Wait for the configuration of all GPS units to be confirmed. Until this has occurred the GPS driver cannot provide a correct time delay
        float gps_delay_sec = 0;
        if (!dal.gps().get_lag(selected_gps, gps_delay_sec)) {
#if HAL_GCS_ENABLED
            const uint32_t now = dal.millis();
            if (now - lastInitFailReport_ms > 10000) {
                lastInitFailReport_ms = now;
                // provide an escalating series of messages
                MAV_SEVERITY severity = MAV_SEVERITY_INFO;
                if (now > 30000) {
                    severity = MAV_SEVERITY_ERROR;
                } else if (now > 15000) {
                    severity = MAV_SEVERITY_WARNING;
                }
                GCS_SEND_TEXT(severity, "EKF3 waiting for GPS config data");
            }
#endif
            return false;
        }
        // limit the time delay value from the GPS library to a max of 250 msec which is the max value the EKF has been tested for.
        maxTimeDelay_ms = MAX(maxTimeDelay_ms , MIN((uint16_t)(gps_delay_sec * 1000.0f),250));
    }

GCS will print warning info when get_lag = false. So I think when GPS not configured, get_lag() should return false.

Verify that the cited line dal.gps().get_lag(selected_gps, gps_delay_sec) could possibly call to the AP_GPS_Blended::get_lag( ) that you’re looking at.

Again, I’m no expert, but it looks to me like that would call to AP_DAL_GPS::get_lag( ) which is a different function. (And might have different specified return behavior.)