From e67871c7c83ad8f03ed1dcbb719fc8211ce759ce Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 21 Apr 2020 22:09:17 -0700 Subject: rfnoc: radio: Add APIs to query cal keys This allows asking the radio for the keys it uses to read/write its calibration data. By querying radio_control::get_{rx,tx}_power_ref_keys(), the return values can be used to access uhd::usrp::cal::database::read_cal_data(). --- host/include/uhd/rfnoc/radio_control.hpp | 41 ++++++++++++++++++++++ .../include/uhdlib/rfnoc/radio_control_impl.hpp | 2 ++ host/lib/rfnoc/radio_control_impl.cpp | 10 ++++++ 3 files changed, 53 insertions(+) diff --git a/host/include/uhd/rfnoc/radio_control.hpp b/host/include/uhd/rfnoc/radio_control.hpp index 96f082b3e..867b2a919 100644 --- a/host/include/uhd/rfnoc/radio_control.hpp +++ b/host/include/uhd/rfnoc/radio_control.hpp @@ -238,6 +238,26 @@ public: */ virtual double get_tx_power_reference(const size_t chan) = 0; + /*! Return the keys by which the power calibration data is referenced for this + * channel. + * + * The first entry is the key, the second the serial. These are the same + * arguments that can be used for uhd::usrp::cal::database::read_cal_data() + * and friends. See also \ref cal_db_serial. + * + * Note that the key can change at runtime, e.g., when the antenna port is + * switched. + * + * The difference between this and has_tx_power_reference() is that the + * latter requires both device support as well as calibration data, whereas + * this function will never throw, and will always return a non-empty vector + * if device support is there, even if the device does not have calbration + * data loaded. + * + * \returns an empty vector if no power calibration is supported, or a + * vector of length 2 with key and serial if it does. + */ + virtual std::vector get_tx_power_ref_keys(const size_t chan = 0) = 0; /*! Return a list of valid RX gain names */ @@ -338,6 +358,27 @@ public: */ virtual double get_rx_power_reference(const size_t chan) = 0; + /*! Return the keys by which the power calibration data is referenced for this + * channel. + * + * The first entry is the key, the second the serial. These are the same + * arguments that can be used for uhd::usrp::cal::database::read_cal_data() + * and friends. See also \ref cal_db_serial. + * + * Note that the key can change at runtime, e.g., when the antenna port is + * switched. + * + * The difference between this and has_rx_power_reference() is that the + * latter requires both device support as well as calibration data, whereas + * this function will never throw, and will always return a non-empty vector + * if device support is there, even if the device does not have calbration + * data loaded. + * + * \returns an empty vector if no power calibration is supported, or a + * vector of length 2 with key and serial if it does. + */ + virtual std::vector get_rx_power_ref_keys(const size_t chan = 0) = 0; + /*! Return a list of TX gain profiles for this radio */ virtual std::vector get_tx_gain_profile_names( diff --git a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp index 4916ecf6f..db723a6f6 100644 --- a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp +++ b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp @@ -106,6 +106,8 @@ public: virtual bool has_tx_power_reference(const size_t chan); virtual double get_rx_power_reference(const size_t chan); virtual double get_tx_power_reference(const size_t chan); + virtual std::vector get_rx_power_ref_keys(const size_t); + virtual std::vector get_tx_power_ref_keys(const size_t); /************************************************************************** * LO Controls diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index e34a9b430..b3da7ec13 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -611,6 +611,16 @@ double radio_control_impl::get_tx_power_reference(const size_t) return 0.0; } +std::vector radio_control_impl::get_rx_power_ref_keys(const size_t) +{ + return {}; +} + +std::vector radio_control_impl::get_tx_power_ref_keys(const size_t) +{ + return {}; +} + /****************************************************************************** * LO Default API *****************************************************************************/ -- cgit v1.2.3