diff options
| author | Josh Blum <josh@joshknows.com> | 2010-02-12 18:07:55 -0800 | 
|---|---|---|
| committer | Josh Blum <josh@joshknows.com> | 2010-02-12 18:07:55 -0800 | 
| commit | 9fff25f4e5da179ea29ff44278e0415a337870cb (patch) | |
| tree | cfbee4cf2921fd4bd415e3af1c1d466f79bab3d7 /lib/device.cpp | |
| parent | 350f5c5decca20a54132867283448fd32226bbc2 (diff) | |
| download | uhd-9fff25f4e5da179ea29ff44278e0415a337870cb.tar.gz uhd-9fff25f4e5da179ea29ff44278e0415a337870cb.tar.bz2 uhd-9fff25f4e5da179ea29ff44278e0415a337870cb.zip | |
Added a templated dictionary class because its more useful than map.
Made the device addrs into a string:string dict.
If its all strings we dont have to change the top level caller for new product.
Created shared_iovec class to manage memory for device recvs.
Work on the bro/dude control protocol for usrp2.
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)          ));      } | 
