diff options
Diffstat (limited to 'host/utils/uhd_usrp_probe.cpp')
-rw-r--r-- | host/utils/uhd_usrp_probe.cpp | 95 |
1 files changed, 57 insertions, 38 deletions
diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp index 5fc407bfa..fc66b7107 100644 --- a/host/utils/uhd_usrp_probe.cpp +++ b/host/utils/uhd_usrp_probe.cpp @@ -28,7 +28,6 @@ #include <uhd/types/sensors.hpp> #include <boost/program_options.hpp> #include <boost/format.hpp> -#include <boost/foreach.hpp> #include <iostream> #include <sstream> #include <vector> @@ -44,7 +43,7 @@ static std::string make_border(const std::string &text){ std::vector<std::string> lines; boost::split(lines, text, boost::is_any_of("\n")); while (lines.back().empty()) lines.pop_back(); //strip trailing newlines if (lines.size()) lines[0] = " " + lines[0]; //indent the title line - BOOST_FOREACH(const std::string &line, lines){ + for(const std::string &line: lines){ ss << boost::format("| %s") % line << std::endl; } //ss << boost::format(" \\_____________________________________________________") << std::endl; @@ -62,7 +61,7 @@ static std::string get_dsp_pp_string(const std::string &type, property_tree::spt 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){ + for(const std::string &prop_name: prop_names){ ss << ((count++)? ", " : "") << prop_name; } return ss.str(); @@ -75,14 +74,16 @@ static std::string get_frontend_pp_string(const std::string &type, property_tree 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; - ss << boost::format("Sensors: %s") % prop_names_to_pp_string(tree->list(path / "sensors")) << std::endl; + if (tree->exists(path/ "sensors")) { + ss << boost::format("Sensors: %s") % prop_names_to_pp_string(tree->list(path / "sensors")) << std::endl; + } 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; 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 &name, gain_names){ + for(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; } @@ -93,22 +94,25 @@ static std::string get_frontend_pp_string(const std::string &type, property_tree } 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; + ss << boost::format("Uses LO offset: %s") + % ((tree->exists(path / "use_lo_offset") and 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, property_tree::sptr tree, const fs_path &path){ std::stringstream ss; - ss << boost::format("%s Codec: %s") % type % path.leaf() << std::endl; - //ss << std::endl; - - 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 &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; + if (tree->exists(path / "name")) { + ss << boost::format("%s Codec: %s") % type % path.leaf() << std::endl; + + 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; + for(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(); } @@ -129,8 +133,10 @@ static std::string get_dboard_pp_string(const std::string &type, property_tree:: if (not gdb_eeprom.serial.empty()) ss << boost::format("Serial: %s") % gdb_eeprom.serial << std::endl; } } - BOOST_FOREACH(const std::string &name, tree->list(path / (prefix + "_frontends"))){ - ss << make_border(get_frontend_pp_string(type, tree, path / (prefix + "_frontends") / name)); + if (tree->exists(path / (prefix + "_frontends"))) { + for(const std::string &name: tree->list(path / (prefix + "_frontends"))){ + ss << make_border(get_frontend_pp_string(type, tree, path / (prefix + "_frontends") / name)); + } } ss << make_border(get_codec_pp_string(type, tree, path.branch_path().branch_path() / (prefix + "_codecs") / path.leaf())); return ss.str(); @@ -140,7 +146,7 @@ static std::string get_dboard_pp_string(const std::string &type, property_tree:: static std::string get_rfnoc_pp_string(property_tree::sptr tree, const fs_path &path){ std::stringstream ss; ss << "RFNoC blocks on this device:" << std::endl << std::endl; - BOOST_FOREACH(const std::string &name, tree->list(path)){ + for(const std::string &name: tree->list(path)){ ss << "* " << name << std::endl; } return ss.str(); @@ -149,10 +155,14 @@ static std::string get_rfnoc_pp_string(property_tree::sptr tree, const fs_path & static std::string get_mboard_pp_string(property_tree::sptr tree, const fs_path &path){ std::stringstream ss; ss << boost::format("Mboard: %s") % (tree->access<std::string>(path / "name").get()) << std::endl; - //ss << std::endl; - 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; + + if (tree->exists(path / "eeprom")){ + usrp::mboard_eeprom_t mb_eeprom = tree->access<usrp::mboard_eeprom_t>(path / "eeprom").get(); + for(const std::string &key: mb_eeprom.keys()){ + if (not mb_eeprom[key].empty()) ss << boost::format("%s: %s") % key % mb_eeprom[key] << std::endl; + } + } else { + ss << "No mboard EEPROM found." << std::endl; } if (tree->exists(path / "fw_version")){ ss << "FW Version: " << tree->access<std::string>(path / "fw_version").get() << std::endl; @@ -160,6 +170,9 @@ static std::string get_mboard_pp_string(property_tree::sptr tree, const fs_path if (tree->exists(path / "fpga_version")){ ss << "FPGA Version: " << tree->access<std::string>(path / "fpga_version").get() << std::endl; } + if (tree->exists(path / "fpga_version_hash")){ + ss << "FPGA git hash: " << tree->access<std::string>(path / "fpga_version_hash").get() << std::endl; + } if (tree->exists(path / "xbar")){ ss << "RFNoC capable: Yes" << std::endl; } @@ -173,27 +186,33 @@ static std::string get_mboard_pp_string(property_tree::sptr tree, const fs_path const std::vector< std::string > clock_sources = tree->access<std::vector<std::string> >(path / "clock_source" / "options").get(); ss << "Clock sources: " << prop_names_to_pp_string(clock_sources) << std::endl; } - ss << "Sensors: " << prop_names_to_pp_string(tree->list(path / "sensors")) << std::endl; + if (tree->exists(path / "sensors")){ + ss << "Sensors: " << prop_names_to_pp_string(tree->list(path / "sensors")) << std::endl; + } if (tree->exists(path / "rx_dsps")){ - BOOST_FOREACH(const std::string &name, tree->list(path / "rx_dsps")){ + for(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 &name, tree->list(path / "dboards")){ - ss << make_border(get_dboard_pp_string("RX", tree, path / "dboards" / name)); - } - if (tree->exists(path / "tx_dsps")){ - BOOST_FOREACH(const std::string &name, tree->list(path / "tx_dsps")){ - ss << make_border(get_dsp_pp_string("TX", tree, path / "tx_dsps" / name)); + if (tree->exists(path / "dboards")) { + for(const std::string &name: tree->list(path / "dboards")){ + ss << make_border(get_dboard_pp_string("RX", tree, path / "dboards" / name)); + } + if (tree->exists(path / "tx_dsps")){ + for(const std::string &name: tree->list(path / "tx_dsps")){ + ss << make_border(get_dsp_pp_string("TX", tree, path / "tx_dsps" / name)); + } + } + for(const std::string &name: tree->list(path / "dboards")){ + ss << make_border(get_dboard_pp_string("TX", tree, path / "dboards" / name)); } } - BOOST_FOREACH(const std::string &name, tree->list(path / "dboards")){ - ss << make_border(get_dboard_pp_string("TX", tree, path / "dboards" / name)); - } + if (tree->exists(path / "xbar")){ ss << make_border(get_rfnoc_pp_string(tree, path / "xbar")); + } } - catch (const uhd::lookup_error&) { - /* nop */ + catch (const uhd::lookup_error& ex) { + std::cout << "Exited device probe on " << ex.what() << std::endl; } return ss.str(); } @@ -203,7 +222,7 @@ static std::string get_device_pp_string(property_tree::sptr tree){ std::stringstream ss; ss << boost::format("Device: %s") % (tree->access<std::string>("/name").get()) << std::endl; //ss << std::endl; - BOOST_FOREACH(const std::string &name, tree->list("/mboards")){ + for(const std::string &name: tree->list("/mboards")){ ss << make_border(get_mboard_pp_string(tree, "/mboards/" + name)); } return ss.str(); @@ -211,7 +230,7 @@ static std::string get_device_pp_string(property_tree::sptr tree){ void print_tree(const uhd::fs_path &path, uhd::property_tree::sptr tree){ std::cout << path << std::endl; - BOOST_FOREACH(const std::string &name, tree->list(path)){ + for(const std::string &name: tree->list(path)){ print_tree(path / name, tree); } } @@ -254,7 +273,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if (vm.count("vector")) { std::vector<std::string> str_vector = tree->access< std::vector<std::string> >(vm["string"].as<std::string>()).get(); std::cout << "("; - BOOST_FOREACH(const std::string &str, str_vector) { + for(const std::string &str: str_vector) { std::cout << str << ","; } std::cout << ")" << std::endl; |