diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-03-05 12:08:56 -0800 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-04-02 11:55:17 -0500 |
commit | a1f96194696494b756d691ff54e384a1ce478fc2 (patch) | |
tree | 1a1d480b5e35a239c5599ebcda1984e29bd0dd55 /host/utils/usrp_cal_utils.hpp | |
parent | 3fe5ccf700a0c6f27dca9511386460194dcc593c (diff) | |
download | uhd-a1f96194696494b756d691ff54e384a1ce478fc2.tar.gz uhd-a1f96194696494b756d691ff54e384a1ce478fc2.tar.bz2 uhd-a1f96194696494b756d691ff54e384a1ce478fc2.zip |
uhd: cal: Use usrp::cal::database instead of CSV files
Now that we have cal::iq_cal and cal::database, there's no need to
manually wrangle CSV files for calibration data. This commit replaces
all CSV operations with cal::database calls and uses cal::iq_cal as
a container.
CSV files can still be read, but are considered deprecated.
Diffstat (limited to 'host/utils/usrp_cal_utils.hpp')
-rw-r--r-- | host/utils/usrp_cal_utils.hpp | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index 61dd0fbdd..d43df7a1b 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -5,6 +5,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later // +#include <uhd/cal/database.hpp> +#include <uhd/cal/iq_cal.hpp> #include <uhd/property_tree.hpp> #include <uhd/usrp/dboard_eeprom.hpp> #include <uhd/usrp/multi_usrp.hpp> @@ -181,33 +183,18 @@ static void store_results(const std::vector<result_t>& results, const std::string& what, // Type of test, e.g. "iq", const std::string& serial) { - // make the calibration file path - fs::path cal_data_path = fs::path(uhd::get_app_path()) / ".uhd"; - fs::create_directory(cal_data_path); - cal_data_path = cal_data_path / "cal"; - fs::create_directory(cal_data_path); - cal_data_path = - cal_data_path / str(boost::format("%s_%s_cal_v0.2_%s.csv") % xx % what % serial); - if (fs::exists(cal_data_path)) - fs::rename(cal_data_path, - cal_data_path.string() + str(boost::format(".%d") % time(NULL))); - - // fill the calibration file - std::ofstream cal_data(cal_data_path.string().c_str()); - cal_data << boost::format("name, %s Frontend Calibration\n") % XX; - cal_data << boost::format("serial, %s\n") % serial; - cal_data << boost::format("timestamp, %d\n") % time(NULL); - cal_data << boost::format("version, 0, 1\n"); - cal_data << boost::format("DATA STARTS HERE\n"); - cal_data << "lo_frequency, correction_real, correction_imag, measured, delta\n"; - + using namespace uhd::usrp::cal; + // Note: We could also load existing data and update it. + auto cal_data = iq_cal::make(XX + " Frontend Calibration", serial, time(NULL)); for (size_t i = 0; i < results.size(); i++) { - cal_data << results[i].freq << ", " << results[i].real_corr << ", " - << results[i].imag_corr << ", " << results[i].best << ", " - << results[i].delta << "\n"; + cal_data->set_cal_coeff(results[i].freq, + {results[i].real_corr, results[i].imag_corr}, + results[i].best, + results[i].delta); } - std::cout << "wrote cal data to " << cal_data_path << std::endl; + const std::string cal_key = xx + "_" + what; + database::write_cal_data(cal_key, serial, cal_data->serialize()); } /*********************************************************************** |