Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard_base.cpp @ 81b4689c

History | View | Annotate | Download (3.44 KB)

1 8fdffd2f Josh Blum
//
2 95b966a5 Josh Blum
// Copyright 2010-2011 Ettus Research LLC
3 8fdffd2f Josh Blum
//
4 aa2c904d Josh Blum
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17 8fdffd2f Josh Blum
18 fd0d9b7d Josh Blum
#include "dboard_ctor_args.hpp"
19 add5d32f Josh Blum
#include <uhd/usrp/dboard_base.hpp>
20 6fdaccea Josh Blum
#include <boost/format.hpp>
21 cc8caeb1 Josh Blum
#include <stdexcept>
22 8fdffd2f Josh Blum
23 d9035414 Josh Blum
using namespace uhd;
24 add5d32f Josh Blum
using namespace uhd::usrp;
25 8fdffd2f Josh Blum
26
/***********************************************************************
27 add5d32f Josh Blum
 * dboard_base dboard dboard_base class
28 8fdffd2f Josh Blum
 **********************************************************************/
29 b2054a45 Josh Blum
struct dboard_base::impl{
30 f1fe66ac Josh Blum
    dboard_ctor_args_t args;
31 4a19b431 Josh Blum
};
32
33 fd0d9b7d Josh Blum
dboard_base::dboard_base(ctor_args_t args){
34 f1fe66ac Josh Blum
    _impl = UHD_PIMPL_MAKE(impl, ());
35
    _impl->args = *static_cast<dboard_ctor_args_t *>(args);
36 8fdffd2f Josh Blum
}
37
38 add5d32f Josh Blum
std::string dboard_base::get_subdev_name(void){
39 fd0d9b7d Josh Blum
    return _impl->args.sd_name;
40 8fdffd2f Josh Blum
}
41
42 e2a94193 Josh Blum
dboard_iface::sptr dboard_base::get_iface(void){
43 fd0d9b7d Josh Blum
    return _impl->args.db_iface;
44 8fdffd2f Josh Blum
}
45
46 add5d32f Josh Blum
dboard_id_t dboard_base::get_rx_id(void){
47 fd0d9b7d Josh Blum
    return _impl->args.rx_id;
48 6fdaccea Josh Blum
}
49
50 add5d32f Josh Blum
dboard_id_t dboard_base::get_tx_id(void){
51 fd0d9b7d Josh Blum
    return _impl->args.tx_id;
52 6fdaccea Josh Blum
}
53
54 d9035414 Josh Blum
property_tree::sptr dboard_base::get_rx_subtree(void){
55
    return _impl->args.rx_subtree;
56
}
57
58
property_tree::sptr dboard_base::get_tx_subtree(void){
59
    return _impl->args.tx_subtree;
60
}
61
62 8fdffd2f Josh Blum
/***********************************************************************
63 add5d32f Josh Blum
 * xcvr dboard dboard_base class
64 92c76e57 Josh Blum
 **********************************************************************/
65 fd0d9b7d Josh Blum
xcvr_dboard_base::xcvr_dboard_base(ctor_args_t args) : dboard_base(args){
66 4d5df237 Josh Blum
    if (get_rx_id() == dboard_id_t::none()){
67 4357f5d3 Josh Blum
        throw uhd::runtime_error(str(boost::format(
68 6fdaccea Josh Blum
            "cannot create xcvr board when the rx id is \"%s\""
69 4d5df237 Josh Blum
        ) % dboard_id_t::none().to_pp_string()));
70 6fdaccea Josh Blum
    }
71 4d5df237 Josh Blum
    if (get_tx_id() == dboard_id_t::none()){
72 4357f5d3 Josh Blum
        throw uhd::runtime_error(str(boost::format(
73 6fdaccea Josh Blum
            "cannot create xcvr board when the tx id is \"%s\""
74 4d5df237 Josh Blum
        ) % dboard_id_t::none().to_pp_string()));
75 6fdaccea Josh Blum
    }
76 92c76e57 Josh Blum
}
77
78
/***********************************************************************
79 add5d32f Josh Blum
 * rx dboard dboard_base class
80 8fdffd2f Josh Blum
 **********************************************************************/
81 fd0d9b7d Josh Blum
rx_dboard_base::rx_dboard_base(ctor_args_t args) : dboard_base(args){
82 4d5df237 Josh Blum
    if (get_tx_id() != dboard_id_t::none()){
83 4357f5d3 Josh Blum
        throw uhd::runtime_error(str(boost::format(
84 6fdaccea Josh Blum
            "cannot create rx board when the tx id is \"%s\""
85
            " -> expected a tx id of \"%s\""
86 4d5df237 Josh Blum
        ) % get_tx_id().to_pp_string() % dboard_id_t::none().to_pp_string()));
87 6fdaccea Josh Blum
    }
88 8fdffd2f Josh Blum
}
89
90
/***********************************************************************
91 add5d32f Josh Blum
 * tx dboard dboard_base class
92 8fdffd2f Josh Blum
 **********************************************************************/
93 fd0d9b7d Josh Blum
tx_dboard_base::tx_dboard_base(ctor_args_t args) : dboard_base(args){
94 4d5df237 Josh Blum
    if (get_rx_id() != dboard_id_t::none()){
95 4357f5d3 Josh Blum
        throw uhd::runtime_error(str(boost::format(
96 6fdaccea Josh Blum
            "cannot create tx board when the rx id is \"%s\""
97
            " -> expected a rx id of \"%s\""
98 4d5df237 Josh Blum
        ) % get_rx_id().to_pp_string() % dboard_id_t::none().to_pp_string()));
99 6fdaccea Josh Blum
    }
100 8fdffd2f Josh Blum
}