diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-08-06 20:55:35 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-08-17 16:22:35 -0500 |
commit | b9f9ca2d0fd43f2a55e4ed5301070585cbb1be3c (patch) | |
tree | 9f5d41f396b5721b153b659f115fc1ebf71096e9 /host | |
parent | 34729381733f22b36d34d8d451b80de5b0e83203 (diff) | |
download | uhd-b9f9ca2d0fd43f2a55e4ed5301070585cbb1be3c.tar.gz uhd-b9f9ca2d0fd43f2a55e4ed5301070585cbb1be3c.tar.bz2 uhd-b9f9ca2d0fd43f2a55e4ed5301070585cbb1be3c.zip |
uhd: Add APIs for getting the available power range
The previously added APIs for getting/setting power reference levels was
missing an option to read back the currently available power levels
(minimum and maximum power levels).
This adds getters for TX and RX power ranges to multi_usrp and
radio_control. The power API is thus now more similar to the gain API,
which always had getters for gain ranges.
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/rfnoc/radio_control.hpp | 22 | ||||
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 22 | ||||
-rw-r--r-- | host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp | 2 | ||||
-rw-r--r-- | host/lib/rfnoc/radio_control_impl.cpp | 18 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 21 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp_python.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp_rfnoc.cpp | 12 |
7 files changed, 99 insertions, 0 deletions
diff --git a/host/include/uhd/rfnoc/radio_control.hpp b/host/include/uhd/rfnoc/radio_control.hpp index 67ddbd47d..3e05e1b91 100644 --- a/host/include/uhd/rfnoc/radio_control.hpp +++ b/host/include/uhd/rfnoc/radio_control.hpp @@ -261,6 +261,17 @@ public: */ virtual std::vector<std::string> get_tx_power_ref_keys(const size_t chan = 0) = 0; + /*! Return the available TX power range given the current configuration + * + * This will return the range of available power levels given the current + * frequency, gain profile, antenna, and whatever other settings may affect + * the available power ranges. Note that the available power range may + * change frequently, so don't assume an immutable range. + * + * \param chan The channel index + */ + virtual meta_range_t get_tx_power_range(const size_t chan) = 0; + /*! Return a list of valid RX gain names */ virtual std::vector<std::string> get_rx_gain_names(const size_t chan) const = 0; @@ -381,6 +392,17 @@ public: */ virtual std::vector<std::string> get_rx_power_ref_keys(const size_t chan = 0) = 0; + /*! Return the available RX power range given the current configuration + * + * This will return the range of available power levels given the current + * frequency, gain profile, antenna, and whatever other settings may affect + * the available power ranges. Note that the available power range may + * change frequently, so don't assume an immutable range. + * + * \param chan The channel index + */ + virtual meta_range_t get_rx_power_range(const size_t chan) = 0; + /*! Return a list of TX gain profiles for this radio */ virtual std::vector<std::string> get_tx_gain_profile_names( diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 1e2993bf4..2f441bd5a 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -1252,6 +1252,17 @@ public: */ virtual double get_rx_power_reference(const size_t chan = 0) = 0; + /*! Return the available RX power range given the current configuration + * + * This will return the range of available power levels given the current + * frequency, gain profile, antenna, and whatever other settings may affect + * the available power ranges. Note that the available power range may + * change frequently, so don't assume an immutable range. + * + * \param chan The channel index + */ + virtual meta_range_t get_rx_power_range(const size_t chan) = 0; + /******************************************************************* * TX methods ******************************************************************/ @@ -1500,6 +1511,17 @@ public: */ virtual double get_tx_power_reference(const size_t chan = 0) = 0; + /*! Return the available TX power range given the current configuration + * + * This will return the range of available power levels given the current + * frequency, gain profile, antenna, and whatever other settings may affect + * the available power ranges. Note that the available power range may + * change frequently, so don't assume an immutable range. + * + * \param chan The channel index + */ + virtual meta_range_t get_tx_power_range(const size_t chan) = 0; + /*! * Select the TX antenna on the frontend. * \param ant the antenna name diff --git a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp index 5ea1e57f0..f60319d32 100644 --- a/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp +++ b/host/lib/include/uhdlib/rfnoc/radio_control_impl.hpp @@ -111,6 +111,8 @@ public: virtual double get_tx_power_reference(const size_t chan); virtual std::vector<std::string> get_rx_power_ref_keys(const size_t); virtual std::vector<std::string> get_tx_power_ref_keys(const size_t); + virtual meta_range_t get_rx_power_range(const size_t chan); + virtual meta_range_t get_tx_power_range(const size_t chan); /************************************************************************** * LO Controls diff --git a/host/lib/rfnoc/radio_control_impl.cpp b/host/lib/rfnoc/radio_control_impl.cpp index 23a885a83..61937e080 100644 --- a/host/lib/rfnoc/radio_control_impl.cpp +++ b/host/lib/rfnoc/radio_control_impl.cpp @@ -636,6 +636,24 @@ std::vector<std::string> radio_control_impl::get_tx_power_ref_keys(const size_t return {_tx_pwr_mgr.at(chan)->get_key(), _tx_pwr_mgr.at(chan)->get_serial()}; } +uhd::meta_range_t radio_control_impl::get_rx_power_range(const size_t chan) +{ + if (_rx_pwr_mgr.empty()) { + throw uhd::not_implemented_error( + "get_rx_power_range() is not supported on this radio!"); + } + return _rx_pwr_mgr.at(chan)->get_power_range(); +} + +uhd::meta_range_t radio_control_impl::get_tx_power_range(const size_t chan) +{ + if (_tx_pwr_mgr.empty()) { + throw uhd::not_implemented_error( + "get_tx_power_range() is not supported on this radio!"); + } + return _tx_pwr_mgr.at(chan)->get_power_range(); +} + /****************************************************************************** * LO Default API diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 03a2a169c..e3424d748 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1730,6 +1730,17 @@ public: return _tree->access<double>(power_ref_path).get(); } + meta_range_t get_rx_power_range(const size_t chan) + { + const auto power_ref_path = rx_rf_fe_root(chan) / "ref_power/range"; + if (!_tree->exists(power_ref_path)) { + throw uhd::not_implemented_error( + "get_rx_power_range() not available for this device and channel"); + } + return _tree->access<meta_range_t>(power_ref_path).get(); + + } + void set_rx_antenna(const std::string& ant, size_t chan) { _tree->access<std::string>(rx_rf_fe_root(chan) / "antenna" / "value").set(ant); @@ -2230,6 +2241,16 @@ public: return _tree->access<double>(power_ref_path).get(); } + meta_range_t get_tx_power_range(const size_t chan) + { + const auto power_ref_path = tx_rf_fe_root(chan) / "ref_power/range"; + if (!_tree->exists(power_ref_path)) { + throw uhd::not_implemented_error( + "get_tx_power_range() not available for this device and channel"); + } + return _tree->access<meta_range_t>(power_ref_path).get(); + } + void set_tx_antenna(const std::string& ant, size_t chan) { _tree->access<std::string>(tx_rf_fe_root(chan) / "antenna" / "value").set(ant); diff --git a/host/lib/usrp/multi_usrp_python.hpp b/host/lib/usrp/multi_usrp_python.hpp index 6c2fd2ccf..cec901315 100644 --- a/host/lib/usrp/multi_usrp_python.hpp +++ b/host/lib/usrp/multi_usrp_python.hpp @@ -130,6 +130,7 @@ void export_multi_usrp(py::module& m) .def("has_rx_power_reference" , &multi_usrp::has_rx_power_reference, py::arg("chan") = 0) .def("set_rx_power_reference" , &multi_usrp::set_rx_power_reference, py::arg("power_dbm"), py::arg("chan") = 0) .def("get_rx_power_reference" , &multi_usrp::get_rx_power_reference, py::arg("chan") = 0) + .def("get_rx_power_range" , &multi_usrp::get_rx_power_range, py::arg("chan") = 0) // TX methods .def("set_tx_subdev_spec" , &multi_usrp::set_tx_subdev_spec, py::arg("spec"), py::arg("mboard") = ALL_MBOARDS) @@ -171,6 +172,7 @@ void export_multi_usrp(py::module& m) .def("has_tx_power_reference" , &multi_usrp::has_tx_power_reference, py::arg("chan") = 0) .def("set_tx_power_reference" , &multi_usrp::set_tx_power_reference, py::arg("power_dbm"), py::arg("chan") = 0) .def("get_tx_power_reference" , &multi_usrp::get_tx_power_reference, py::arg("chan") = 0) + .def("get_tx_power_range" , &multi_usrp::get_tx_power_range, py::arg("chan") = 0) // GPIO methods .def("get_gpio_banks" , &multi_usrp::get_gpio_banks) diff --git a/host/lib/usrp/multi_usrp_rfnoc.cpp b/host/lib/usrp/multi_usrp_rfnoc.cpp index 26932ef30..659d879e8 100644 --- a/host/lib/usrp/multi_usrp_rfnoc.cpp +++ b/host/lib/usrp/multi_usrp_rfnoc.cpp @@ -1484,6 +1484,12 @@ public: return rx_chain.radio->get_rx_power_reference(rx_chain.block_chan); } + meta_range_t get_rx_power_range(const size_t chan) + { + auto& rx_chain = _get_rx_chan(chan); + return rx_chain.radio->get_rx_power_range(rx_chain.block_chan); + } + void set_rx_antenna(const std::string& ant, size_t chan = 0) { MUX_RX_API_CALL(set_rx_antenna, ant); @@ -1955,6 +1961,12 @@ public: return tx_chain.radio->get_tx_power_reference(tx_chain.block_chan); } + meta_range_t get_tx_power_range(const size_t chan) + { + auto& tx_chain = _get_tx_chan(chan); + return tx_chain.radio->get_tx_power_range(tx_chain.block_chan); + } + void set_tx_antenna(const std::string& ant, size_t chan = 0) { MUX_TX_API_CALL(set_tx_antenna, ant); |