aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp20
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp2
2 files changed, 20 insertions, 2 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 85d73e83a..f04ae8d2c 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -15,9 +15,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#include <uhd/transport/if_addrs.hpp>
+#include <uhd/utils.hpp>
#include <boost/format.hpp>
+#include <boost/foreach.hpp>
#include <boost/bind.hpp>
-#include <uhd/utils.hpp>
#include <iostream>
#include "usrp2_impl.hpp"
@@ -36,7 +38,21 @@ STATIC_BLOCK(register_usrp2_device){
uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){
device_addrs_t usrp2_addrs;
- if (not hint.has_key("addr")) return usrp2_addrs;
+ //if no address was specified, send a broadcast on each interface
+ if (not hint.has_key("addr")){
+ BOOST_FOREACH(const if_addrs_t &if_addrs, get_if_addrs()){
+ //create a new hint with this broadcast address
+ device_addr_t new_hint = 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);
+ usrp2_addrs.insert(usrp2_addrs.begin(),
+ new_usrp2_addrs.begin(), new_usrp2_addrs.end()
+ );
+ }
+ return usrp2_addrs;
+ }
//create a udp transport to communicate
//TODO if an addr is not provided, search all interfaces?
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 2794cc666..3a2963c5a 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -21,6 +21,8 @@
#include <uhd/usrp/usrp2.hpp>
#include <uhd/dict.hpp>
#include <uhd/types.hpp>
+#include <uhd/time_spec.hpp>
+#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>