diff options
Diffstat (limited to 'lib/device.cpp')
-rw-r--r-- | lib/device.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/device.cpp b/lib/device.cpp index 4b51a70d4..822733217 100644 --- a/lib/device.cpp +++ b/lib/device.cpp @@ -23,35 +23,37 @@ using namespace uhd; -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_UDP){ +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); + } + else if (hint["type"] == "udp"){ std::vector<device_addr_t> usrp2_addrs = usrp::mboard::usrp2::discover(hint); device_addrs.insert(device_addrs.begin(), usrp2_addrs.begin(), usrp2_addrs.end()); } - if (hint.type == DEVICE_ADDR_TYPE_VIRTUAL){ - //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){ throw std::runtime_error(str( - boost::format("No devices found for %s") % hint.to_string() + boost::format("No devices found for %s") % device_addr_to_string(hint) )); } //check that the which index is valid if (device_addrs.size() <= which){ throw std::runtime_error(str( - boost::format("No device at index %d for %s") - % which % hint.to_string() + boost::format("No device at index %d for %s") % which % device_addr_to_string(hint) )); } |