summaryrefslogtreecommitdiffstats
path: root/lib/device.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/device.cpp')
-rw-r--r--lib/device.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/device.cpp b/lib/device.cpp
index fe655ec7a..4f942ebaf 100644
--- a/lib/device.cpp
+++ b/lib/device.cpp
@@ -2,20 +2,24 @@
// Copyright 2010 Ettus Research LLC
//
+#include <usrp_uhd/usrp/usrp.hpp>
#include <usrp_uhd/device.hpp>
#include <boost/format.hpp>
+#include <stdexcept>
using namespace usrp_uhd;
-std::vector<device_addr_t> device::discover(const device_addr_t& hint){
+std::vector<device_addr_t> device::discover(const device_addr_t & hint = device_addr_t()){
std::vector<device_addr_t> device_addrs;
if (hint.type == DEVICE_ADDR_TYPE_VIRTUAL){
- //TODO device_addrs.push_back(...);
+ //make a copy of the hint for virtual testing
+ device_addr_t virtual_device_addr = hint;
+ device_addrs.push_back(virtual_device_addr);
}
return device_addrs;
}
-device::sptr device::make(const device_addr_t& hint, size_t which){
+device::sptr device::make(const device_addr_t & hint, size_t which){
std::vector<device_addr_t> device_addrs = discover(hint);
//check that we found any devices
if (device_addrs.size() == 0){
@@ -31,10 +35,13 @@ device::sptr device::make(const device_addr_t& hint, size_t which){
));
}
//create the new device with the discovered address
- return sptr(new device(device_addrs.at(which)));
+ if (hint.type == DEVICE_ADDR_TYPE_VIRTUAL){
+ return sptr(new usrp_uhd::usrp::usrp(device_addrs.at(which)));
+ }
+ throw std::runtime_error("cant make a device");
}
-device::device(const device_addr_t&){
+device::device(void){
/* NOP */
}