From 5e265ad175658ab6ac784aa298d0e760d8380b68 Mon Sep 17 00:00:00 2001 From: Trung N Tran Date: Tue, 9 Jan 2018 17:52:48 -0800 Subject: usrp: add multiusrp api for gain profile. --- host/lib/usrp/multi_usrp.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'host/lib') diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 57f7cc8f6..636940f53 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1272,6 +1272,42 @@ public: } } + void set_rx_gain_profile(const std::string& profile, const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(rx_rf_fe_root(chan) / "gains/all/profile/value")) { + _tree->access(rx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } else { + for (size_t c = 0; c < get_rx_num_channels(); c++){ + if (_tree->exists(rx_rf_fe_root(c) / "gains/all/profile/value")) { + _tree->access(rx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } + } + } + + std::string get_rx_gain_profile(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(rx_rf_fe_root(chan) / "gains/all/profile/value")) { + return _tree->access(rx_rf_fe_root(chan) / "gains/all/profile/value").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get rx gain profile from all channels at once. Ignoring this operation") + return ""; + } + } + + std::vector get_rx_gain_profile_names(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(rx_rf_fe_root(chan) / "gains/all/profile/options")) { + return _tree->access>(rx_rf_fe_root(chan) / "gains/all/profile/options").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get rx gain profile from all channels at once. Ignoring this operation") + return std::vector(); + } + } + void set_normalized_rx_gain(double gain, size_t chan = 0) { if (gain > 1.0 || gain < 0.0) { @@ -1631,6 +1667,42 @@ public: } } + void set_tx_gain_profile(const std::string& profile, const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(tx_rf_fe_root(chan) / "gains/all/profile/value")) { + _tree->access(tx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } else { + for (size_t c = 0; c < get_tx_num_channels(); c++){ + if (_tree->exists(tx_rf_fe_root(c) / "gains/all/profile/value")) { + _tree->access(tx_rf_fe_root(chan) / "gains/all/profile/value").set(profile); + } + } + } + } + + std::string get_tx_gain_profile(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(tx_rf_fe_root(chan) / "gains/all/profile/value")) { + return _tree->access(tx_rf_fe_root(chan) / "gains/all/profile/value").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get tx gain profile from all channels at once. Ignoring this operation") + return ""; + } + } + + std::vector get_tx_gain_profile_names(const size_t chan){ + if (chan != ALL_CHANS) { + if (_tree->exists(tx_rf_fe_root(chan) / "gains/all/profile/options")) { + return _tree->access>(tx_rf_fe_root(chan) / "gains/all/profile/options").get(); + } + } else { + UHD_LOG_ERROR("MULTI_USRP", "Can't get tx gain profile from all channels at once. Ignoring this operation") + return std::vector(); + } + } + void set_normalized_tx_gain(double gain, size_t chan = 0) { if (gain > 1.0 || gain < 0.0) { -- cgit v1.2.3