From bdce3c20d1f804a7bb25020ab6e25ac11c90abbb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 22 May 2018 00:29:33 +0200 Subject: [PATCH] Catch exception --- src/utils/front-end-cal/main.cc | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 6467dac25..db8e8baae 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -471,38 +471,37 @@ int main(int argc, char** argv) << elapsed_seconds.count() << " [seconds]" << std::endl; - //6. find TOW from SUPL assistance - + // 6. find TOW from SUPL assistance double current_TOW = 0; - if (global_gps_ephemeris_map.size() > 0) + try { - std::map Eph_map; - try + if (global_gps_ephemeris_map.size() > 0) { + std::map Eph_map; Eph_map = global_gps_ephemeris_map.get_map_copy(); + current_TOW = Eph_map.begin()->second.d_TOW; + + time_t t = utc_time(Eph_map.begin()->second.i_GPS_week, (long int)current_TOW); + + fprintf(stdout, "Reference Time:\n"); + fprintf(stdout, " GPS Week: %d\n", Eph_map.begin()->second.i_GPS_week); + fprintf(stdout, " GPS TOW: %ld %lf\n", (long int)current_TOW, (long int)current_TOW * 0.08); + fprintf(stdout, " ~ UTC: %s", ctime(&t)); + std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl; } - catch (const boost::exception& e) + else { - std::cout << "Exception in getting Global ephemeris map" << std::endl; + std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!" << std::endl; delete acquisition; delete gnss_synchro; google::ShutDownCommandLineFlags(); std::cout << "GNSS-SDR Front-end calibration program ended." << std::endl; return 0; } - current_TOW = Eph_map.begin()->second.d_TOW; - - time_t t = utc_time(Eph_map.begin()->second.i_GPS_week, (long int)current_TOW); - - fprintf(stdout, "Reference Time:\n"); - fprintf(stdout, " GPS Week: %d\n", Eph_map.begin()->second.i_GPS_week); - fprintf(stdout, " GPS TOW: %ld %lf\n", (long int)current_TOW, (long int)current_TOW * 0.08); - fprintf(stdout, " ~ UTC: %s", ctime(&t)); - std::cout << "Current TOW obtained from SUPL assistance = " << current_TOW << std::endl; } - else + catch (const boost::exception& e) { - std::cout << "Unable to get Ephemeris SUPL assistance. TOW is unknown!" << std::endl; + std::cout << "Exception in getting Global ephemeris map" << std::endl; delete acquisition; delete gnss_synchro; google::ShutDownCommandLineFlags(); @@ -510,7 +509,7 @@ int main(int argc, char** argv) return 0; } - //Get user position from config file (or from SUPL using GSM Cell ID) + // Get user position from config file (or from SUPL using GSM Cell ID) double lat_deg = configuration->property("GNSS-SDR.init_latitude_deg", 41.0); double lon_deg = configuration->property("GNSS-SDR.init_longitude_deg", 2.0); double altitude_m = configuration->property("GNSS-SDR.init_altitude_m", 100);