summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-21 22:15:30 -0800
committerJosh Blum <josh@joshknows.com>2010-02-21 22:15:30 -0800
commit3e5898fa11d9e77421cf0d3853acc49fbf4801ca (patch)
tree8f04464a8246bcfdb858a27c313adc614427c469
parentadd5d32f9b0cb3cda15624fb7aef3998096ff3f6 (diff)
downloaduhd-3e5898fa11d9e77421cf0d3853acc49fbf4801ca.tar.gz
uhd-3e5898fa11d9e77421cf0d3853acc49fbf4801ca.tar.bz2
uhd-3e5898fa11d9e77421cf0d3853acc49fbf4801ca.zip
Made the usrp2 impl into a device.
Removed the usrp device wrapper and usrp2 cpp file outside of the usrp2 lib dir. Also removed the mboard base files since we wont be needing them.
-rw-r--r--host/include/uhd/usrp/CMakeLists.txt2
-rw-r--r--host/include/uhd/usrp/mboard_base.hpp45
-rw-r--r--host/include/uhd/usrp/usrp.hpp53
-rw-r--r--host/include/uhd/usrp/usrp2.hpp21
-rw-r--r--host/lib/CMakeLists.txt3
-rw-r--r--host/lib/device.cpp16
-rw-r--r--host/lib/usrp/mboard_base.cpp29
-rw-r--r--host/lib/usrp/usrp.cpp94
-rw-r--r--host/lib/usrp/usrp2.cpp116
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp11
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp113
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp13
12 files changed, 148 insertions, 368 deletions
diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt
index 4b49e315f..e7bdc1784 100644
--- a/host/include/uhd/usrp/CMakeLists.txt
+++ b/host/include/uhd/usrp/CMakeLists.txt
@@ -21,8 +21,6 @@ INSTALL(FILES
dboard_id.hpp
dboard_interface.hpp
dboard_manager.hpp
- mboard_base.hpp
usrp2.hpp
- usrp.hpp
DESTINATION ${HEADER_DIR}/uhd/usrp
)
diff --git a/host/include/uhd/usrp/mboard_base.hpp b/host/include/uhd/usrp/mboard_base.hpp
deleted file mode 100644
index 498a46681..000000000
--- a/host/include/uhd/usrp/mboard_base.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#ifndef INCLUDED_UHD_USRP_MBOARD_BASE_HPP
-#define INCLUDED_UHD_USRP_MBOARD_BASE_HPP
-
-#include <uhd/wax.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace uhd{ namespace usrp{
-
-/*!
- * A mboard_base class for usrp mboard objects.
- */
-class mboard_base : boost::noncopyable, public wax::obj{
-public:
- typedef boost::shared_ptr<mboard_base> sptr;
- mboard_base(void);
- ~mboard_base(void);
-
- //TODO other api calls
-
-private:
- virtual void get(const wax::obj &, wax::obj &) = 0;
- virtual void set(const wax::obj &, const wax::obj &) = 0;
-};
-
-}} //namespace
-
-#endif /* INCLUDED_UHD_USRP_MBOARD_BASE_HPP */
diff --git a/host/include/uhd/usrp/usrp.hpp b/host/include/uhd/usrp/usrp.hpp
deleted file mode 100644
index cc5ed601e..000000000
--- a/host/include/uhd/usrp/usrp.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/device.hpp>
-#include <uhd/usrp/mboard_base.hpp>
-#include <uhd/dict.hpp>
-
-#ifndef INCLUDED_UHD_USRP_USRP_HPP
-#define INCLUDED_UHD_USRP_USRP_HPP
-
-namespace uhd{ namespace usrp{
-
-/*!
- * A usrp device provides a device-level interface to usrp mboards.
- * In most cases, a usrp device will have only one mboard.
- * In the usrp2 mimo case, this device will have two mboards,
- * where one talks through the other's control port.
- */
-class usrp : public device{
-public:
- usrp(const device_addr_t &device_addr);
- ~usrp(void);
-
- //the io interface
- void send_raw(const std::vector<boost::asio::const_buffer> &);
- uhd::shared_iovec recv_raw(void);
-
-private:
- void get(const wax::obj &, wax::obj &);
- void set(const wax::obj &, const wax::obj &);
-
- uhd::dict<std::string, mboard_base::sptr> _mboards;
- boost::function<void(const std::vector<boost::asio::const_buffer> &)> _send_raw_cb;
- boost::function<uhd::shared_iovec(void)> _recv_raw_cb;
-};
-
-}} //namespace
-
-#endif /* INCLUDED_UHD_USRP_USRP_HPP */
diff --git a/host/include/uhd/usrp/usrp2.hpp b/host/include/uhd/usrp/usrp2.hpp
index 68d4c513c..f6e49cbd6 100644
--- a/host/include/uhd/usrp/usrp2.hpp
+++ b/host/include/uhd/usrp/usrp2.hpp
@@ -18,15 +18,14 @@
#ifndef INCLUDED_UHD_USRP_MBOARD_USRP2_HPP
#define INCLUDED_UHD_USRP_MBOARD_USRP2_HPP
-#include <uhd/usrp/mboard_base.hpp>
-#include <uhd/device_addr.hpp>
+#include <uhd/device.hpp>
namespace uhd{ namespace usrp{
/*!
- * The usrp2 mboard class.
+ * The usrp2 device class.
*/
-class usrp2 : public mboard_base{
+class usrp2 : public device{
public:
/*!
* Discover usrp2 devices over the ethernet.
@@ -36,14 +35,12 @@ public:
*/
static device_addrs_t discover(const device_addr_t &hint);
- usrp2(const device_addr_t &);
- ~usrp2(void);
-
-private:
- void get(const wax::obj &, wax::obj &);
- void set(const wax::obj &, const wax::obj &);
-
- wax::obj _impl;
+ /*!
+ * Make a usrp2 from a device address.
+ * \param addr the device address
+ * \return a device sptr to a new usrp2
+ */
+ static device::sptr make(const device_addr_t &addr);
};
}} //namespace
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 5bafc206d..5cf334678 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -24,14 +24,11 @@ SET(libuhd_sources
uhd.cpp
wax.cpp
transport/udp.cpp
- usrp/usrp.cpp
usrp/dboard/basic.cpp
usrp/dboard_base.cpp
usrp/dboard_id.cpp
usrp/dboard_interface.cpp
usrp/dboard_manager.cpp
- usrp/mboard_base.cpp
- usrp/usrp2.cpp
usrp/usrp2/dboard_impl.cpp
usrp/usrp2/dboard_interface.cpp
usrp/usrp2/dsp_impl.cpp
diff --git a/host/lib/device.cpp b/host/lib/device.cpp
index be27ac1ae..e376a5c50 100644
--- a/host/lib/device.cpp
+++ b/host/lib/device.cpp
@@ -15,8 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include <uhd/usrp/usrp.hpp>
-#include <uhd/usrp/usrp2.hpp> //TODO remove and call discover from usrp
+#include <uhd/usrp/usrp2.hpp>
#include <uhd/device.hpp>
#include <boost/format.hpp>
#include <stdexcept>
@@ -26,12 +25,7 @@ using namespace uhd;
device_addrs_t device::discover(const device_addr_t &hint){
device_addrs_t device_addrs;
if (not hint.has_key("type")){
- //TODO nothing
- }
- else if (hint["type"] == "test"){
- //make a copy of the hint for testing
- device_addr_t test_device_addr = hint;
- device_addrs.push_back(test_device_addr);
+ //TODO call discover for others and append results
}
else if (hint["type"] == "udp"){
std::vector<device_addr_t> usrp2_addrs = usrp::usrp2::discover(hint);
@@ -58,9 +52,9 @@ device::sptr device::make(const device_addr_t &hint, size_t which){
}
//create the new device with the discovered address
- //TODO only a usrp device will be made (until others are supported)
- if (true){
- return sptr(new uhd::usrp::usrp(device_addrs.at(which)));
+ //TODO only a usrp2 device will be made (until others are supported)
+ if (hint.has_key("type") and hint["type"] == "udp"){
+ return usrp::usrp2::make(device_addrs.at(which));
}
throw std::runtime_error("cant make a device");
}
diff --git a/host/lib/usrp/mboard_base.cpp b/host/lib/usrp/mboard_base.cpp
deleted file mode 100644
index ccf50794a..000000000
--- a/host/lib/usrp/mboard_base.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/usrp/mboard_base.hpp>
-#include <stdexcept>
-
-using namespace uhd::usrp;
-
-mboard_base::mboard_base(void){
- /* NOP */
-}
-
-mboard_base::~mboard_base(void){
- /* NOP */
-}
diff --git a/host/lib/usrp/usrp.cpp b/host/lib/usrp/usrp.cpp
deleted file mode 100644
index d4bae1694..000000000
--- a/host/lib/usrp/usrp.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/usrp/usrp.hpp>
-#include <uhd/usrp/usrp2.hpp>
-#include <boost/format.hpp>
-#include <boost/bind.hpp>
-#include <stdexcept>
-
-using namespace uhd::usrp;
-
-/***********************************************************************
- * default callbacks for the send and recv
- * these should be replaced with callbacks from the mboard object
- **********************************************************************/
-static void send_raw_default(const std::vector<boost::asio::const_buffer> &){
- throw std::runtime_error("No callback registered for send raw");
-}
-
-static uhd::shared_iovec recv_raw_default(void){
- throw std::runtime_error("No callback registered for recv raw");
-}
-
-/***********************************************************************
- * the usrp device wrapper
- **********************************************************************/
-usrp::usrp(const device_addr_t &device_addr){
- //set the default callbacks, the code below should replace them
- _send_raw_cb = boost::bind(&send_raw_default, _1);
- _recv_raw_cb = boost::bind(&recv_raw_default);
-
- //create mboard based on the device addr
- if (not device_addr.has_key("type")){
- //TODO nothing
- }
- else if (device_addr["type"] == "udp"){
- _mboards[""] = mboard_base::sptr(new usrp2(device_addr));
- }
-}
-
-usrp::~usrp(void){
- /* NOP */
-}
-
-void usrp::get(const wax::obj &key_, wax::obj &val){
- wax::obj key; std::string name;
- boost::tie(key, name) = extract_named_prop(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:
- if (not _mboards.has_key(name)) throw std::invalid_argument(
- str(boost::format("Unknown mboard name %s") % name)
- );
- //turn the mboard sptr object into a wax::obj::sptr
- //this allows the properties access through the wax::proxy
- val = _mboards[name]->get_link();
- return;
-
- case DEVICE_PROP_MBOARD_NAMES:
- val = prop_names_t(_mboards.get_keys());
- return;
- }
-}
-
-void usrp::set(const wax::obj &, const wax::obj &){
- throw std::runtime_error("Cannot set in usrp device");
-}
-
-void usrp::send_raw(const std::vector<boost::asio::const_buffer> &buffs){
- return _send_raw_cb(buffs);
-}
-
-uhd::shared_iovec usrp::recv_raw(void){
- return _recv_raw_cb();
-}
diff --git a/host/lib/usrp/usrp2.cpp b/host/lib/usrp/usrp2.cpp
deleted file mode 100644
index 1ff363ae1..000000000
--- a/host/lib/usrp/usrp2.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/usrp/usrp2.hpp>
-#include <uhd/device.hpp>
-#include <uhd/transport/udp.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/format.hpp>
-#include <boost/thread.hpp>
-#include <netinet/in.h>
-#include "usrp2/usrp2_impl.hpp"
-
-using namespace uhd::usrp;
-
-/***********************************************************************
- * Discovery over the udp transport
- **********************************************************************/
-uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){
- device_addrs_t usrp2_addrs;
-
- //create a udp transport to communicate
- //TODO if an addr is not provided, search all interfaces?
- std::string ctrl_port = boost::lexical_cast<std::string>(USRP2_UDP_CTRL_PORT);
- uhd::transport::udp udp_transport(hint["addr"], ctrl_port, true);
-
- //send a hello control packet
- usrp2_ctrl_data_t ctrl_data_out;
- ctrl_data_out.id = htonl(USRP2_CTRL_ID_GIVE_ME_YOUR_IP_ADDR_BRO);
- udp_transport.send(boost::asio::buffer(&ctrl_data_out, sizeof(ctrl_data_out)));
-
- //loop and recieve until the time is up
- size_t num_timeouts = 0;
- while(true){
- uhd::shared_iovec iov = udp_transport.recv();
- //std::cout << boost::asio::buffer_size(buff) << "\n";
- if (iov.len < sizeof(usrp2_ctrl_data_t)){
- //sleep a little so we dont burn cpu
- if (num_timeouts++ > 50) break;
- boost::this_thread::sleep(boost::posix_time::milliseconds(1));
- }else{
- //handle the received data
- const usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<const usrp2_ctrl_data_t *>(iov.base);
- switch(ntohl(ctrl_data_in->id)){
- case USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE:
- //make a boost asio ipv4 with the raw addr in host byte order
- boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
- device_addr_t new_addr;
- new_addr["name"] = "USRP2";
- new_addr["type"] = "udp";
- new_addr["addr"] = ip_addr.to_string();
- usrp2_addrs.push_back(new_addr);
- break;
- }
- }
- }
-
- return usrp2_addrs;
-}
-
-/***********************************************************************
- * Structors
- **********************************************************************/
-usrp2::usrp2(const device_addr_t &device_addr){
- //create a control transport
- uhd::transport::udp::sptr ctrl_transport(
- new uhd::transport::udp(
- device_addr["addr"],
- boost::lexical_cast<std::string>(USRP2_UDP_CTRL_PORT)
- )
- );
-
- //create a data transport
- uhd::transport::udp::sptr data_transport(
- new uhd::transport::udp(
- device_addr["addr"],
- boost::lexical_cast<std::string>(USRP2_UDP_DATA_PORT)
- )
- );
-
- //create the usrp2 implementation guts
- _impl = usrp2_impl::sptr(
- new usrp2_impl(ctrl_transport, data_transport)
- );
-}
-
-usrp2::~usrp2(void){
- /* NOP */
-}
-
-/***********************************************************************
- * Get Properties
- **********************************************************************/
-void usrp2::get(const wax::obj &key, wax::obj &val){
- return wax::cast<usrp2_impl::sptr>(_impl)->get(key, val);
-}
-
-/***********************************************************************
- * Set Properties
- **********************************************************************/
-void usrp2::set(const wax::obj &key, const wax::obj &val){
- return wax::cast<usrp2_impl::sptr>(_impl)->set(key, val);
-}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 2e4a0715f..cc73b229c 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -23,6 +23,13 @@ using namespace uhd;
/***********************************************************************
* Helper Methods
**********************************************************************/
+void usrp2_impl::mboard_init(void){
+ _mboards[""] = wax_obj_proxy(
+ boost::bind(&usrp2_impl::mboard_get, this, _1, _2),
+ boost::bind(&usrp2_impl::mboard_set, this, _1, _2)
+ );
+}
+
void usrp2_impl::init_clock_config(void){
//init the pps source clock config
_pps_source_dict["sma"] = USRP2_PPS_SOURCE_SMA;
@@ -60,7 +67,7 @@ void usrp2_impl::update_clock_config(void){
/***********************************************************************
* MBoard Get Properties
**********************************************************************/
-void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
+void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
wax::obj key; std::string name;
boost::tie(key, name) = extract_named_prop(key_);
@@ -146,7 +153,7 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
/***********************************************************************
* MBoard Set Properties
**********************************************************************/
-void usrp2_impl::set(const wax::obj &key, const wax::obj &val){
+void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
//handle the get request conditioned on the key
switch(wax::cast<mboard_prop_t>(key)){
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index dbf740f2b..ac0c3c88a 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -22,6 +22,78 @@
#include "usrp2_impl.hpp"
using namespace uhd;
+using namespace uhd::usrp;
+
+/***********************************************************************
+ * Discovery over the udp transport
+ **********************************************************************/
+uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){
+ device_addrs_t usrp2_addrs;
+
+ //create a udp transport to communicate
+ //TODO if an addr is not provided, search all interfaces?
+ std::string ctrl_port = boost::lexical_cast<std::string>(USRP2_UDP_CTRL_PORT);
+ uhd::transport::udp udp_transport(hint["addr"], ctrl_port, true);
+
+ //send a hello control packet
+ usrp2_ctrl_data_t ctrl_data_out;
+ ctrl_data_out.id = htonl(USRP2_CTRL_ID_GIVE_ME_YOUR_IP_ADDR_BRO);
+ udp_transport.send(boost::asio::buffer(&ctrl_data_out, sizeof(ctrl_data_out)));
+
+ //loop and recieve until the time is up
+ size_t num_timeouts = 0;
+ while(true){
+ uhd::shared_iovec iov = udp_transport.recv();
+ //std::cout << boost::asio::buffer_size(buff) << "\n";
+ if (iov.len < sizeof(usrp2_ctrl_data_t)){
+ //sleep a little so we dont burn cpu
+ if (num_timeouts++ > 50) break;
+ boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+ }else{
+ //handle the received data
+ const usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<const usrp2_ctrl_data_t *>(iov.base);
+ switch(ntohl(ctrl_data_in->id)){
+ case USRP2_CTRL_ID_THIS_IS_MY_IP_ADDR_DUDE:
+ //make a boost asio ipv4 with the raw addr in host byte order
+ boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr));
+ device_addr_t new_addr;
+ new_addr["name"] = "USRP2";
+ new_addr["type"] = "udp";
+ new_addr["addr"] = ip_addr.to_string();
+ usrp2_addrs.push_back(new_addr);
+ break;
+ }
+ }
+ }
+
+ return usrp2_addrs;
+}
+
+/***********************************************************************
+ * Make
+ **********************************************************************/
+device::sptr usrp2::make(const device_addr_t &device_addr){
+ //create a control transport
+ uhd::transport::udp::sptr ctrl_transport(
+ new uhd::transport::udp(
+ device_addr["addr"],
+ boost::lexical_cast<std::string>(USRP2_UDP_CTRL_PORT)
+ )
+ );
+
+ //create a data transport
+ uhd::transport::udp::sptr data_transport(
+ new uhd::transport::udp(
+ device_addr["addr"],
+ boost::lexical_cast<std::string>(USRP2_UDP_DATA_PORT)
+ )
+ );
+
+ //create the usrp2 implementation guts
+ return device::sptr(dynamic_cast<device*>(
+ new usrp2_impl(ctrl_transport, data_transport)
+ ));
+}
/***********************************************************************
* Structors
@@ -46,6 +118,9 @@ usrp2_impl::usrp2_impl(
_allowed_decim_and_interp_rates.push_back(i);
}
+ //init the mboard
+ mboard_init();
+
//init the tx and rx dboards
dboard_init();
@@ -100,3 +175,41 @@ usrp2_ctrl_data_t usrp2_impl::ctrl_send_and_recv(const usrp2_ctrl_data_t &out_da
}
throw std::runtime_error("usrp2 no control response");
}
+
+/***********************************************************************
+ * Device Properties
+ **********************************************************************/
+void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
+ wax::obj key; std::string name;
+ boost::tie(key, name) = extract_named_prop(key_);
+
+ //handle the get request conditioned on the key
+ switch(wax::cast<device_prop_t>(key)){
+ case DEVICE_PROP_NAME:
+ val = std::string("usrp2 device");
+ return;
+
+ case DEVICE_PROP_MBOARD:
+ val = _mboards[name].get_link();
+ return;
+
+ case DEVICE_PROP_MBOARD_NAMES:
+ val = prop_names_t(_mboards.get_keys());
+ return;
+ }
+}
+
+void usrp2_impl::set(const wax::obj &, const wax::obj &){
+ throw std::runtime_error("Cannot set in usrp2 device");
+}
+
+/***********************************************************************
+ * IO Interface
+ **********************************************************************/
+void usrp2_impl::send_raw(const std::vector<boost::asio::const_buffer> &){
+ return;
+}
+
+uhd::shared_iovec usrp2_impl::recv_raw(void){
+ throw std::runtime_error("not implemented");
+}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index be457a91c..2545efd58 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#include <uhd/usrp/usrp2.hpp>
#include <uhd/dict.hpp>
#include <uhd/props.hpp>
#include <uhd/time_spec.hpp>
@@ -70,7 +71,7 @@ private:
* The implementation details are encapsulated here.
* Handles properties on the mboard, dboard, dsps...
*/
-class usrp2_impl : boost::noncopyable, public wax::obj{
+class usrp2_impl : public uhd::device{
public:
typedef boost::shared_ptr<usrp2_impl> sptr;
@@ -96,6 +97,10 @@ public:
//misc access methods
double get_master_clock_freq(void);
+ //the io interface
+ void send_raw(const std::vector<boost::asio::const_buffer> &);
+ uhd::shared_iovec recv_raw(void);
+
private:
//udp transports for control and data
uhd::transport::udp::sptr _ctrl_transport;
@@ -119,6 +124,12 @@ private:
uhd::usrp::dboard_manager::sptr _dboard_manager;
void dboard_init(void);
+ //properties for the mboard
+ void mboard_init(void);
+ void mboard_get(const wax::obj &, wax::obj &);
+ void mboard_set(const wax::obj &, const wax::obj &);
+ uhd::dict<std::string, wax_obj_proxy> _mboards;
+
//properties interface for rx dboard
void rx_dboard_get(const wax::obj &, wax::obj &);
void rx_dboard_set(const wax::obj &, const wax::obj &);