Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / dboard / db_unknown.cpp @ 98ba0cc0

History | View | Annotate | Download (6.51 KB)

1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// 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

    
18
#include <uhd/usrp/subdev_props.hpp>
19
#include <uhd/types/ranges.hpp>
20
#include <uhd/utils/assert.hpp>
21
#include <uhd/utils/static.hpp>
22
#include <uhd/usrp/dboard_base.hpp>
23
#include <uhd/usrp/dboard_manager.hpp>
24
#include <boost/assign/list_of.hpp>
25
#include <boost/format.hpp>
26

    
27
using namespace uhd;
28
using namespace uhd::usrp;
29
using namespace boost::assign;
30

    
31
/***********************************************************************
32
 * The unknown boards:
33
 *   Like a basic board, but with only one subdev.
34
 **********************************************************************/
35
class unknown_rx : public rx_dboard_base{
36
public:
37
    unknown_rx(ctor_args_t args);
38
    ~unknown_rx(void);
39

    
40
    void rx_get(const wax::obj &key, wax::obj &val);
41
    void rx_set(const wax::obj &key, const wax::obj &val);
42
};
43

    
44
class unknown_tx : public tx_dboard_base{
45
public:
46
    unknown_tx(ctor_args_t args);
47
    ~unknown_tx(void);
48

    
49
    void tx_get(const wax::obj &key, wax::obj &val);
50
    void tx_set(const wax::obj &key, const wax::obj &val);
51
};
52

    
53
/***********************************************************************
54
 * Register the unknown dboards
55
 **********************************************************************/
56
static dboard_base::sptr make_unknown_rx(dboard_base::ctor_args_t args){
57
    return dboard_base::sptr(new unknown_rx(args));
58
}
59

    
60
static dboard_base::sptr make_unknown_tx(dboard_base::ctor_args_t args){
61
    return dboard_base::sptr(new unknown_tx(args));
62
}
63

    
64
UHD_STATIC_BLOCK(reg_unknown_dboards){
65
    dboard_manager::register_dboard(0xfff0, &make_unknown_tx, "Unknown TX");
66
    dboard_manager::register_dboard(0xfff1, &make_unknown_rx, "Unknown RX");
67
}
68

    
69
/***********************************************************************
70
 * Unknown RX dboard
71
 **********************************************************************/
72
unknown_rx::unknown_rx(ctor_args_t args) : rx_dboard_base(args){
73
    /* NOP */
74
}
75

    
76
unknown_rx::~unknown_rx(void){
77
    /* NOP */
78
}
79

    
80
void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){
81
    named_prop_t key = named_prop_t::extract(key_);
82

    
83
    //handle the get request conditioned on the key
84
    switch(key.as<subdev_prop_t>()){
85
    case SUBDEV_PROP_NAME:
86
        val = "Unknown - " + get_rx_id().to_pp_string();
87
        return;
88

    
89
    case SUBDEV_PROP_OTHERS:
90
        val = prop_names_t(); //empty
91
        return;
92

    
93
    case SUBDEV_PROP_GAIN:
94
        val = float(0);
95
        return;
96

    
97
    case SUBDEV_PROP_GAIN_RANGE:
98
        val = gain_range_t(0, 0, 0);
99
        return;
100

    
101
    case SUBDEV_PROP_GAIN_NAMES:
102
        val = prop_names_t(); //empty
103
        return;
104

    
105
    case SUBDEV_PROP_FREQ:
106
        val = double(0);
107
        return;
108

    
109
    case SUBDEV_PROP_FREQ_RANGE:
110
        val = freq_range_t(0, 0);
111
        return;
112

    
113
    case SUBDEV_PROP_ANTENNA:
114
        val = std::string("");
115
        return;
116

    
117
    case SUBDEV_PROP_ANTENNA_NAMES:
118
        val = prop_names_t(1, ""); //vector of 1 empty string
119
        return;
120

    
121
    case SUBDEV_PROP_CONNECTION:
122
        val = SUBDEV_CONN_COMPLEX_IQ;
123
        return;
124

    
125
    case SUBDEV_PROP_USE_LO_OFFSET:
126
        val = false;
127
        return;
128

    
129
    case SUBDEV_PROP_LO_LOCKED:
130
        val = true; //there is no LO, so it must be true!
131
        return;
132

    
133
    default: UHD_THROW_PROP_GET_ERROR();
134
    }
135
}
136

    
137
void unknown_rx::rx_set(const wax::obj &key_, const wax::obj &val){
138
    named_prop_t key = named_prop_t::extract(key_);
139

    
140
    //handle the get request conditioned on the key
141
    switch(key.as<subdev_prop_t>()){
142

    
143
    case SUBDEV_PROP_GAIN:
144
        UHD_ASSERT_THROW(val.as<float>() == float(0));
145
        return;
146

    
147
    case SUBDEV_PROP_ANTENNA:
148
        UHD_ASSERT_THROW(val.as<std::string>() == std::string(""));
149
        return;
150

    
151
    case SUBDEV_PROP_FREQ:
152
        return; // it wont do you much good, but you can set it
153

    
154
    default: UHD_THROW_PROP_SET_ERROR();
155
    }
156
}
157

    
158
/***********************************************************************
159
 * Basic and LF TX dboard
160
 **********************************************************************/
161
unknown_tx::unknown_tx(ctor_args_t args) : tx_dboard_base(args){
162
    /* NOP */
163
}
164

    
165
unknown_tx::~unknown_tx(void){
166
    /* NOP */
167
}
168

    
169
void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){
170
    named_prop_t key = named_prop_t::extract(key_);
171

    
172
    //handle the get request conditioned on the key
173
    switch(key.as<subdev_prop_t>()){
174
    case SUBDEV_PROP_NAME:
175
        val = "Unknown - " + get_tx_id().to_pp_string();
176
        return;
177

    
178
    case SUBDEV_PROP_OTHERS:
179
        val = prop_names_t(); //empty
180
        return;
181

    
182
    case SUBDEV_PROP_GAIN:
183
        val = float(0);
184
        return;
185

    
186
    case SUBDEV_PROP_GAIN_RANGE:
187
        val = gain_range_t(0, 0, 0);
188
        return;
189

    
190
    case SUBDEV_PROP_GAIN_NAMES:
191
        val = prop_names_t(); //empty
192
        return;
193

    
194
    case SUBDEV_PROP_FREQ:
195
        val = double(0);
196
        return;
197

    
198
    case SUBDEV_PROP_FREQ_RANGE:
199
        val = freq_range_t(0, 0);
200
        return;
201

    
202
    case SUBDEV_PROP_ANTENNA:
203
        val = std::string("");
204
        return;
205

    
206
    case SUBDEV_PROP_ANTENNA_NAMES:
207
        val = prop_names_t(1, ""); //vector of 1 empty string
208
        return;
209

    
210
    case SUBDEV_PROP_CONNECTION:
211
        val = SUBDEV_CONN_COMPLEX_IQ;
212
        return;
213

    
214
    case SUBDEV_PROP_USE_LO_OFFSET:
215
        val = false;
216
        return;
217

    
218
    case SUBDEV_PROP_LO_LOCKED:
219
        val = true; //there is no LO, so it must be true!
220
        return;
221

    
222
    default: UHD_THROW_PROP_GET_ERROR();
223
    }
224
}
225

    
226
void unknown_tx::tx_set(const wax::obj &key_, const wax::obj &val){
227
    named_prop_t key = named_prop_t::extract(key_);
228

    
229
    //handle the get request conditioned on the key
230
    switch(key.as<subdev_prop_t>()){
231

    
232
    case SUBDEV_PROP_GAIN:
233
        UHD_ASSERT_THROW(val.as<float>() == float(0));
234
        return;
235

    
236
    case SUBDEV_PROP_ANTENNA:
237
        UHD_ASSERT_THROW(val.as<std::string>() == std::string(""));
238
        return;
239

    
240
    case SUBDEV_PROP_FREQ:
241
        return; // it wont do you much good, but you can set it
242

    
243
    default: UHD_THROW_PROP_SET_ERROR();
244
    }
245
}