Пример #1
0
uint32_t _extract_port_number(
    std::string radio_src_string, uhd::property_tree::sptr ptree)
{
    std::string s_val = "0";
    std::vector<std::string> radio_strings;
    boost::algorithm::split(radio_strings,
        radio_src_string,
        boost::is_any_of("_/"),
        boost::token_compress_on);
    boost::to_lower(radio_strings[0]);
    if (radio_strings.size() < 3) {
        throw uhd::runtime_error(str(
            boost::format("%s is an invalid GPIO source string.") % radio_src_string));
    }
    size_t radio_num = std::stoi(radio_strings[1]);
    size_t port_num  = std::stoi(radio_strings[2]);
    if (radio_strings[0] != "radio") {
        throw uhd::runtime_error(
            "Front panel GPIO bank can only accept a radio block as its driver.");
    }
    std::string radio_port_out  = "Radio_" + radio_strings[1] + "/ports/out";
    std::string radio_port_path = radio_port_out + "/" + radio_strings[2];
    auto found                  = ptree->exists(fs_path("xbar") / radio_port_path);
    if (not found) {
        throw uhd::runtime_error(
            str(boost::format("Could not find radio port %s.\n") % radio_port_path));
    }
    size_t port_size = ptree->list(fs_path("xbar") / radio_port_out).size();
    return radio_num * port_size + port_num;
}
Пример #2
0
void print_tree(const uhd::fs_path &path, uhd::property_tree::sptr tree){
    std::cout << path << std::endl;
    for(const std::string &name:  tree->list(path)){
        print_tree(path / name, tree);
    }
}