示例#1
0
void dboard_manager_impl::init(
    dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id
){
    //find the dboard key matches for the dboard ids
    dboard_key_t rx_dboard_key, tx_dboard_key, xcvr_dboard_key;
    BOOST_FOREACH(const dboard_key_t &key, get_id_to_args_map().keys()){
        if (key.is_xcvr()){
            if (rx_dboard_id == key.rx_id() and tx_dboard_id == key.tx_id()) xcvr_dboard_key = key;
            if (rx_dboard_id == key.rx_id()) rx_dboard_key = key; //kept to handle warning
            if (tx_dboard_id == key.tx_id()) tx_dboard_key = key; //kept to handle warning
        }
        else{
            if (rx_dboard_id == key.xx_id()) rx_dboard_key = key;
            if (tx_dboard_id == key.xx_id()) tx_dboard_key = key;
        }
    }

    //warn for invalid dboard id xcvr combinations
    if (not xcvr_dboard_key.is_xcvr() and (rx_dboard_key.is_xcvr() or tx_dboard_key.is_xcvr())){
        UHD_MSG(warning) << boost::format(
            "Unknown transceiver board ID combination.\n"
            "Is your daughter-board mounted properly?\n"
            "RX dboard ID: %s\n"
            "TX dboard ID: %s\n"
        ) % rx_dboard_id.to_pp_string() % tx_dboard_id.to_pp_string();
    }

    //initialize the gpio pins before creating subdevs
    set_nice_dboard_if();

    //dboard constructor args
    dboard_ctor_args_t db_ctor_args;
    db_ctor_args.db_iface = _iface;

    //make xcvr subdevs
    if (xcvr_dboard_key.is_xcvr()){

        //extract data for the xcvr dboard key
        dboard_ctor_t dboard_ctor; std::string name; prop_names_t subdevs;
        boost::tie(dboard_ctor, name, subdevs) = get_id_to_args_map()[xcvr_dboard_key];

        //create the xcvr object for each subdevice
        BOOST_FOREACH(const std::string &subdev, subdevs){
            db_ctor_args.sd_name = subdev;
            db_ctor_args.rx_id = rx_dboard_id;
            db_ctor_args.tx_id = tx_dboard_id;
            dboard_base::sptr xcvr_dboard = dboard_ctor(&db_ctor_args);
            //create a rx proxy for this xcvr board
            _rx_dboards[subdev] = subdev_proxy::sptr(
                new subdev_proxy(xcvr_dboard, subdev_proxy::RX_TYPE)
            );
            //create a tx proxy for this xcvr board
            _tx_dboards[subdev] = subdev_proxy::sptr(
                new subdev_proxy(xcvr_dboard, subdev_proxy::TX_TYPE)
            );
        }
示例#2
0
void dboard_manager_impl::init(
    dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, property_tree::sptr subtree, bool defer_db_init
){
    //find the dboard key matches for the dboard ids
    dboard_key_t rx_dboard_key, tx_dboard_key, xcvr_dboard_key;
    for(const dboard_key_t &key:  get_id_to_args_map().keys()){
        if (key.is_xcvr()){
            if (rx_dboard_id == key.rx_id() and tx_dboard_id == key.tx_id()) xcvr_dboard_key = key;
            if (rx_dboard_id == key.rx_id()) rx_dboard_key = key; //kept to handle warning
            if (tx_dboard_id == key.tx_id()) tx_dboard_key = key; //kept to handle warning
        }
        else{
            if (rx_dboard_id == key.xx_id()) rx_dboard_key = key;
            if (tx_dboard_id == key.xx_id()) tx_dboard_key = key;
        }
    }

    //warn for invalid dboard id xcvr combinations
    if (not xcvr_dboard_key.is_xcvr() and (rx_dboard_key.is_xcvr() or tx_dboard_key.is_xcvr())){
        UHD_LOGGER_WARNING("DBMGR") << boost::format(
            "Unknown transceiver board ID combination.\n"
            "Is your daughter-board mounted properly?\n"
            "RX dboard ID: %s\n"
            "TX dboard ID: %s\n"
        ) % rx_dboard_id.to_pp_string() % tx_dboard_id.to_pp_string();
    }

    //initialize the gpio pins before creating subdevs
    set_nice_dboard_if();

    //conditionally register the dboard iface in the tree
    if (not (rx_dboard_key.is_restricted() or tx_dboard_key.is_restricted() or xcvr_dboard_key.is_restricted())) {
        subtree->create<dboard_iface::sptr>("iface").set(_iface);
    }

    //dboard constructor args
    dboard_ctor_args_t db_ctor_args;
    db_ctor_args.db_iface = _iface;

    //make xcvr subdevs
    if (xcvr_dboard_key.is_xcvr()){

        //extract data for the xcvr dboard key
        dboard_ctor_t subdev_ctor; std::string name; std::vector<std::string> subdevs; dboard_ctor_t container_ctor;
        boost::tie(subdev_ctor, name, subdevs, container_ctor) = get_id_to_args_map()[xcvr_dboard_key];

        //create the container class.
        //a container class exists per N subdevs registered in a register_dboard* call
        db_ctor_args.sd_name    = "common";
        db_ctor_args.rx_id      = rx_dboard_id;
        db_ctor_args.tx_id      = tx_dboard_id;
        db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
        db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
        if (container_ctor) {
            db_ctor_args.rx_container = container_ctor(&db_ctor_args);
        } else {
            db_ctor_args.rx_container = dboard_base::sptr();
        }
        db_ctor_args.tx_container = db_ctor_args.rx_container;  //Same TX and RX container

        //create the xcvr object for each subdevice
        for(const std::string &subdev:  subdevs){
            db_ctor_args.sd_name = subdev;
            db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
            db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
            dboard_base::sptr xcvr_dboard = subdev_ctor(&db_ctor_args);
            _rx_dboards[subdev] = xcvr_dboard;
            _tx_dboards[subdev] = xcvr_dboard;
            xcvr_dboard->initialize();
        }

        //initialize the container after all subdevs have been created
        if (container_ctor) {
            if (defer_db_init) {
                _rx_containers.push_back(db_ctor_args.rx_container);
            } else {
                db_ctor_args.rx_container->initialize();
            }
        }

        //Populate frontend names in-order.
        //We cannot use _xx_dboards.keys() here because of the ordering requirement
        _rx_frontends = subdevs;
        _tx_frontends = subdevs;
    }

    //make tx and rx subdevs (separate subdevs for rx and tx dboards)
    else
    {
        //force the rx key to the unknown board for bad combinations
        if (rx_dboard_key.is_xcvr() or rx_dboard_key.xx_id() == dboard_id_t::none()){
            rx_dboard_key = dboard_key_t(0xfff1);
        }

        //extract data for the rx dboard key
        dboard_ctor_t rx_dboard_ctor; std::string rx_name; std::vector<std::string> rx_subdevs; dboard_ctor_t rx_cont_ctor;
        boost::tie(rx_dboard_ctor, rx_name, rx_subdevs, rx_cont_ctor) = get_id_to_args_map()[rx_dboard_key];

        //create the container class.
        //a container class exists per N subdevs registered in a register_dboard* call
        db_ctor_args.sd_name    = "common";
        db_ctor_args.rx_id      = rx_dboard_id;
        db_ctor_args.tx_id      = dboard_id_t::none();
        db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
        db_ctor_args.tx_subtree = property_tree::sptr();
        if (rx_cont_ctor) {
            db_ctor_args.rx_container = rx_cont_ctor(&db_ctor_args);
        } else {
            db_ctor_args.rx_container = dboard_base::sptr();
        }

        //make the rx subdevs
        for(const std::string &subdev:  rx_subdevs){
            db_ctor_args.sd_name = subdev;
            db_ctor_args.rx_subtree = subtree->subtree("rx_frontends/" + db_ctor_args.sd_name);
            _rx_dboards[subdev] = rx_dboard_ctor(&db_ctor_args);
            _rx_dboards[subdev]->initialize();
        }

        //initialize the container after all subdevs have been created
        if (rx_cont_ctor) {
            if (defer_db_init) {
                _rx_containers.push_back(db_ctor_args.rx_container);
            } else {
                db_ctor_args.rx_container->initialize();
            }
        }

        //force the tx key to the unknown board for bad combinations
        if (tx_dboard_key.is_xcvr() or tx_dboard_key.xx_id() == dboard_id_t::none()){
            tx_dboard_key = dboard_key_t(0xfff0);
        }

        //extract data for the tx dboard key
        dboard_ctor_t tx_dboard_ctor; std::string tx_name; std::vector<std::string> tx_subdevs; dboard_ctor_t tx_cont_ctor;
        boost::tie(tx_dboard_ctor, tx_name, tx_subdevs, tx_cont_ctor) = get_id_to_args_map()[tx_dboard_key];

        //create the container class.
        //a container class exists per N subdevs registered in a register_dboard* call
        db_ctor_args.sd_name    = "common";
        db_ctor_args.rx_id      = dboard_id_t::none();
        db_ctor_args.tx_id      = tx_dboard_id;
        db_ctor_args.rx_subtree = property_tree::sptr();
        db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
        if (tx_cont_ctor) {
            db_ctor_args.tx_container = tx_cont_ctor(&db_ctor_args);
        } else {
            db_ctor_args.tx_container = dboard_base::sptr();
        }

        //make the tx subdevs
        for(const std::string &subdev:  tx_subdevs){
            db_ctor_args.sd_name = subdev;
            db_ctor_args.tx_subtree = subtree->subtree("tx_frontends/" + db_ctor_args.sd_name);
            _tx_dboards[subdev] = tx_dboard_ctor(&db_ctor_args);
            _tx_dboards[subdev]->initialize();
        }

        //initialize the container after all subdevs have been created
        if (tx_cont_ctor) {
            if (defer_db_init) {
                _tx_containers.push_back(db_ctor_args.tx_container);
            } else {
                db_ctor_args.tx_container->initialize();
            }
        }

        //Populate frontend names in-order.
        //We cannot use _xx_dboards.keys() here because of the ordering requirement
        _rx_frontends = rx_subdevs;
        _tx_frontends = tx_subdevs;
    }
}