Example #1
0
static std::string get_frontend_pp_string(const std::string &type, property_tree::sptr tree, const fs_path &path){
    std::stringstream ss;
    ss << boost::format("%s Frontend: %s") % type % path.leaf() << std::endl;
    //ss << 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;
    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;
    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;
    }
    if (tree->exists(path / "bandwidth" / "range"))
    {
        meta_range_t bw_range = tree->access<meta_range_t>(path / "bandwidth" / "range").get();
        ss << boost::format("Bandwidth range: %.1f to %.1f step %.1f Hz") % bw_range.start() % bw_range.stop() % bw_range.step() << 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->exists(path / "use_lo_offset") and tree->access<bool>(path / "use_lo_offset").get())? "Yes" : "No")
       << std::endl;

    return ss.str();
}
Example #2
0
void shd::smini::validate_subdev_spec(
    property_tree::sptr tree,
    const subdev_spec_t &spec,
    const std::string &type,
    const std::string &mb
){
    const size_t num_dsps = tree->list(str(boost::format("/mboards/%s/%s_dsps") % mb % type)).size();

    //sanity checking on the length
    if (spec.size() == 0) throw shd::value_error(str(boost::format(
        "Empty %s subdevice specification is not supported.\n"
    ) % type));
    if (spec.size() > num_dsps) throw shd::value_error(str(boost::format(
        "The subdevice specification \"%s\" is too long.\n"
        "The user specified %u channels, but there are only %u %s dsps on mboard %s.\n"
    ) % spec.to_string() % spec.size() % num_dsps % type % mb));

    //make a list of all possible specs
    subdev_spec_t all_specs;
    BOOST_FOREACH(const std::string &db, tree->list(str(boost::format("/mboards/%s/dboards") % mb))){
        BOOST_FOREACH(const std::string &sd, tree->list(str(boost::format("/mboards/%s/dboards/%s/%s_frontends") % mb % db % type))){
            all_specs.push_back(subdev_spec_pair_t(db, sd));
        }
    }

    //validate that the spec is possible
    BOOST_FOREACH(const subdev_spec_pair_t &pair, spec){
        shd::assert_has(all_specs, pair, str(boost::format("%s subdevice specification on mboard %s") % type % mb));
    }
Example #3
0
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;
    for(const std::string &name:  tree->list(path)){
        ss << "* " << name << std::endl;
    }
    return ss.str();
}
Example #4
0
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;
    for(const std::string &name:  tree->list("/mboards")){
        ss << make_border(get_mboard_pp_string(tree, "/mboards/" + name));
    }
    return ss.str();
}
Example #5
0
static std::string get_codec_pp_string(const std::string &type, property_tree::sptr tree, const fs_path &path){
    std::stringstream ss;
    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();
}
Example #6
0
static std::string get_dboard_pp_string(const std::string &type, property_tree::sptr tree, const fs_path &path){
    std::stringstream ss;
    ss << boost::format("%s Dboard: %s") % type % path.leaf() << std::endl;
    //ss << std::endl;
    const std::string prefix = (type == "RX")? "rx" : "tx";
    if (tree->exists(path / (prefix + "_eeprom")))
    {
        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 = 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;
        }
    }
    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();
}
Example #7
0
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;

    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;
    }
    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;
    }
    ss << std::endl;
    try {
        if (tree->exists(path / "time_source" / "options")){
            const std::vector< std::string > time_sources  = tree->access<std::vector<std::string> >(path / "time_source" / "options").get();
            ss << "Time sources:  " << prop_names_to_pp_string(time_sources)  << std::endl;
        }
        if (tree->exists(path / "clock_source" / "options")){
            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;
        }
        if (tree->exists(path / "sensors")){
            ss << "Sensors: " << prop_names_to_pp_string(tree->list(path / "sensors")) << std::endl;
        }
        if (tree->exists(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));
            }
        }
        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));
            }
        }
        if (tree->exists(path / "xbar")){
            ss << make_border(get_rfnoc_pp_string(tree, path / "xbar"));
        }
    }
    catch (const uhd::lookup_error& ex) {
        std::cout << "Exited device probe on " << ex.what() << std::endl;
    }
    return ss.str();
}