From 58257d749d9bc35de41e755f8d968a1463fae7a6 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 16 Jan 2018 18:27:12 -0800 Subject: multi_usrp: Fix compiler warnings Also elevated a UHD_LOG_ERROR() to an exception. --- host/lib/usrp/multi_usrp.cpp | 63 ++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 636940f53..a4b459b6e 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -1286,36 +1286,47 @@ public: } } - std::string get_rx_gain_profile(const size_t chan){ + 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(); + 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 ""; + throw uhd::runtime_error("Can't get RX gain profile from " + "all channels at once!"); } + return ""; } - std::vector get_rx_gain_profile_names(const size_t chan){ + 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(); + 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(); + throw uhd::runtime_error("Can't get RX gain profile names from " + "all channels at once!"); } + return std::vector(); } void set_normalized_rx_gain(double gain, size_t chan = 0) { - if (gain > 1.0 || gain < 0.0) { - throw uhd::runtime_error("Normalized gain out of range, must be in [0, 1]."); - } - gain_range_t gain_range = get_rx_gain_range(ALL_GAINS, chan); - double abs_gain = (gain * (gain_range.stop() - gain_range.start())) + gain_range.start(); - set_rx_gain(abs_gain, ALL_GAINS, chan); + if (gain > 1.0 || gain < 0.0) { + throw uhd::runtime_error("Normalized gain out of range, " + "must be in [0, 1]."); + } + const gain_range_t gain_range = get_rx_gain_range(ALL_GAINS, chan); + const double abs_gain = + (gain * (gain_range.stop() - gain_range.start())) + + gain_range.start(); + set_rx_gain(abs_gain, ALL_GAINS, chan); } void set_rx_agc(bool enable, size_t chan = 0) @@ -1681,26 +1692,34 @@ public: } } - std::string get_tx_gain_profile(const size_t chan){ + 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(); + 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 ""; + throw uhd::runtime_error("Can't get TX gain profile from " + "all channels at once!"); } + return ""; } - std::vector get_tx_gain_profile_names(const size_t chan){ + 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(); + 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(); + throw uhd::runtime_error("Can't get TX gain profile names from " + "all channels at once!"); } + return std::vector(); } void set_normalized_tx_gain(double gain, size_t chan = 0) -- cgit v1.2.3