diff options
Diffstat (limited to 'host/lib/usrp/multi_usrp.cpp')
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 367 |
1 files changed, 253 insertions, 114 deletions
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 64f82e559..2f416d93a 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -15,18 +15,13 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include <uhd/property_tree.hpp> #include <uhd/usrp/multi_usrp.hpp> -#include <uhd/usrp/tune_helper.hpp> #include <uhd/usrp/mboard_iface.hpp> #include <uhd/utils/msg.hpp> #include <uhd/exception.hpp> #include <uhd/utils/msg.hpp> #include <uhd/utils/gain_group.hpp> -#include <uhd/usrp/subdev_props.hpp> -#include <uhd/usrp/mboard_props.hpp> -#include <uhd/usrp/device_props.hpp> -#include <uhd/usrp/dboard_props.hpp> -#include <uhd/usrp/dsp_props.hpp> #include <boost/thread.hpp> #include <boost/foreach.hpp> #include <boost/format.hpp> @@ -40,15 +35,7 @@ const std::string multi_usrp::ALL_GAINS = ""; /*********************************************************************** * Helper methods **********************************************************************/ -static inline uhd::freq_range_t add_dsp_shift( - const uhd::freq_range_t &range, - wax::obj dsp -){ - double codec_rate = dsp[uhd::usrp::DSP_PROP_CODEC_RATE].as<double>(); - return uhd::freq_range_t(range.start() - codec_rate/2.0, range.stop() + codec_rate/2.0); -} - -static inline void do_samp_rate_warning_message( +static void do_samp_rate_warning_message( double target_rate, double actual_rate, const std::string &xx @@ -63,7 +50,7 @@ static inline void do_samp_rate_warning_message( } } -static inline void do_tune_freq_warning_message( +static void do_tune_freq_warning_message( double target_freq, double actual_freq, const std::string &xx @@ -79,12 +66,130 @@ static inline void do_tune_freq_warning_message( } /*********************************************************************** + * Gain helper functions + **********************************************************************/ +static double get_gain_value(property_tree::sptr tree, const property_tree::path_type &path){ + return tree->access<double>(path / "value").get(); +} + +static void set_gain_value(property_tree::sptr tree, const property_tree::path_type &path, const double gain){ + tree->access<double>(path / "value").set(gain); +} + +static meta_range_t get_gain_range(property_tree::sptr tree, const property_tree::path_type &path){ + return tree->access<meta_range_t>(path / "range").get(); +} + +static gain_fcns_t make_gain_fcns_from_path(property_tree::sptr tree, const property_tree::path_type &path){ + gain_fcns_t gain_fcns; + gain_fcns.get_range = boost::bind(&get_gain_range, tree, path); + gain_fcns.get_value = boost::bind(&get_gain_value, tree, path); + gain_fcns.set_value = boost::bind(&set_gain_value, tree, path, _1); + return gain_fcns; +} + +/*********************************************************************** + * Tune Helper Functions + **********************************************************************/ +static const double RX_SIGN = +1.0; +static const double TX_SIGN = -1.0; + +static tune_result_t tune_xx_subdev_and_dsp( + const double xx_sign, + property_tree::sptr tree, + const property_tree::path_type &dsp_path, + const property_tree::path_type &rf_fe_path, + const tune_request_t &tune_request +){ + //------------------------------------------------------------------ + //-- calculate the LO offset, only used with automatic policy + //------------------------------------------------------------------ + double lo_offset = 0.0; + if (tree->access<bool>(rf_fe_path / "use_lo_offset").get()){ + //If the local oscillator will be in the passband, use an offset. + //But constrain the LO offset by the width of the filter bandwidth. + const double rate = tree->access<double>(dsp_path / "rate" / "value").get(); + const double bw = tree->access<double>(rf_fe_path / "bandwidth" / "value").get(); + if (bw > rate) lo_offset = std::min((bw - rate)/2, rate/2); + } + + //------------------------------------------------------------------ + //-- set the RF frequency depending upon the policy + //------------------------------------------------------------------ + double target_rf_freq = 0.0; + switch (tune_request.rf_freq_policy){ + case tune_request_t::POLICY_AUTO: + target_rf_freq = tune_request.target_freq + lo_offset; + tree->access<double>(rf_fe_path / "freq" / "value").set(target_rf_freq); + break; + + case tune_request_t::POLICY_MANUAL: + target_rf_freq = tune_request.rf_freq; + tree->access<double>(rf_fe_path / "freq" / "value").set(target_rf_freq); + break; + + case tune_request_t::POLICY_NONE: break; //does not set + } + const double actual_rf_freq = tree->access<double>(rf_fe_path / "freq" / "value").get(); + + //------------------------------------------------------------------ + //-- calculate the dsp freq, only used with automatic policy + //------------------------------------------------------------------ + double target_dsp_freq = actual_rf_freq - tune_request.target_freq; + + //invert the sign on the dsp freq for transmit + target_dsp_freq *= xx_sign; + + //------------------------------------------------------------------ + //-- set the dsp frequency depending upon the dsp frequency policy + //------------------------------------------------------------------ + switch (tune_request.dsp_freq_policy){ + case tune_request_t::POLICY_AUTO: + tree->access<double>(dsp_path / "freq" / "value").set(target_dsp_freq); + break; + + case tune_request_t::POLICY_MANUAL: + target_dsp_freq = tune_request.dsp_freq; + tree->access<double>(dsp_path / "freq" / "value").set(target_dsp_freq); + break; + + case tune_request_t::POLICY_NONE: break; //does not set + } + const double actual_dsp_freq = tree->access<double>(dsp_path / "freq" / "value").get(); + + //------------------------------------------------------------------ + //-- load and return the tune result + //------------------------------------------------------------------ + tune_result_t tune_result; + tune_result.target_rf_freq = target_rf_freq; + tune_result.actual_rf_freq = actual_rf_freq; + tune_result.target_dsp_freq = target_dsp_freq; + tune_result.actual_dsp_freq = actual_dsp_freq; + return tune_result; +} + +static double derive_freq_from_xx_subdev_and_dsp( + const double xx_sign, + property_tree::sptr tree, + const property_tree::path_type &dsp_path, + const property_tree::path_type &rf_fe_path +){ + //extract actual dsp and IF frequencies + const double actual_rf_freq = tree->access<double>(rf_fe_path / "freq" / "value").get(); + const double actual_dsp_freq = tree->access<double>(dsp_path / "freq" / "value").get(); + + //invert the sign on the dsp freq for transmit + return actual_rf_freq - actual_dsp_freq * xx_sign; +} + +/*********************************************************************** * Multi USRP Implementation **********************************************************************/ class multi_usrp_impl : public multi_usrp{ public: multi_usrp_impl(const device_addr_t &addr){ _dev = device::make(addr); + _tree = (*_dev)[0].as<property_tree::sptr>(); } device::sptr get_device(void){ @@ -96,7 +201,7 @@ public: ******************************************************************/ void set_master_clock_rate(double rate, size_t mboard){ if (mboard != ALL_MBOARDS){ - _mboard(mboard)[MBOARD_PROP_CLOCK_RATE] = rate; + _tree->access<double>(mb_root(mboard) / "tick_rate").set(rate); return; } for (size_t m = 0; m < get_num_mboards(); m++){ @@ -105,7 +210,7 @@ public: } double get_master_clock_rate(size_t mboard){ - return _mboard(mboard)[MBOARD_PROP_CLOCK_RATE].as<double>(); + return _tree->access<double>(mb_root(mboard) / "tick_rate").get(); } std::string get_pp_string(void){ @@ -114,13 +219,13 @@ public: " Device: %s\n" ) % ((get_num_mboards() > 1)? "Multi" : "Single") - % (*_dev)[DEVICE_PROP_NAME].as<std::string>() + % (_tree->access<std::string>("/name").get()) ); for (size_t m = 0; m < get_num_mboards(); m++){ buff += str(boost::format( " Mboard %d: %s\n" ) % m - % _mboard(m)[MBOARD_PROP_NAME].as<std::string>() + % (_tree->access<std::string>(mb_root(m) / "name").get()) ); } @@ -133,9 +238,9 @@ public: " RX Dboard: %s\n" " RX Subdev: %s\n" ) % chan - % _rx_dsp(chan)[DSP_PROP_NAME].as<std::string>() - % _rx_dboard(chan)[DBOARD_PROP_NAME].as<std::string>() - % _rx_subdev(chan)[SUBDEV_PROP_NAME].as<std::string>() + % rx_dsp_root(chan).leaf() + % rx_rf_fe_root(chan).branch_path().branch_path().leaf() + % (_tree->access<std::string>(rx_rf_fe_root(chan) / "name").get()) ); } } @@ -149,9 +254,9 @@ public: " TX Dboard: %s\n" " TX Subdev: %s\n" ) % chan - % _tx_dsp(chan)[DSP_PROP_NAME].as<std::string>() - % _tx_dboard(chan)[DBOARD_PROP_NAME].as<std::string>() - % _tx_subdev(chan)[SUBDEV_PROP_NAME].as<std::string>() + % tx_dsp_root(chan).leaf() + % tx_rf_fe_root(chan).branch_path().branch_path().leaf() + % (_tree->access<std::string>(tx_rf_fe_root(chan) / "name").get()) ); } } @@ -160,20 +265,20 @@ public: } std::string get_mboard_name(size_t mboard){ - return _mboard(mboard)[MBOARD_PROP_NAME].as<std::string>(); + return _tree->access<std::string>(mb_root(mboard) / "name").get(); } time_spec_t get_time_now(size_t mboard = 0){ - return _mboard(mboard)[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); + return _tree->access<time_spec_t>(mb_root(mboard) / "time/now").get(); } time_spec_t get_time_last_pps(size_t mboard = 0){ - return _mboard(mboard)[MBOARD_PROP_TIME_PPS].as<time_spec_t>(); + return _tree->access<time_spec_t>(mb_root(mboard) / "time/pps").get(); } void set_time_now(const time_spec_t &time_spec, size_t mboard){ if (mboard != ALL_MBOARDS){ - _mboard(mboard)[MBOARD_PROP_TIME_NOW] = time_spec; + _tree->access<time_spec_t>(mb_root(mboard) / "time/now").set(time_spec); return; } for (size_t m = 0; m < get_num_mboards(); m++){ @@ -183,7 +288,7 @@ public: void set_time_next_pps(const time_spec_t &time_spec){ for (size_t m = 0; m < get_num_mboards(); m++){ - _mboard(m)[MBOARD_PROP_TIME_PPS] = time_spec; + _tree->access<time_spec_t>(mb_root(m) / "time/pps").set(time_spec); } } @@ -208,8 +313,8 @@ public: //verify that the time registers are read to be within a few RTT for (size_t m = 1; m < get_num_mboards(); m++){ - time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); - time_spec_t time_i = _mboard(m)[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); + time_spec_t time_0 = this->get_time_now(0); + time_spec_t time_i = this->get_time_now(m); if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)){ //10 ms: greater than RTT but not too big UHD_MSG(warning) << boost::format( "Detected time deviation between board %d and board 0.\n" @@ -222,8 +327,8 @@ public: bool get_time_synchronized(void){ for (size_t m = 1; m < get_num_mboards(); m++){ - time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); - time_spec_t time_i = _mboard(m)[MBOARD_PROP_TIME_NOW].as<time_spec_t>(); + time_spec_t time_0 = this->get_time_now(0); + time_spec_t time_i = this->get_time_now(m); if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)) return false; } return true; @@ -231,7 +336,7 @@ public: void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan){ if (chan != ALL_CHANS){ - _rx_dsp(chan)[DSP_PROP_STREAM_CMD] = stream_cmd; + _tree->access<stream_cmd_t>(rx_dsp_root(chan) / "stream_cmd").set(stream_cmd); return; } for (size_t c = 0; c < get_rx_num_channels(); c++){ @@ -241,7 +346,26 @@ public: void set_clock_config(const clock_config_t &clock_config, size_t mboard){ if (mboard != ALL_MBOARDS){ - _mboard(mboard)[MBOARD_PROP_CLOCK_CONFIG] = clock_config; + //set the reference source... + std::string clock_source; + switch(clock_config.ref_source){ + case clock_config_t::REF_INT: clock_source = "internal"; break; + case clock_config_t::PPS_SMA: clock_source = "external"; break; + case clock_config_t::PPS_MIMO: clock_source = "mimo"; break; + default: clock_source = "unknown"; + } + if (clock_source == "external" and clock_config.pps_polarity == clock_config_t::PPS_NEG) clock_source = "_external_"; + _tree->access<std::string>(mb_root(mboard) / "clock_source" / "value").set(clock_source); + + //set the time source + std::string time_source; + switch(clock_config.pps_source){ + case clock_config_t::PPS_INT: time_source = "internal"; break; + case clock_config_t::PPS_SMA: time_source = "external"; break; + case clock_config_t::PPS_MIMO: time_source = "mimo"; break; + default: time_source = "unknown"; + } + _tree->access<std::string>(mb_root(mboard) / "time_source" / "value").set(time_source); return; } for (size_t m = 0; m < get_num_mboards(); m++){ @@ -250,19 +374,19 @@ public: } size_t get_num_mboards(void){ - return (*_dev)[DEVICE_PROP_MBOARD_NAMES].as<prop_names_t>().size(); + return _tree->list("/mboards").size(); } sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){ - return _mboard(mboard)[named_prop_t(MBOARD_PROP_SENSOR, name)].as<sensor_value_t>(); + return _tree->access<sensor_value_t>(mb_root(mboard) / "sensors" / name).get(); } std::vector<std::string> get_mboard_sensor_names(size_t mboard){ - return _mboard(mboard)[MBOARD_PROP_SENSOR_NAMES].as<prop_names_t>(); + return _tree->list(mb_root(mboard) / "sensors"); } - - mboard_iface::sptr get_mboard_iface(size_t mboard){ - return _mboard(mboard)[MBOARD_PROP_IFACE].as<mboard_iface::sptr>(); + + mboard_iface::sptr get_mboard_iface(size_t){ + return mboard_iface::sptr(); //not implemented } /******************************************************************* @@ -270,7 +394,7 @@ public: ******************************************************************/ void set_rx_subdev_spec(const subdev_spec_t &spec, size_t mboard){ if (mboard != ALL_MBOARDS){ - _mboard(mboard)[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; + _tree->access<subdev_spec_t>(mb_root(mboard) / "rx_subdev_spec").set(spec); return; } for (size_t m = 0; m < get_num_mboards(); m++){ @@ -279,7 +403,7 @@ public: } subdev_spec_t get_rx_subdev_spec(size_t mboard){ - return _mboard(mboard)[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>(); + return _tree->access<subdev_spec_t>(mb_root(mboard) / "rx_subdev_spec").get(); } size_t get_rx_num_channels(void){ @@ -291,12 +415,12 @@ public: } std::string get_rx_subdev_name(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_NAME].as<std::string>(); + return _tree->access<std::string>(rx_rf_fe_root(chan) / "name").get(); } void set_rx_rate(double rate, size_t chan){ if (chan != ALL_CHANS){ - _rx_dsp(chan)[DSP_PROP_HOST_RATE] = rate; + _tree->access<double>(rx_dsp_root(chan) / "rate" / "value").set(rate); do_samp_rate_warning_message(rate, get_rx_rate(chan), "RX"); return; } @@ -306,69 +430,71 @@ public: } double get_rx_rate(size_t chan){ - return _rx_dsp(chan)[DSP_PROP_HOST_RATE].as<double>(); + return _tree->access<double>(rx_dsp_root(chan) / "rate" / "value").get(); } tune_result_t set_rx_freq(const tune_request_t &tune_request, size_t chan){ - tune_result_t r = tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), tune_request); + tune_result_t r = tune_xx_subdev_and_dsp(RX_SIGN, _tree, rx_dsp_root(chan), rx_rf_fe_root(chan), tune_request); do_tune_freq_warning_message(tune_request.target_freq, get_rx_freq(chan), "RX"); return r; } double get_rx_freq(size_t chan){ - return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan)); + return derive_freq_from_xx_subdev_and_dsp(RX_SIGN, _tree, rx_dsp_root(chan), rx_rf_fe_root(chan)); } freq_range_t get_rx_freq_range(size_t chan){ - return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _rx_dsp(chan)); + meta_range_t range = _tree->access<meta_range_t>(rx_rf_fe_root(chan) / "freq" / "range").get(); + meta_range_t dsp_range = _tree->access<meta_range_t>(rx_dsp_root(chan) / "freq" / "range").get(); + return meta_range_t(range.start() + dsp_range.start(), range.stop() + dsp_range.stop(), dsp_range.step()); } void set_rx_gain(double gain, const std::string &name, size_t chan){ - return _rx_gain_group(chan)->set_value(gain, name); + return rx_gain_group(chan)->set_value(gain, name); } double get_rx_gain(const std::string &name, size_t chan){ - return _rx_gain_group(chan)->get_value(name); + return rx_gain_group(chan)->get_value(name); } gain_range_t get_rx_gain_range(const std::string &name, size_t chan){ - return _rx_gain_group(chan)->get_range(name); + return rx_gain_group(chan)->get_range(name); } std::vector<std::string> get_rx_gain_names(size_t chan){ - return _rx_gain_group(chan)->get_names(); + return rx_gain_group(chan)->get_names(); } void set_rx_antenna(const std::string &ant, size_t chan){ - _rx_subdev(chan)[SUBDEV_PROP_ANTENNA] = ant; + _tree->access<std::string>(rx_rf_fe_root(chan) / "antenna" / "value").set(ant); } std::string get_rx_antenna(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_ANTENNA].as<std::string>(); + return _tree->access<std::string>(rx_rf_fe_root(chan) / "antenna" / "value").get(); } std::vector<std::string> get_rx_antennas(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>(); + return _tree->access<std::vector<std::string> >(rx_rf_fe_root(chan) / "antenna" / "options").get(); } void set_rx_bandwidth(double bandwidth, size_t chan){ - _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth; + _tree->access<double>(rx_rf_fe_root(chan) / "bandwidth" / "value").set(bandwidth); } double get_rx_bandwidth(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as<double>(); + return _tree->access<double>(rx_rf_fe_root(chan) / "bandwidth" / "value").get(); } dboard_iface::sptr get_rx_dboard_iface(size_t chan){ - return _rx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as<dboard_iface::sptr>(); + return _tree->access<dboard_iface::sptr>(rx_rf_fe_root(chan).branch_path().branch_path() / "iface").get(); } sensor_value_t get_rx_sensor(const std::string &name, size_t chan){ - return _rx_subdev(chan)[named_prop_t(SUBDEV_PROP_SENSOR, name)].as<sensor_value_t>(); + return _tree->access<sensor_value_t>(rx_rf_fe_root(chan) / "sensors" / name).get(); } std::vector<std::string> get_rx_sensor_names(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_SENSOR_NAMES].as<prop_names_t>(); + return _tree->list(rx_rf_fe_root(chan) / "sensors"); } /******************************************************************* @@ -376,7 +502,7 @@ public: ******************************************************************/ void set_tx_subdev_spec(const subdev_spec_t &spec, size_t mboard){ if (mboard != ALL_MBOARDS){ - _mboard(mboard)[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; + _tree->access<subdev_spec_t>(mb_root(mboard) / "tx_subdev_spec").set(spec); return; } for (size_t m = 0; m < get_num_mboards(); m++){ @@ -385,11 +511,11 @@ public: } subdev_spec_t get_tx_subdev_spec(size_t mboard){ - return _mboard(mboard)[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>(); + return _tree->access<subdev_spec_t>(mb_root(mboard) / "tx_subdev_spec").get(); } std::string get_tx_subdev_name(size_t chan){ - return _tx_subdev(chan)[SUBDEV_PROP_NAME].as<std::string>(); + return _tree->access<std::string>(tx_rf_fe_root(chan) / "name").get(); } size_t get_tx_num_channels(void){ @@ -402,7 +528,7 @@ public: void set_tx_rate(double rate, size_t chan){ if (chan != ALL_CHANS){ - _tx_dsp(chan)[DSP_PROP_HOST_RATE] = rate; + _tree->access<double>(tx_dsp_root(chan) / "rate" / "value").set(rate); do_samp_rate_warning_message(rate, get_tx_rate(chan), "TX"); return; } @@ -412,73 +538,76 @@ public: } double get_tx_rate(size_t chan){ - return _tx_dsp(chan)[DSP_PROP_HOST_RATE].as<double>(); + return _tree->access<double>(tx_dsp_root(chan) / "rate" / "value").get(); } tune_result_t set_tx_freq(const tune_request_t &tune_request, size_t chan){ - tune_result_t r = tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), tune_request); + tune_result_t r = tune_xx_subdev_and_dsp(TX_SIGN, _tree, tx_dsp_root(chan), tx_rf_fe_root(chan), tune_request); do_tune_freq_warning_message(tune_request.target_freq, get_tx_freq(chan), "TX"); return r; } double get_tx_freq(size_t chan){ - return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan)); + return derive_freq_from_xx_subdev_and_dsp(TX_SIGN, _tree, tx_dsp_root(chan), tx_rf_fe_root(chan)); } freq_range_t get_tx_freq_range(size_t chan){ - return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>(), _tx_dsp(chan)); + meta_range_t range = _tree->access<meta_range_t>(tx_rf_fe_root(chan) / "freq" / "range").get(); + meta_range_t dsp_range = _tree->access<meta_range_t>(tx_dsp_root(chan) / "freq" / "range").get(); + return meta_range_t(range.start() + dsp_range.start(), range.stop() + dsp_range.stop(), dsp_range.step()); } void set_tx_gain(double gain, const std::string &name, size_t chan){ - return _tx_gain_group(chan)->set_value(gain, name); + return tx_gain_group(chan)->set_value(gain, name); } double get_tx_gain(const std::string &name, size_t chan){ - return _tx_gain_group(chan)->get_value(name); + return tx_gain_group(chan)->get_value(name); } gain_range_t get_tx_gain_range(const std::string &name, size_t chan){ - return _tx_gain_group(chan)->get_range(name); + return tx_gain_group(chan)->get_range(name); } std::vector<std::string> get_tx_gain_names(size_t chan){ - return _tx_gain_group(chan)->get_names(); + return tx_gain_group(chan)->get_names(); } void set_tx_antenna(const std::string &ant, size_t chan){ - _tx_subdev(chan)[SUBDEV_PROP_ANTENNA] = ant; + _tree->access<std::string>(tx_rf_fe_root(chan) / "antenna" / "value").set(ant); } std::string get_tx_antenna(size_t chan){ - return _tx_subdev(chan)[SUBDEV_PROP_ANTENNA].as<std::string>(); + return _tree->access<std::string>(tx_rf_fe_root(chan) / "antenna" / "value").get(); } std::vector<std::string> get_tx_antennas(size_t chan){ - return _tx_subdev(chan)[SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>(); + return _tree->access<std::vector<std::string> >(tx_rf_fe_root(chan) / "antenna" / "options").get(); } void set_tx_bandwidth(double bandwidth, size_t chan){ - _tx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth; + _tree->access<double>(tx_rf_fe_root(chan) / "bandwidth" / "value").set(bandwidth); } double get_tx_bandwidth(size_t chan){ - return _tx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as<double>(); + return _tree->access<double>(tx_rf_fe_root(chan) / "bandwidth" / "value").get(); } dboard_iface::sptr get_tx_dboard_iface(size_t chan){ - return _tx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as<dboard_iface::sptr>(); + return _tree->access<dboard_iface::sptr>(tx_rf_fe_root(chan).branch_path().branch_path() / "iface").get(); } sensor_value_t get_tx_sensor(const std::string &name, size_t chan){ - return _tx_subdev(chan)[named_prop_t(SUBDEV_PROP_SENSOR, name)].as<sensor_value_t>(); + return _tree->access<sensor_value_t>(tx_rf_fe_root(chan) / "sensors" / name).get(); } std::vector<std::string> get_tx_sensor_names(size_t chan){ - return _tx_subdev(chan)[SUBDEV_PROP_SENSOR_NAMES].as<prop_names_t>(); + return _tree->list(tx_rf_fe_root(chan) / "sensors"); } private: device::sptr _dev; + property_tree::sptr _tree; struct mboard_chan_pair{ size_t mboard, chan; @@ -507,49 +636,59 @@ private: return mcp; } - wax::obj _mboard(size_t mboard){ - std::string mb_name = (*_dev)[DEVICE_PROP_MBOARD_NAMES].as<prop_names_t>().at(mboard); - return (*_dev)[named_prop_t(DEVICE_PROP_MBOARD, mb_name)]; + property_tree::path_type mb_root(const size_t mboard){ + const std::string name = _tree->list("/mboards").at(mboard); + return "/mboards/" + name; } - wax::obj _rx_dsp(size_t chan){ - mboard_chan_pair mcp = rx_chan_to_mcp(chan); - prop_names_t dsp_names = _mboard(mcp.mboard)[MBOARD_PROP_RX_DSP_NAMES].as<prop_names_t>(); - return _mboard(mcp.mboard)[named_prop_t(MBOARD_PROP_RX_DSP, dsp_names.at(mcp.chan))]; - } - wax::obj _tx_dsp(size_t chan){ - mboard_chan_pair mcp = tx_chan_to_mcp(chan); - prop_names_t dsp_names = _mboard(mcp.mboard)[MBOARD_PROP_TX_DSP_NAMES].as<prop_names_t>(); - return _mboard(mcp.mboard)[named_prop_t(MBOARD_PROP_TX_DSP, dsp_names.at(mcp.chan))]; - } - wax::obj _rx_dboard(size_t chan){ + + property_tree::path_type rx_dsp_root(const size_t chan){ mboard_chan_pair mcp = rx_chan_to_mcp(chan); - std::string db_name = get_rx_subdev_spec(mcp.mboard).at(mcp.chan).db_name; - return _mboard(mcp.mboard)[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)]; + const std::string name = _tree->list(mb_root(mcp.mboard) / "rx_dsps").at(mcp.chan); + return mb_root(mcp.mboard) / "rx_dsps" / name; } - wax::obj _tx_dboard(size_t chan){ + + property_tree::path_type tx_dsp_root(const size_t chan){ mboard_chan_pair mcp = tx_chan_to_mcp(chan); - std::string db_name = get_tx_subdev_spec(mcp.mboard).at(mcp.chan).db_name; - return _mboard(mcp.mboard)[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)]; + const std::string name = _tree->list(mb_root(mcp.mboard) / "tx_dsps").at(mcp.chan); + return mb_root(mcp.mboard) / "tx_dsps" / name; } - wax::obj _rx_subdev(size_t chan){ + + property_tree::path_type rx_rf_fe_root(const size_t chan){ mboard_chan_pair mcp = rx_chan_to_mcp(chan); - std::string sd_name = get_rx_subdev_spec(mcp.mboard).at(mcp.chan).sd_name; - return _rx_dboard(chan)[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; + const subdev_spec_pair_t spec = get_rx_subdev_spec(mcp.mboard).at(mcp.chan); + return mb_root(mcp.mboard) / "dboards" / spec.db_name / "rx_frontends" / spec.sd_name; } - wax::obj _tx_subdev(size_t chan){ + + property_tree::path_type tx_rf_fe_root(const size_t chan){ mboard_chan_pair mcp = tx_chan_to_mcp(chan); - std::string sd_name = get_tx_subdev_spec(mcp.mboard).at(mcp.chan).sd_name; - return _tx_dboard(chan)[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; + const subdev_spec_pair_t spec = get_tx_subdev_spec(mcp.mboard).at(mcp.chan); + return mb_root(mcp.mboard) / "dboards" / spec.db_name / "tx_frontends" / spec.sd_name; } - gain_group::sptr _rx_gain_group(size_t chan){ + + gain_group::sptr rx_gain_group(size_t chan){ mboard_chan_pair mcp = rx_chan_to_mcp(chan); - std::string sd_name = get_rx_subdev_spec(mcp.mboard).at(mcp.chan).sd_name; - return _rx_dboard(chan)[named_prop_t(DBOARD_PROP_GAIN_GROUP, sd_name)].as<gain_group::sptr>(); + const subdev_spec_pair_t spec = get_rx_subdev_spec(mcp.mboard).at(mcp.chan); + gain_group::sptr gg = gain_group::make(); + BOOST_FOREACH(const std::string &name, _tree->list(mb_root(mcp.mboard) / "rx_codecs" / spec.db_name / "gains")){ + gg->register_fcns("ADC-"+name, make_gain_fcns_from_path(_tree, mb_root(mcp.mboard) / "rx_codecs" / spec.db_name / "gains" / name), 0 /* low prio */); + } + BOOST_FOREACH(const std::string &name, _tree->list(rx_rf_fe_root(chan) / "gains")){ + gg->register_fcns(name, make_gain_fcns_from_path(_tree, rx_rf_fe_root(chan) / "gains" / name), 1 /* high prio */); + } + return gg; } - gain_group::sptr _tx_gain_group(size_t chan){ + + gain_group::sptr tx_gain_group(size_t chan){ mboard_chan_pair mcp = tx_chan_to_mcp(chan); - std::string sd_name = get_tx_subdev_spec(mcp.mboard).at(mcp.chan).sd_name; - return _tx_dboard(chan)[named_prop_t(DBOARD_PROP_GAIN_GROUP, sd_name)].as<gain_group::sptr>(); + const subdev_spec_pair_t spec = get_tx_subdev_spec(mcp.mboard).at(mcp.chan); + gain_group::sptr gg = gain_group::make(); + BOOST_FOREACH(const std::string &name, _tree->list(mb_root(mcp.mboard) / "tx_codecs" / spec.db_name / "gains")){ + gg->register_fcns("ADC-"+name, make_gain_fcns_from_path(_tree, mb_root(mcp.mboard) / "tx_codecs" / spec.db_name / "gains" / name), 1 /* high prio */); + } + BOOST_FOREACH(const std::string &name, _tree->list(tx_rf_fe_root(chan) / "gains")){ + gg->register_fcns(name, make_gain_fcns_from_path(_tree, tx_rf_fe_root(chan) / "gains" / name), 0 /* low prio */); + } + return gg; } }; |