diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/cores/rx_dsp_core_200.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/cores/tx_frontend_core_200.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 9 | ||||
-rw-r--r-- | host/lib/usrp2/usrp2_impl.cpp | 6 | ||||
-rw-r--r-- | host/utils/uhd_usrp_probe.cpp | 110 |
5 files changed, 72 insertions, 69 deletions
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp index b13cc8f03..5c4544392 100644 --- a/host/lib/usrp/cores/rx_dsp_core_200.cpp +++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp @@ -109,10 +109,10 @@ public: void set_mux(const std::string &mode){ static const uhd::dict<std::string, boost::uint32_t> mode_to_mux = boost::assign::map_list_of - ("iq", 0) - ("qi", FLAG_DSP_RX_MUX_SWAP_IQ) - ("i", FLAG_DSP_RX_MUX_REAL_MODE) - ("q", FLAG_DSP_RX_MUX_SWAP_IQ | FLAG_DSP_RX_MUX_REAL_MODE) + ("IQ", 0) + ("QI", FLAG_DSP_RX_MUX_SWAP_IQ) + ("I", FLAG_DSP_RX_MUX_REAL_MODE) + ("Q", FLAG_DSP_RX_MUX_SWAP_IQ | FLAG_DSP_RX_MUX_REAL_MODE) ; _iface->poke32(REG_DSP_RX_MUX, mode_to_mux[mode]); } diff --git a/host/lib/usrp/cores/tx_frontend_core_200.cpp b/host/lib/usrp/cores/tx_frontend_core_200.cpp index 682e6613d..c568133fd 100644 --- a/host/lib/usrp/cores/tx_frontend_core_200.cpp +++ b/host/lib/usrp/cores/tx_frontend_core_200.cpp @@ -42,10 +42,10 @@ public: void set_mux(const std::string &mode){ static const uhd::dict<std::string, boost::uint32_t> mode_to_mux = boost::assign::map_list_of - ("iq", (0x1 << 4) | (0x0 << 0)) //DAC0Q=DUC0Q, DAC0I=DUC0I - ("qi", (0x0 << 4) | (0x1 << 0)) //DAC0Q=DUC0I, DAC0I=DUC0Q - ("i", (0xf << 4) | (0x0 << 0)) //DAC0Q=ZERO, DAC0I=DUC0I - ("q", (0x0 << 4) | (0xf << 0)) //DAC0Q=DUC0I, DAC0I=ZERO + ("IQ", (0x1 << 4) | (0x0 << 0)) //DAC0Q=DUC0Q, DAC0I=DUC0I + ("QI", (0x0 << 4) | (0x1 << 0)) //DAC0Q=DUC0I, DAC0I=DUC0Q + ("I", (0xf << 4) | (0x0 << 0)) //DAC0Q=ZERO, DAC0I=DUC0I + ("Q", (0x0 << 4) | (0xf << 0)) //DAC0Q=DUC0I, DAC0I=ZERO ; _iface->poke32(REG_TX_FE_MUX, mode_to_mux[mode]); } diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index bff55009e..b1c10e1c1 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -444,10 +444,10 @@ static std::vector<std::string> get_ants(wax::obj subdev){ static std::string get_conn(wax::obj subdev){ switch(subdev[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()){ - case SUBDEV_CONN_COMPLEX_IQ: return "iq"; - case SUBDEV_CONN_COMPLEX_QI: return "qi"; - case SUBDEV_CONN_REAL_I: return "i"; - case SUBDEV_CONN_REAL_Q: return "q"; + case SUBDEV_CONN_COMPLEX_IQ: return "IQ"; + case SUBDEV_CONN_COMPLEX_QI: return "QI"; + case SUBDEV_CONN_REAL_I: return "I"; + case SUBDEV_CONN_REAL_Q: return "Q"; } UHD_THROW_INVALID_CODE_PATH(); } @@ -480,6 +480,7 @@ void dboard_manager::populate_prop_tree_from_subdev( } const prop_names_t gain_names = subdev[SUBDEV_PROP_GAIN_NAMES].as<prop_names_t>(); + tree->create<int>(root / "gains"); //phony property so this dir exists BOOST_FOREACH(const std::string &name, gain_names){ tree->create<double>(root / "gains" / name / "value") .subscribe_master(boost::bind(&get_set_gain, subdev, name, _1)); diff --git a/host/lib/usrp2/usrp2_impl.cpp b/host/lib/usrp2/usrp2_impl.cpp index 7dc9ac812..829becd19 100644 --- a/host/lib/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp2/usrp2_impl.cpp @@ -293,6 +293,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ // create controller objects and initialize the properties tree //////////////////////////////////////////////////////////////////// _tree = property_tree::make(); + _tree->create<std::string>("/name").set("USRP2 / N-Series Device"); for (size_t mbi = 0; mbi < device_args.size(); mbi++){ const device_addr_t device_args_i = device_args[mbi]; @@ -349,6 +350,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ //////////////////////////////////////////////////////////////// property_tree::path_type rx_codec_path = mb_path / "rx_codecs/A"; property_tree::path_type tx_codec_path = mb_path / "tx_codecs/A"; + _tree->create<int>(rx_codec_path / "gains"); //phony property so this dir exists + _tree->create<int>(tx_codec_path / "gains"); //phony property so this dir exists _mbc[mb].codec = usrp2_codec_ctrl::make(_mbc[mb].iface); switch(_mbc[mb].iface->get_rev()){ case usrp2_iface::USRP_N200: @@ -503,10 +506,13 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ //create the properties and register subscribers _tree->create<dboard_eeprom_t>(mb_path / "dboards/A/rx_eeprom") + .set(rx_db_eeprom) .subscribe(boost::bind(&usrp2_impl::set_db_eeprom, this, mb, "rx", _1)); _tree->create<dboard_eeprom_t>(mb_path / "dboards/A/tx_eeprom") + .set(tx_db_eeprom) .subscribe(boost::bind(&usrp2_impl::set_db_eeprom, this, mb, "tx", _1)); _tree->create<dboard_eeprom_t>(mb_path / "dboards/A/gdb_eeprom") + .set(gdb_eeprom) .subscribe(boost::bind(&usrp2_impl::set_db_eeprom, this, mb, "gdb", _1)); //create a new dboard interface and manager diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp index 441f657d0..0605aa621 100644 --- a/host/utils/uhd_usrp_probe.cpp +++ b/host/utils/uhd_usrp_probe.cpp @@ -18,13 +18,8 @@ #include <uhd/utils/safe_main.hpp> #include <uhd/device.hpp> #include <uhd/types/ranges.hpp> +#include <uhd/property_tree.hpp> #include <boost/algorithm/string.hpp> //for split -#include <uhd/usrp/device_props.hpp> -#include <uhd/usrp/mboard_props.hpp> -#include <uhd/usrp/dboard_props.hpp> -#include <uhd/usrp/codec_props.hpp> -#include <uhd/usrp/dsp_props.hpp> -#include <uhd/usrp/subdev_props.hpp> #include <uhd/usrp/dboard_id.hpp> #include <uhd/usrp/mboard_eeprom.hpp> #include <uhd/usrp/dboard_eeprom.hpp> @@ -56,17 +51,15 @@ static std::string make_border(const std::string &text){ return ss.str(); } -static std::string get_dsp_pp_string(const std::string &type, wax::obj dsp){ +static std::string get_dsp_pp_string(const std::string &type, property_tree::sptr tree, const property_tree::path_type &path){ std::stringstream ss; - ss << boost::format("%s DSP: %s") % type % dsp[usrp::DSP_PROP_NAME].as<std::string>() << std::endl; + ss << boost::format("%s DSP: %s") % type % path.leaf() << std::endl; //ss << std::endl; - ss << boost::format("Codec Rate: %f Msps") % (dsp[usrp::DSP_PROP_CODEC_RATE].as<double>()/1e6) << std::endl; - //ss << boost::format("Host Rate: %f Msps") % (dsp[usrp::DSP_PROP_HOST_RATE].as<double>()/1e6) << std::endl; - //ss << boost::format("Freq Shift: %f Mhz") % (dsp[usrp::DSP_PROP_FREQ_SHIFT].as<double>()/1e6) << std::endl; + ss << boost::format("DSP Rate: %f Msps") % (tree->access<double>(path.branch_path().branch_path() / "tick_rate").get()/1e6) << std::endl; return ss.str(); } -static std::string prop_names_to_pp_string(const prop_names_t &prop_names){ +static std::string prop_names_to_pp_string(const std::vector<std::string> &prop_names){ std::stringstream ss; size_t count = 0; BOOST_FOREACH(const std::string &prop_name, prop_names){ ss << ((count++)? ", " : "") << prop_name; @@ -74,98 +67,99 @@ static std::string prop_names_to_pp_string(const prop_names_t &prop_names){ return ss.str(); } -static std::string get_subdev_pp_string(const std::string &type, wax::obj subdev){ +static std::string get_subdev_pp_string(const std::string &type, property_tree::sptr tree, const property_tree::path_type &path){ std::stringstream ss; - ss << boost::format("%s Subdev: %s") % type % subdev[usrp::SUBDEV_PROP_NAME].as<std::string>() << std::endl; + ss << boost::format("%s Subdev: %s") % type % path.leaf() << std::endl; //ss << std::endl; - prop_names_t ant_names(subdev[usrp::SUBDEV_PROP_ANTENNA_NAMES].as<prop_names_t>()); - ss << boost::format("Antennas: %s") % prop_names_to_pp_string(ant_names) << std::endl; + ss << boost::format("Name: %s") % (tree->access<std::string>(path / "name").get()) << std::endl; + ss << boost::format("Antennas: %s") % prop_names_to_pp_string(tree->access<std::vector<std::string> >(path / "antenna/options").get()) << std::endl; - freq_range_t freq_range(subdev[usrp::SUBDEV_PROP_FREQ_RANGE].as<freq_range_t>()); + meta_range_t freq_range = tree->access<meta_range_t>(path / "freq/range").get(); ss << boost::format("Freq range: %.3f to %.3f Mhz") % (freq_range.start()/1e6) % (freq_range.stop()/1e6) << std::endl; - prop_names_t gain_names(subdev[usrp::SUBDEV_PROP_GAIN_NAMES].as<prop_names_t>()); + std::vector<std::string> gain_names = tree->list(path / "gains"); if (gain_names.size() == 0) ss << "Gain Elements: None" << std::endl; - BOOST_FOREACH(const std::string &gain_name, gain_names){ - gain_range_t gain_range(subdev[named_prop_t(usrp::SUBDEV_PROP_GAIN_RANGE, gain_name)].as<gain_range_t>()); - ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % gain_name % gain_range.start() % gain_range.stop() % gain_range.step() << std::endl; + BOOST_FOREACH(const std::string &name, gain_names){ + meta_range_t gain_range = tree->access<meta_range_t>(path / "gains" / name / "range").get(); + ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % name % gain_range.start() % gain_range.stop() % gain_range.step() << std::endl; } - ss << boost::format("Connection Type: %c") % char(subdev[usrp::SUBDEV_PROP_CONNECTION].as<usrp::subdev_conn_t>()) << std::endl; - ss << boost::format("Uses LO offset: %s") % (subdev[usrp::SUBDEV_PROP_USE_LO_OFFSET].as<bool>()? "Yes" : "No") << std::endl; + ss << boost::format("Connection Type: %s") % (tree->access<std::string>(path / "connection").get()) << std::endl; + ss << boost::format("Uses LO offset: %s") % ((tree->access<bool>(path / "use_lo_offset").get())? "Yes" : "No") << std::endl; return ss.str(); } -static std::string get_codec_pp_string(const std::string &type, wax::obj codec){ +static std::string get_codec_pp_string(const std::string &type, property_tree::sptr tree, const property_tree::path_type &path){ std::stringstream ss; - ss << boost::format("%s Codec: %s") % type % codec[usrp::CODEC_PROP_NAME].as<std::string>() << std::endl; + ss << boost::format("%s Codec: %s") % type % path.leaf() << std::endl; //ss << std::endl; - prop_names_t gain_names(codec[usrp::CODEC_PROP_GAIN_NAMES].as<prop_names_t>()); + + ss << boost::format("Name: %s") % (tree->access<std::string>(path / "name").get()) << std::endl; + std::vector<std::string> gain_names = tree->list(path / "gains"); if (gain_names.size() == 0) ss << "Gain Elements: None" << std::endl; - BOOST_FOREACH(const std::string &gain_name, gain_names){ - gain_range_t gain_range(codec[named_prop_t(usrp::CODEC_PROP_GAIN_RANGE, gain_name)].as<gain_range_t>()); - ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % gain_name % gain_range.start() % gain_range.stop() % gain_range.step() << std::endl; + BOOST_FOREACH(const std::string &name, gain_names){ + meta_range_t gain_range = tree->access<meta_range_t>(path / "gains" / name / "range").get(); + ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % name % gain_range.start() % gain_range.stop() % gain_range.step() << std::endl; } return ss.str(); } -static std::string get_dboard_pp_string(const std::string &type, wax::obj dboard){ +static std::string get_dboard_pp_string(const std::string &type, property_tree::sptr tree, const property_tree::path_type &path){ std::stringstream ss; - ss << boost::format("%s Dboard: %s") % type % dboard[usrp::DBOARD_PROP_NAME].as<std::string>() << std::endl; + ss << boost::format("%s Dboard: %s") % type % path.leaf() << std::endl; //ss << std::endl; - usrp::dboard_eeprom_t db_eeprom = dboard[usrp::DBOARD_PROP_DBOARD_EEPROM].as<usrp::dboard_eeprom_t>(); + const std::string prefix = (type == "RX")? "rx" : "tx"; + usrp::dboard_eeprom_t db_eeprom = tree->access<usrp::dboard_eeprom_t>(path / (prefix + "_eeprom")).get(); if (db_eeprom.id != usrp::dboard_id_t::none()) ss << boost::format("ID: %s") % db_eeprom.id.to_pp_string() << std::endl; if (not db_eeprom.serial.empty()) ss << boost::format("Serial: %s") % db_eeprom.serial << std::endl; if (type == "TX"){ - usrp::dboard_eeprom_t gdb_eeprom = dboard[usrp::DBOARD_PROP_GBOARD_EEPROM].as<usrp::dboard_eeprom_t>(); - if (gdb_eeprom.id != usrp::dboard_id_t::none()) ss << boost::format("GDB ID: %s") % gdb_eeprom.id.to_pp_string() << std::endl; - if (not gdb_eeprom.serial.empty()) ss << boost::format("GDB Serial: %s") % gdb_eeprom.serial << std::endl; + usrp::dboard_eeprom_t gdb_eeprom = tree->access<usrp::dboard_eeprom_t>(path / "gdb_eeprom").get(); + if (gdb_eeprom.id != usrp::dboard_id_t::none()) ss << boost::format("ID: %s") % gdb_eeprom.id.to_pp_string() << std::endl; + if (not gdb_eeprom.serial.empty()) ss << boost::format("Serial: %s") % gdb_eeprom.serial << std::endl; } - BOOST_FOREACH(const std::string &subdev_name, dboard[usrp::DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>()){ - ss << make_border(get_subdev_pp_string(type, dboard[named_prop_t(usrp::DBOARD_PROP_SUBDEV, subdev_name)])); + BOOST_FOREACH(const std::string &name, tree->list(path / (prefix + "_frontends"))){ + ss << make_border(get_subdev_pp_string(type, tree, path / (prefix + "_frontends") / name)); } - ss << make_border(get_codec_pp_string(type, dboard[usrp::DBOARD_PROP_CODEC])); + ss << make_border(get_codec_pp_string(type, tree, path.branch_path().branch_path() / (prefix + "_codecs") / path.leaf())); return ss.str(); } -static std::string get_mboard_pp_string(wax::obj mboard){ +static std::string get_mboard_pp_string(property_tree::sptr tree, const property_tree::path_type &path){ std::stringstream ss; - ss << boost::format("Mboard: %s") % mboard[usrp::MBOARD_PROP_NAME].as<std::string>() << std::endl; + ss << boost::format("Mboard: %s") % (tree->access<std::string>(path / "name").get()) << std::endl; //ss << std::endl; - usrp::mboard_eeprom_t mb_eeprom = mboard[usrp::MBOARD_PROP_EEPROM_MAP].as<usrp::mboard_eeprom_t>(); + usrp::mboard_eeprom_t mb_eeprom = tree->access<usrp::mboard_eeprom_t>(path / "eeprom").get(); BOOST_FOREACH(const std::string &key, mb_eeprom.keys()){ if (not mb_eeprom[key].empty()) ss << boost::format("%s: %s") % key % mb_eeprom[key] << std::endl; } - BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_RX_DSP_NAMES].as<prop_names_t>()){ - ss << make_border(get_dsp_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DSP, dsp_name)])); + BOOST_FOREACH(const std::string &name, tree->list(path / "rx_dsps")){ + ss << make_border(get_dsp_pp_string("RX", tree, path / "rx_dsps" / name)); } - BOOST_FOREACH(const std::string &db_name, mboard[usrp::MBOARD_PROP_RX_DBOARD_NAMES].as<prop_names_t>()){ - ss << make_border(get_dboard_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DBOARD, db_name)])); + BOOST_FOREACH(const std::string &name, tree->list(path / "dboards")){ + ss << make_border(get_dboard_pp_string("RX", tree, path / "dboards" / name)); } - BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_TX_DSP_NAMES].as<prop_names_t>()){ - ss << make_border(get_dsp_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DSP, dsp_name)])); + BOOST_FOREACH(const std::string &name, tree->list(path / "tx_dsps")){ + ss << make_border(get_dsp_pp_string("TX", tree, path / "tx_dsps" / name)); } - BOOST_FOREACH(const std::string &db_name, mboard[usrp::MBOARD_PROP_TX_DBOARD_NAMES].as<prop_names_t>()){ - ss << make_border(get_dboard_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DBOARD, db_name)])); + BOOST_FOREACH(const std::string &name, tree->list(path / "dboards")){ + ss << make_border(get_dboard_pp_string("TX", tree, path / "dboards" / name)); } return ss.str(); } -static std::string get_device_pp_string(device::sptr dev){ +static std::string get_device_pp_string(property_tree::sptr tree){ std::stringstream ss; - ss << boost::format("Device: %s") % (*dev)[usrp::DEVICE_PROP_NAME].as<std::string>() << std::endl; + ss << boost::format("Device: %s") % (tree->access<std::string>("/name").get()) << std::endl; //ss << std::endl; - BOOST_FOREACH(const std::string &mboard_name, (*dev)[usrp::DEVICE_PROP_MBOARD_NAMES].as<prop_names_t>()){ - ss << make_border(get_mboard_pp_string((*dev)[named_prop_t(usrp::DEVICE_PROP_MBOARD, mboard_name)])); + BOOST_FOREACH(const std::string &name, tree->list("/mboards")){ + ss << make_border(get_mboard_pp_string(tree, "/mboards/" + name)); } return ss.str(); } -#include <uhd/property_tree.hpp> - void print_tree(const uhd::property_tree::path_type &path, uhd::property_tree::sptr tree){ std::cout << path << std::endl; BOOST_FOREACH(const std::string &name, tree->list(path)){ @@ -178,6 +172,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value<std::string>()->default_value(""), "device address args") + ("tree", "specify to print a complete property tree") ; po::variables_map vm; @@ -191,9 +186,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } device::sptr dev = device::make(vm["args"].as<std::string>()); + property_tree::sptr tree = (*dev)[0].as<property_tree::sptr>(); - //std::cout << make_border(get_device_pp_string(dev)) << std::endl; - print_tree("/", (*dev)[0].as<uhd::property_tree::sptr>()); + if (vm.count("tree") != 0) print_tree("/", tree); + else std::cout << make_border(get_device_pp_string(tree)) << std::endl; return 0; } |