diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index f639d4ecd..2e0bec8d5 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -46,6 +46,7 @@ #include #include #include +#include #if OLD_BOOST #include namespace bc = boost::math; @@ -588,403 +589,546 @@ rtklib_pvt_cc::rtklib_pvt_cc(uint32_t nchannels, rtklib_pvt_cc::~rtklib_pvt_cc() { msgctl(sysv_msqid, IPC_RMID, nullptr); - if (d_xml_storage) + try { - // save GPS L2CM ephemeris to XML file - std::string file_name = xml_base_path + "gps_cnav_ephemeris.xml"; - if (d_pvt_solver->gps_cnav_ephemeris_map.empty() == false) + if (d_xml_storage) { - std::ofstream ofs; - try + // save GPS L2CM ephemeris to XML file + std::string file_name = xml_base_path + "gps_cnav_ephemeris.xml"; + if (d_pvt_solver->gps_cnav_ephemeris_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", d_pvt_solver->gps_cnav_ephemeris_map); - LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", d_pvt_solver->gps_cnav_ephemeris_map); + LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS L2CM or L5 Ephemeris, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save GPS L2CM or L5 Ephemeris, map is empty"; - } - // save GPS L1 CA ephemeris to XML file - file_name = xml_base_path + "gps_ephemeris.xml"; - if (d_pvt_solver->gps_ephemeris_map.empty() == false) - { - std::ofstream ofs; - try + // save GPS L1 CA ephemeris to XML file + file_name = xml_base_path + "gps_ephemeris.xml"; + if (d_pvt_solver->gps_ephemeris_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_pvt_solver->gps_ephemeris_map); - LOG(INFO) << "Saved GPS L1 CA Ephemeris map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_pvt_solver->gps_ephemeris_map); + LOG(INFO) << "Saved GPS L1 CA Ephemeris map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (const std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS L1 CA Ephemeris, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save GPS L1 CA Ephemeris, map is empty"; - } - // save Galileo E1 ephemeris to XML file - file_name = xml_base_path + "gal_ephemeris.xml"; - if (d_pvt_solver->galileo_ephemeris_map.empty() == false) - { - std::ofstream ofs; - try + // save Galileo E1 ephemeris to XML file + file_name = xml_base_path + "gal_ephemeris.xml"; + if (d_pvt_solver->galileo_ephemeris_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", d_pvt_solver->galileo_ephemeris_map); - LOG(INFO) << "Saved Galileo E1 Ephemeris map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", d_pvt_solver->galileo_ephemeris_map); + LOG(INFO) << "Saved Galileo E1 Ephemeris map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (const std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save Galileo E1 Ephemeris, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save Galileo E1 Ephemeris, map is empty"; - } - // save GLONASS GNAV ephemeris to XML file - file_name = xml_base_path + "eph_GLONASS_GNAV.xml"; - if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) - { - std::ofstream ofs; - try + // save GLONASS GNAV ephemeris to XML file + file_name = xml_base_path + "eph_GLONASS_GNAV.xml"; + if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); - LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); + LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GLONASS GNAV Ephemeris, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save GLONASS GNAV Ephemeris, map is empty"; - } - // Save GPS UTC model parameters - file_name = xml_base_path + "gps_utc_model.xml"; - if (d_pvt_solver->gps_utc_model.valid) - { - std::ofstream ofs; - try + // Save GPS UTC model parameters + file_name = xml_base_path + "gps_utc_model.xml"; + if (d_pvt_solver->gps_utc_model.valid) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", d_pvt_solver->gps_utc_model); - LOG(INFO) << "Saved GPS UTC model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", d_pvt_solver->gps_utc_model); + LOG(INFO) << "Saved GPS UTC model parameters"; + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS UTC model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save GPS UTC model parameters, not valid data"; - } - // Save Galileo UTC model parameters - file_name = xml_base_path + "gal_utc_model.xml"; - if (d_pvt_solver->galileo_utc_model.Delta_tLS_6 != 0.0) - { - std::ofstream ofs; - try + // Save Galileo UTC model parameters + file_name = xml_base_path + "gal_utc_model.xml"; + if (d_pvt_solver->galileo_utc_model.Delta_tLS_6 != 0.0) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", d_pvt_solver->galileo_utc_model); - LOG(INFO) << "Saved Galileo UTC model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", d_pvt_solver->galileo_utc_model); + LOG(INFO) << "Saved Galileo UTC model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save Galileo UTC model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save Galileo UTC model parameters, not valid data"; - } - // Save GPS iono parameters - file_name = xml_base_path + "gps_iono.xml"; - if (d_pvt_solver->gps_iono.valid == true) - { - std::ofstream ofs; - try + // Save GPS iono parameters + file_name = xml_base_path + "gps_iono.xml"; + if (d_pvt_solver->gps_iono.valid == true) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", d_pvt_solver->gps_iono); - LOG(INFO) << "Saved GPS ionospheric model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", d_pvt_solver->gps_iono); + LOG(INFO) << "Saved GPS ionospheric model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS ionospheric model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save GPS ionospheric model parameters, not valid data"; - } - // Save GPS CNAV iono parameters - file_name = xml_base_path + "gps_cnav_iono.xml"; - if (d_pvt_solver->gps_cnav_iono.valid == true) - { - std::ofstream ofs; - try + // Save GPS CNAV iono parameters + file_name = xml_base_path + "gps_cnav_iono.xml"; + if (d_pvt_solver->gps_cnav_iono.valid == true) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_cnav_iono_model", d_pvt_solver->gps_cnav_iono); - LOG(INFO) << "Saved GPS CNAV ionospheric model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_iono_model", d_pvt_solver->gps_cnav_iono); + LOG(INFO) << "Saved GPS CNAV ionospheric model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS CNAV ionospheric model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save GPS CNAV ionospheric model parameters, not valid data"; - } - // Save Galileo iono parameters - file_name = xml_base_path + "gal_iono.xml"; - if (d_pvt_solver->galileo_iono.ai0_5 != 0.0) - { - std::ofstream ofs; - try + // Save Galileo iono parameters + file_name = xml_base_path + "gal_iono.xml"; + if (d_pvt_solver->galileo_iono.ai0_5 != 0.0) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", d_pvt_solver->galileo_iono); - LOG(INFO) << "Saved Galileo ionospheric model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", d_pvt_solver->galileo_iono); + LOG(INFO) << "Saved Galileo ionospheric model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save Galileo ionospheric model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save Galileo ionospheric model parameters, not valid data"; - } - // save GPS almanac to XML file - file_name = xml_base_path + "gps_almanac.xml"; - if (d_pvt_solver->gps_almanac_map.empty() == false) - { - std::ofstream ofs; - try + // save GPS almanac to XML file + file_name = xml_base_path + "gps_almanac.xml"; + if (d_pvt_solver->gps_almanac_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", d_pvt_solver->gps_almanac_map); - LOG(INFO) << "Saved GPS almanac map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", d_pvt_solver->gps_almanac_map); + LOG(INFO) << "Saved GPS almanac map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (const std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS almanac, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save GPS almanac, map is empty"; - } - // Save Galileo almanac - file_name = xml_base_path + "gal_almanac.xml"; - if (d_pvt_solver->galileo_almanac_map.empty() == false) - { - std::ofstream ofs; - try + // Save Galileo almanac + file_name = xml_base_path + "gal_almanac.xml"; + if (d_pvt_solver->galileo_almanac_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", d_pvt_solver->galileo_almanac_map); - LOG(INFO) << "Saved Galileo almanac data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", d_pvt_solver->galileo_almanac_map); + LOG(INFO) << "Saved Galileo almanac data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save Galileo almanac, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save Galileo almanac, not valid data"; - } - // Save GPS CNAV UTC model parameters - file_name = xml_base_path + "gps_cnav_utc_model.xml"; - if (d_pvt_solver->gps_cnav_utc_model.valid) - { - std::ofstream ofs; - try + // Save GPS CNAV UTC model parameters + file_name = xml_base_path + "gps_cnav_utc_model.xml"; + if (d_pvt_solver->gps_cnav_utc_model.valid) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", d_pvt_solver->gps_cnav_utc_model); - LOG(INFO) << "Saved GPS CNAV UTC model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", d_pvt_solver->gps_cnav_utc_model); + LOG(INFO) << "Saved GPS CNAV UTC model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GPS CNAV UTC model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save GPS CNAV UTC model parameters, not valid data"; - } - // save GLONASS GNAV ephemeris to XML file - file_name = xml_base_path + "glo_gnav_ephemeris.xml"; - if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) - { - std::ofstream ofs; - try + // save GLONASS GNAV ephemeris to XML file + file_name = xml_base_path + "glo_gnav_ephemeris.xml"; + if (d_pvt_solver->glonass_gnav_ephemeris_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); - LOG(INFO) << "Saved GLONASS GNAV ephemeris map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); + LOG(INFO) << "Saved GLONASS GNAV ephemeris map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GLONASS GNAV ephemeris, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save GLONASS GNAV ephemeris, map is empty"; - } - // save GLONASS UTC model parameters to XML file - file_name = xml_base_path + "glo_utc_model.xml"; - if (d_pvt_solver->glonass_gnav_utc_model.valid) - { - std::ofstream ofs; - try + // save GLONASS UTC model parameters to XML file + file_name = xml_base_path + "glo_utc_model.xml"; + if (d_pvt_solver->glonass_gnav_utc_model.valid) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gnav_utc_model", d_pvt_solver->glonass_gnav_utc_model); - LOG(INFO) << "Saved GLONASS UTC model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_gnav_utc_model", d_pvt_solver->glonass_gnav_utc_model); + LOG(INFO) << "Saved GLONASS UTC model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save GLONASS GNAV ephemeris, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save GLONASS GNAV ephemeris, not valid data"; - } - // save BeiDou DNAV ephemeris to XML file - file_name = xml_base_path + "bds_dnav_ephemeris.xml"; - if (d_pvt_solver->beidou_dnav_ephemeris_map.empty() == false) - { - std::ofstream ofs; - try + // save BeiDou DNAV ephemeris to XML file + file_name = xml_base_path + "bds_dnav_ephemeris.xml"; + if (d_pvt_solver->beidou_dnav_ephemeris_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_ephemeris_map", d_pvt_solver->beidou_dnav_ephemeris_map); - LOG(INFO) << "Saved BeiDou DNAV Ephemeris map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_ephemeris_map", d_pvt_solver->beidou_dnav_ephemeris_map); + LOG(INFO) << "Saved BeiDou DNAV Ephemeris map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (const std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save BeiDou DNAV Ephemeris, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save BeiDou DNAV Ephemeris, map is empty"; - } - // Save BeiDou DNAV iono parameters - file_name = xml_base_path + "bds_dnav_iono.xml"; - if (d_pvt_solver->beidou_dnav_iono.valid) - { - std::ofstream ofs; - try + // Save BeiDou DNAV iono parameters + file_name = xml_base_path + "bds_dnav_iono.xml"; + if (d_pvt_solver->beidou_dnav_iono.valid) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_iono_model", d_pvt_solver->beidou_dnav_iono); - LOG(INFO) << "Saved BeiDou DNAV ionospheric model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_iono_model", d_pvt_solver->beidou_dnav_iono); + LOG(INFO) << "Saved BeiDou DNAV ionospheric model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save BeiDou DNAV ionospheric model parameters, not valid data"; } - } - else - { - LOG(INFO) << "Failed to save BeiDou DNAV ionospheric model parameters, not valid data"; - } - // save BeiDou DNAV almanac to XML file - file_name = xml_base_path + "bds_dnav_almanac.xml"; - if (d_pvt_solver->beidou_dnav_almanac_map.empty() == false) - { - std::ofstream ofs; - try + // save BeiDou DNAV almanac to XML file + file_name = xml_base_path + "bds_dnav_almanac.xml"; + if (d_pvt_solver->beidou_dnav_almanac_map.empty() == false) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_almanac_map", d_pvt_solver->beidou_dnav_almanac_map); - LOG(INFO) << "Saved BeiDou DNAV almanac map data"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_almanac_map", d_pvt_solver->beidou_dnav_almanac_map); + LOG(INFO) << "Saved BeiDou DNAV almanac map data"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (const std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (const std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save BeiDou DNAV almanac, map is empty"; } - } - else - { - LOG(INFO) << "Failed to save BeiDou DNAV almanac, map is empty"; - } - // Save BeiDou UTC model parameters - file_name = xml_base_path + "bds_dnav_utc_model.xml"; - if (d_pvt_solver->beidou_dnav_utc_model.valid) - { - std::ofstream ofs; - try + // Save BeiDou UTC model parameters + file_name = xml_base_path + "bds_dnav_utc_model.xml"; + if (d_pvt_solver->beidou_dnav_utc_model.valid) { - ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); - boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_utc_model", d_pvt_solver->beidou_dnav_utc_model); - LOG(INFO) << "Saved BeiDou DNAV UTC model parameters"; + std::ofstream ofs; + try + { + ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); + boost::archive::xml_oarchive xml(ofs); + xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_utc_model", d_pvt_solver->beidou_dnav_utc_model); + LOG(INFO) << "Saved BeiDou DNAV UTC model parameters"; + } + catch (const boost::archive::archive_exception e) + { + LOG(WARNING) << e.what(); + } + catch (const std::ofstream::failure& e) + { + LOG(WARNING) << "Problem opening output XML file"; + } + catch (std::exception& e) + { + LOG(WARNING) << e.what(); + } } - catch (std::exception& e) + else { - LOG(WARNING) << e.what(); + LOG(INFO) << "Failed to save BeiDou DNAV UTC model parameters, not valid data"; } } - else - { - LOG(INFO) << "Failed to save BeiDou DNAV UTC model parameters, not valid data"; - } + } + catch (std::length_error& e) + { + LOG(WARNING) << e.what(); } } diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index 7f4da17c1..22da08606 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -36,6 +36,7 @@ #include // for path, operator<< #include // for filesystem #include +#include #include #include @@ -79,7 +80,14 @@ GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path) GeoJSON_Printer::~GeoJSON_Printer() { - GeoJSON_Printer::close_file(); + try + { + GeoJSON_Printer::close_file(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } } diff --git a/src/algorithms/PVT/libs/gpx_printer.cc b/src/algorithms/PVT/libs/gpx_printer.cc index 7ca86052a..8075b21fa 100644 --- a/src/algorithms/PVT/libs/gpx_printer.cc +++ b/src/algorithms/PVT/libs/gpx_printer.cc @@ -36,6 +36,7 @@ #include // for path, operator<< #include // for filesystem #include +#include #include using google::LogMessage; @@ -218,7 +219,14 @@ bool Gpx_Printer::close_file() Gpx_Printer::~Gpx_Printer() { - close_file(); + try + { + close_file(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } if (!positions_printed) { if (remove(gpx_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary GPX file"; diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index 76018ba35..627e26416 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -36,6 +36,7 @@ #include // for path, operator<< #include // for filesystem #include +#include #include using google::LogMessage; @@ -319,7 +320,14 @@ bool Kml_Printer::close_file() Kml_Printer::~Kml_Printer() { - close_file(); + try + { + close_file(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } if (!positions_printed) { if (remove(kml_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary KML file"; diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 2470b1819..39b374bc7 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -41,6 +41,7 @@ #include // for filesystem #include #include +#include #include #include @@ -118,11 +119,29 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_fi Nmea_Printer::~Nmea_Printer() { - if (nmea_file_descriptor.is_open()) + try { - nmea_file_descriptor.close(); + if (nmea_file_descriptor.is_open()) + { + nmea_file_descriptor.close(); + } + } + catch (const std::ofstream::failure& e) + { + std::cerr << "Problem closing NMEA dump file: " << nmea_filename << '\n'; + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } + try + { + close_serial(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; } - close_serial(); } diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 0f686e460..2da35daa2 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -39,6 +39,7 @@ #include // for min and max #include // for floor #include // for getenv() +#include #include #include #include @@ -213,13 +214,19 @@ Rinex_Printer::~Rinex_Printer() posmn = navMixFile.tellp(); posnr = navGloFile.tellp(); posnc = navBdsFile.tellp(); - - Rinex_Printer::navFile.close(); - Rinex_Printer::obsFile.close(); - Rinex_Printer::sbsFile.close(); - Rinex_Printer::navGalFile.close(); - Rinex_Printer::navGloFile.close(); - Rinex_Printer::navBdsFile.close(); + try + { + Rinex_Printer::navFile.close(); + Rinex_Printer::obsFile.close(); + Rinex_Printer::sbsFile.close(); + Rinex_Printer::navGalFile.close(); + Rinex_Printer::navGloFile.close(); + Rinex_Printer::navBdsFile.close(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } // If nothing written, erase the files. if (posn == 0) { diff --git a/src/algorithms/PVT/libs/rtcm_printer.cc b/src/algorithms/PVT/libs/rtcm_printer.cc index b4892e2f8..39c7fe650 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.cc +++ b/src/algorithms/PVT/libs/rtcm_printer.cc @@ -38,6 +38,7 @@ #include // for filesystem #include #include +#include #include // for O_RDWR #include #include // for tcgetattr @@ -190,13 +191,27 @@ Rtcm_Printer::~Rtcm_Printer() { int64_t pos; pos = rtcm_file_descriptor.tellp(); - rtcm_file_descriptor.close(); + try + { + rtcm_file_descriptor.close(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } if (pos == 0) { if (remove(rtcm_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary RTCM file"; } } - close_serial(); + try + { + close_serial(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; + } } diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index a6bb03c4a..6057276ab 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -60,6 +60,7 @@ #include "rtklib_solution.h" #include #include +#include #include @@ -397,6 +398,7 @@ bool rtklib_solver::save_matfile() return true; } + rtklib_solver::~rtklib_solver() { if (d_dump_file.is_open() == true) @@ -412,7 +414,14 @@ rtklib_solver::~rtklib_solver() } if (d_flag_dump_mat_enabled) { - save_matfile(); + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor saving the PVT .mat dump file " << ex.what(); + } } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index 7b127007d..c6f14d597 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -213,9 +214,20 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::~galileo_e5a_noncoherentIQ_acquisi delete d_fft_if; delete d_ifft; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index ef8fe300d..05ac683e0 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -53,6 +54,7 @@ galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc( samples_per_code, dump, std::move(dump_filename))); } + galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( uint32_t sampled_ms, uint32_t max_dwells, @@ -125,9 +127,20 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index 1037aabc7..1934ee5e8 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -131,9 +132,20 @@ pcps_assisted_acquisition_cc::~pcps_assisted_acquisition_cc() volk_gnsssdr_free(d_fft_codes); delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 13af36da9..17082ae25 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -117,6 +118,7 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( d_channel = 0; } + pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc() { if (d_num_doppler_bins > 0) @@ -139,12 +141,24 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc() delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } + void pcps_cccwsr_acquisition_cc::set_local_code(std::complex *code_data, std::complex *code_pilot) { @@ -165,6 +179,7 @@ void pcps_cccwsr_acquisition_cc::set_local_code(std::complex *code_data, volk_32fc_conjugate_32fc(d_fft_code_pilot, d_fft_if->get_outbuf(), d_fft_size); } + void pcps_cccwsr_acquisition_cc::init() { d_gnss_synchro->Flag_valid_acquisition = false; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc index 0838fee7b..774022fb2 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -186,9 +187,20 @@ pcps_opencl_acquisition_cc::~pcps_opencl_acquisition_cc() delete d_fft_if; } - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 7377aebae..48ae578e6 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -158,11 +159,21 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc() delete d_corr_output_f; delete[] d_code_folded; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure& e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception& e) + { + std::cerr << e.what() << '\n'; } - // DLOG(INFO) << "END DESTROYER"; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index a6013fcaf..7fc685028 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,7 @@ pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( tong_init_val, tong_max_val, tong_max_dwells, dump, std::move(dump_filename))); } + pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( uint32_t sampled_ms, uint32_t doppler_max, @@ -152,12 +154,24 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc() delete d_ifft; delete d_fft_if; - if (d_dump) + try { - d_dump_file.close(); + if (d_dump) + { + d_dump_file.close(); + } + } + catch (const std::ofstream::failure &e) + { + std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } + void pcps_tong_acquisition_cc::set_local_code(std::complex *code) { memcpy(d_fft_if->get_inbuf(), code, sizeof(gr_complex) * d_fft_size); @@ -168,6 +182,7 @@ void pcps_tong_acquisition_cc::set_local_code(std::complex *code) volk_32fc_conjugate_32fc(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size); } + void pcps_tong_acquisition_cc::init() { d_gnss_synchro->Flag_valid_acquisition = false; @@ -212,6 +227,7 @@ void pcps_tong_acquisition_cc::init() } } + void pcps_tong_acquisition_cc::set_state(int32_t state) { d_state = state; @@ -244,6 +260,7 @@ void pcps_tong_acquisition_cc::set_state(int32_t state) } } + int pcps_tong_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index cf9807ece..d542235a9 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -140,7 +141,14 @@ hybrid_observables_cc::~hybrid_observables_cc() } if (d_dump_mat) { - save_matfile(); + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } } } diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index 2ae97cd1d..efc866de8 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -31,6 +31,7 @@ #include "labsat23_source.h" #include +#include #include #include @@ -88,9 +89,20 @@ labsat23_source::labsat23_source(const char *signal_file_basename, labsat23_source::~labsat23_source() { - if (binary_input_file->is_open()) + try { - binary_input_file->close(); + if (binary_input_file->is_open()) + { + binary_input_file->close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing input file" << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } delete binary_input_file; } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 8f7e5b44d..a42e85d15 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -672,7 +673,14 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking() } if (d_dump_mat) { - save_matfile(); + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } } try { diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 24b5e4e77..94ff75e3e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -621,7 +622,14 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() } if (d_dump_mat) { - save_matfile(); + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } } try { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index 7eefb338a..73a5f8604 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -325,7 +326,14 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::~glonass_l1_ca_dll_pll_c_aid_tracking_c { std::cout << "Writing .mat files ..."; } - glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + try + { + glonass_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index ed0fecde8..a9f9402b8 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -528,7 +529,15 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::~glonass_l1_ca_dll_pll_c_aid_tracking_s { std::cout << "Writing .mat files ..."; } - glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + try + { + glonass_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc index 482ea0140..0bd9553c6 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -278,7 +279,15 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::~Glonass_L1_Ca_Dll_Pll_Tracking_cc() { std::cout << "Writing .mat files ..."; } - Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile(); + try + { + Glonass_L1_Ca_Dll_Pll_Tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index 81fbe50db..ac85df763 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -322,7 +323,15 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::~glonass_l2_ca_dll_pll_c_aid_tracking_c { std::cout << "Writing .mat files ..."; } - glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + try + { + glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index 92d3e1bcc..b60aabb3a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -527,7 +528,15 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_s { std::cout << "Writing .mat files ..."; } - glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + try + { + glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index 2549f85e0..8b3492978 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -278,7 +279,15 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::~Glonass_L2_Ca_Dll_Pll_Tracking_cc() { std::cout << "Writing .mat files ..."; } - Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile(); + try + { + Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index 9701a6810..eea588de4 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -304,7 +305,15 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc() { std::cout << "Writing .mat files ..."; } - gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + try + { + gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc index 847806647..6ba84d855 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -305,7 +306,15 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc() { std::cout << "Writing .mat files ..."; } - gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + try + { + gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc index 8c250036c..d5a6cb62f 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -374,7 +375,15 @@ Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc() { std::cout << "Writing .mat files ..."; } - Gps_L1_Ca_Kf_Tracking_cc::save_matfile(); + try + { + Gps_L1_Ca_Kf_Tracking_cc::save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Error saving the .mat file: " << ex.what(); + } + if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index 020402421..cf5cb96a2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include diff --git a/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc b/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc index a2c25debc..5de0d332a 100644 --- a/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc +++ b/src/tests/system-tests/libs/rtklib_solver_dump_reader.cc @@ -29,6 +29,7 @@ */ #include "rtklib_solver_dump_reader.h" +#include #include #include @@ -113,7 +114,7 @@ bool rtklib_solver_dump_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening rtklib_solver dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening rtklib_solver dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -126,8 +127,19 @@ bool rtklib_solver_dump_reader::open_obs_file(std::string out_file) rtklib_solver_dump_reader::~rtklib_solver_dump_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing rtklib_solver dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc b/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc index 1082fb233..631e8e782 100644 --- a/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc +++ b/src/tests/system-tests/libs/spirent_motion_csv_dump_reader.cc @@ -30,6 +30,7 @@ #include "spirent_motion_csv_dump_reader.h" #include +#include #include #include @@ -80,9 +81,20 @@ spirent_motion_csv_dump_reader::spirent_motion_csv_dump_reader() spirent_motion_csv_dump_reader::~spirent_motion_csv_dump_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Spirent CSV dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } @@ -225,7 +237,7 @@ bool spirent_motion_csv_dump_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening Spirent CSV dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Spirent CSV dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -238,8 +250,19 @@ bool spirent_motion_csv_dump_reader::open_obs_file(std::string out_file) void spirent_motion_csv_dump_reader::close_obs_file() { - if (d_dump_file.is_open() == false) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Spirent CSV dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc index 95c5ed22d..370b38d9b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/observables_dump_reader.cc @@ -29,6 +29,7 @@ */ #include "observables_dump_reader.h" +#include #include #include @@ -96,7 +97,7 @@ bool observables_dump_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Observables dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -106,6 +107,7 @@ bool observables_dump_reader::open_obs_file(std::string out_file) } } + void observables_dump_reader::close_obs_file() { if (d_dump_file.is_open() == false) @@ -114,6 +116,7 @@ void observables_dump_reader::close_obs_file() } } + observables_dump_reader::observables_dump_reader(int n_channels_) { n_channels = n_channels_; @@ -129,9 +132,20 @@ observables_dump_reader::observables_dump_reader(int n_channels_) observables_dump_reader::~observables_dump_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Observables dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } delete[] RX_time; delete[] TOW_at_current_symbol_s; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc index c8c95afd4..e35304014 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc @@ -29,6 +29,7 @@ */ #include "tlm_dump_reader.h" +#include #include #include @@ -90,7 +91,7 @@ bool tlm_dump_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening TLM dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -103,8 +104,19 @@ bool tlm_dump_reader::open_obs_file(std::string out_file) tlm_dump_reader::~tlm_dump_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing TLM dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc index 233bd8acb..2e3fe04dc 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc @@ -29,6 +29,7 @@ */ #include "tracking_dump_reader.h" +#include #include #include @@ -112,7 +113,7 @@ bool tracking_dump_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -125,8 +126,19 @@ bool tracking_dump_reader::open_obs_file(std::string out_file) tracking_dump_reader::~tracking_dump_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Tracking dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc index efa913404..41735824f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.cc @@ -29,6 +29,7 @@ */ #include "tracking_true_obs_reader.h" +#include #include #include @@ -92,7 +93,7 @@ bool tracking_true_obs_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename << std::endl; return false; } } @@ -112,8 +113,19 @@ void tracking_true_obs_reader::close_obs_file() tracking_true_obs_reader::~tracking_true_obs_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing Tracking dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc index 14cd52562..e183bb9ef 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/true_observables_reader.cc @@ -29,6 +29,7 @@ */ #include "true_observables_reader.h" +#include #include #include @@ -97,7 +98,7 @@ bool true_observables_reader::open_obs_file(std::string out_file) } catch (const std::ifstream::failure &e) { - std::cout << "Problem opening True observables Log file: " << d_dump_filename.c_str() << std::endl; + std::cout << "Problem opening true Observables Log file: " << d_dump_filename << std::endl; return false; } } @@ -110,8 +111,19 @@ bool true_observables_reader::open_obs_file(std::string out_file) true_observables_reader::~true_observables_reader() { - if (d_dump_file.is_open() == true) + try { - d_dump_file.close(); + if (d_dump_file.is_open() == true) + { + d_dump_file.close(); + } + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem closing true Observables dump Log file: " << d_dump_filename << '\n'; + } + catch (const std::exception &e) + { + std::cerr << e.what() << '\n'; } }