diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-21 15:30:34 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-21 15:30:34 -0800 |
commit | e3483c7451d20b7ed1d8d4865e15751f18cdef78 (patch) | |
tree | f309a95a1b0ecd3dc3295ebc71ee5ad697c9f7a8 /lib/usrp/usrp.cpp | |
parent | 5b42b774d9ac1e74fb2916bf58085fe19ecb6720 (diff) | |
download | uhd-e3483c7451d20b7ed1d8d4865e15751f18cdef78.tar.gz uhd-e3483c7451d20b7ed1d8d4865e15751f18cdef78.tar.bz2 uhd-e3483c7451d20b7ed1d8d4865e15751f18cdef78.zip |
Added a usrp device abstration that creates usrp mboards.
Added a usrp mboard named test, its empty for now.
Diffstat (limited to 'lib/usrp/usrp.cpp')
-rw-r--r-- | lib/usrp/usrp.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/usrp/usrp.cpp b/lib/usrp/usrp.cpp new file mode 100644 index 000000000..af0e66e9f --- /dev/null +++ b/lib/usrp/usrp.cpp @@ -0,0 +1,58 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#include <usrp_uhd/usrp/usrp.hpp> +#include <usrp_uhd/usrp/mboard/test.hpp> +#include <stdexcept> + +using namespace usrp_uhd::usrp; + +usrp::usrp(const device_addr_t & device_addr){ + if (device_addr.type == DEVICE_ADDR_TYPE_VIRTUAL){ + _mboards.push_back( + mboard::base::sptr(new mboard::test(device_addr)) + ); + } +} + +usrp::~usrp(void){ + /* NOP */ +} + +void usrp::get(const wax::type &key_, wax::type &val){ + //extract the index if key is an indexed prop + wax::type key = key_; size_t index = 0; + if (key.type() == typeid(indexed_prop_t)){ + boost::tie(key, index) = wax::cast<indexed_prop_t>(key); + } + + //handle the get request conditioned on the key + switch(wax::cast<device_prop_t>(key)){ + case DEVICE_PROP_NAME: + val = std::string("usrp device"); + return; + + case DEVICE_PROP_MBOARD: + //turn the mboard sptr object into a wax::obj::sptr + //this allows the properties access through the wax::proxy + val = wax::obj::cast(_mboards.at(index)); + return; + + case DEVICE_PROP_NUM_MBOARDS: + val = size_t(_mboards.size()); + return; + } +} + +void usrp::set(const wax::type &, const wax::type &){ + throw std::runtime_error("Cannot set in usrp device"); +} + +void usrp::send_raw(const send_args_t &){ + //TODO make the call on the mboard +} + +void usrp::recv_raw(const recv_args_t &){ + //TODO make the call on the mboard +} |