diff options
author | Josh Blum <josh@joshknows.com> | 2010-03-30 15:11:23 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-03-30 15:11:23 -0700 |
commit | 281307833c8275031bd2469e6aef3f472490749a (patch) | |
tree | 2ffe095d5f4a741c65cfee08f52adc43e5cf148a | |
parent | f9be69cae7c0fd9bca8b310ff79dd6aad958dc2b (diff) | |
download | uhd-281307833c8275031bd2469e6aef3f472490749a.tar.gz uhd-281307833c8275031bd2469e6aef3f472490749a.tar.bz2 uhd-281307833c8275031bd2469e6aef3f472490749a.zip |
use find to discover devices
-rw-r--r-- | host/include/uhd/device.hpp | 14 | ||||
-rw-r--r-- | host/include/uhd/usrp/usrp1e.hpp | 5 | ||||
-rw-r--r-- | host/include/uhd/usrp/usrp2.hpp | 5 | ||||
-rw-r--r-- | host/lib/device.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/usrp1e/usrp1e_none.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 7 | ||||
-rw-r--r-- | host/utils/CMakeLists.txt | 6 | ||||
-rw-r--r-- | host/utils/uhd_find_devices.cpp (renamed from host/utils/discover_usrps.cpp) | 10 |
8 files changed, 27 insertions, 30 deletions
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index 1d0360799..4d4196d98 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -38,22 +38,22 @@ class UHD_API device : boost::noncopyable, public wax::obj{ public: typedef boost::shared_ptr<device> sptr; - typedef boost::function<device_addrs_t(const device_addr_t &)> discover_t; + typedef boost::function<device_addrs_t(const device_addr_t &)> find_t; typedef boost::function<sptr(const device_addr_t &)> make_t; /*! * Register a device into the discovery and factory system. * - * \param discover a function that discovers devices + * \param find a function that discovers devices * \param make a factory function that makes a device */ static void register_device( - const discover_t &discover, + const find_t &find, const make_t &make ); /*! - * \brief Discover usrp devices attached to the host. + * \brief Find usrp devices attached to the host. * * The hint device address should be used to narrow down the search * to particular transport types and/or transport arguments. @@ -61,17 +61,17 @@ public: * \param hint a partially (or fully) filled in device address * \return a vector of device addresses for all usrps on the system */ - static device_addrs_t discover(const device_addr_t &hint); + static device_addrs_t find(const device_addr_t &hint); /*! * \brief Create a new usrp device from the device address hint. * - * The make routine will call discover and pick one of the results. + * The make routine will call find and pick one of the results. * By default, the first result will be used to create a new device. * Use the which parameter as an index into the list of results. * * \param hint a partially (or fully) filled in device address - * \param which which address to use when multiple are discovered + * \param which which address to use when multiple are found * \return a shared pointer to a new device instance */ static sptr make(const device_addr_t &hint, size_t which = 0); diff --git a/host/include/uhd/usrp/usrp1e.hpp b/host/include/uhd/usrp/usrp1e.hpp index 5cba4ef52..cee9dc3d5 100644 --- a/host/include/uhd/usrp/usrp1e.hpp +++ b/host/include/uhd/usrp/usrp1e.hpp @@ -29,12 +29,11 @@ namespace uhd{ namespace usrp{ class UHD_API usrp1e : public device{ public: /*! - * Discover usrp1e devices on the system via the device node. - * This static method will be called by the device::discover. + * Find usrp1e devices on the system via the device node. * \param hint a device addr with the usrp1e address filled in * \return a vector of device addresses for all usrp1es found */ - static device_addrs_t discover(const device_addr_t &hint); + static device_addrs_t find(const device_addr_t &hint); /*! * Make a usrp1e from a device address. diff --git a/host/include/uhd/usrp/usrp2.hpp b/host/include/uhd/usrp/usrp2.hpp index 277ddc131..613b40ae3 100644 --- a/host/include/uhd/usrp/usrp2.hpp +++ b/host/include/uhd/usrp/usrp2.hpp @@ -29,17 +29,16 @@ namespace uhd{ namespace usrp{ class UHD_API usrp2 : public device{ public: /*! - * Discover usrp2 devices over the ethernet. + * Find usrp2 devices over the ethernet. * * Recommended key/value pairs for the device hint address: * hint["addr"] = address, where address is a resolvable address * or ip address, which may or may not be a broadcast address. * - * This static method will be called by the device::discover. * \param hint a device addr with the usrp2 address filled in * \return a vector of device addresses for all usrp2s found */ - static device_addrs_t discover(const device_addr_t &hint); + static device_addrs_t find(const device_addr_t &hint); /*! * Make a usrp2 from a device address. diff --git a/host/lib/device.cpp b/host/lib/device.cpp index ca45d0795..27a365d34 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -57,23 +57,23 @@ static size_t hash_device_addr( /*********************************************************************** * Registration **********************************************************************/ -typedef boost::tuple<device::discover_t, device::make_t> dev_fcn_reg_t; +typedef boost::tuple<device::find_t, device::make_t> dev_fcn_reg_t; // instantiate the device function registry container UHD_SINGLETON_FCN(std::vector<dev_fcn_reg_t>, get_dev_fcn_regs) void device::register_device( - const discover_t &discover, + const find_t &find, const make_t &make ){ //std::cout << "registering device" << std::endl; - get_dev_fcn_regs().push_back(dev_fcn_reg_t(discover, make)); + get_dev_fcn_regs().push_back(dev_fcn_reg_t(find, make)); } /*********************************************************************** * Discover **********************************************************************/ -device_addrs_t device::discover(const device_addr_t &hint){ +device_addrs_t device::find(const device_addr_t &hint){ device_addrs_t device_addrs; BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){ diff --git a/host/lib/usrp/usrp1e/usrp1e_none.cpp b/host/lib/usrp/usrp1e/usrp1e_none.cpp index 1c8cf9a5b..84fb9276c 100644 --- a/host/lib/usrp/usrp1e/usrp1e_none.cpp +++ b/host/lib/usrp/usrp1e/usrp1e_none.cpp @@ -25,7 +25,7 @@ using namespace uhd::usrp; * when the required kernel module headers are not present. */ -device_addrs_t usrp1e::discover(const device_addr_t &){ +device_addrs_t usrp1e::find(const device_addr_t &){ return device_addrs_t(); //return empty list } diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 9dce351be..b0ee395fb 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -30,13 +30,13 @@ using namespace uhd::transport; namespace asio = boost::asio; UHD_STATIC_BLOCK(register_usrp2_device){ - device::register_device(&usrp2::discover, &usrp2::make); + device::register_device(&usrp2::find, &usrp2::make); } /*********************************************************************** * Discovery over the udp transport **********************************************************************/ -uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){ +uhd::device_addrs_t usrp2::find(const device_addr_t &hint){ device_addrs_t usrp2_addrs; //if no address was specified, send a broadcast on each interface @@ -50,7 +50,7 @@ uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){ new_hint["addr"] = if_addrs.bcast; //call discover with the new hint and append results - device_addrs_t new_usrp2_addrs = usrp2::discover(new_hint); + device_addrs_t new_usrp2_addrs = usrp2::find(new_hint); usrp2_addrs.insert(usrp2_addrs.begin(), new_usrp2_addrs.begin(), new_usrp2_addrs.end() ); @@ -83,7 +83,6 @@ uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){ 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["transport"] = "udp"; new_addr["addr"] = ip_addr.to_string(); usrp2_addrs.push_back(new_addr); //dont break here, it will exit the while loop diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 1fb132937..aa01d1e35 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -15,9 +15,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -ADD_EXECUTABLE(discover_usrps discover_usrps.cpp) -TARGET_LINK_LIBRARIES(discover_usrps uhd) -INSTALL(TARGETS discover_usrps RUNTIME DESTINATION ${RUNTIME_DIR}) +ADD_EXECUTABLE(uhd_find_devices uhd_find_devices.cpp) +TARGET_LINK_LIBRARIES(uhd_find_devices uhd) +INSTALL(TARGETS uhd_find_devices RUNTIME DESTINATION ${RUNTIME_DIR}) ADD_EXECUTABLE(usrp2_burner usrp2_burner.cpp) TARGET_LINK_LIBRARIES(usrp2_burner uhd) diff --git a/host/utils/discover_usrps.cpp b/host/utils/uhd_find_devices.cpp index 72c5b8822..b328216d0 100644 --- a/host/utils/discover_usrps.cpp +++ b/host/utils/uhd_find_devices.cpp @@ -34,11 +34,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); + po::notify(vm); //print the help message if (vm.count("help")){ - std::cout << boost::format("Discover USRPs %s") % desc << std::endl; + std::cout << boost::format("UHD Find Devices %s") % desc << std::endl; return ~0; } @@ -52,16 +52,16 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } //discover the usrps and print the results - uhd::device_addrs_t device_addrs = uhd::device::discover(device_addr); + uhd::device_addrs_t device_addrs = uhd::device::find(device_addr); if (device_addrs.size() == 0){ - std::cerr << "No USRP Devices Found" << std::endl; + std::cerr << "No UHD Devices Found" << std::endl; return ~0; } for (size_t i = 0; i < device_addrs.size(); i++){ std::cout << "--------------------------------------------------" << std::endl; - std::cout << "-- USRP Device " << i << std::endl; + std::cout << "-- UHD Device " << i << std::endl; std::cout << "--------------------------------------------------" << std::endl; std::cout << device_addrs[i].to_string() << std::endl << std::endl; uhd::device::make(device_addrs[i]); //test make |