diff options
author | Nick Foster <nick@nerdnetworks.org> | 2010-11-10 12:15:35 -0800 |
---|---|---|
committer | Nick Foster <nick@nerdnetworks.org> | 2010-11-10 12:15:35 -0800 |
commit | fb0cdbc553d288402ee7939dc72f4368eb9e8e1b (patch) | |
tree | e20003155af08428448a7834a82d259f3b68717d /host/lib/usrp/usrp2/usrp2_impl.cpp | |
parent | 8fe1e7b29aacce7f75ae36e81706bbde02749b97 (diff) | |
parent | 8c434f7d63aca25b55d6d13dffcc1d7037261d4f (diff) | |
download | uhd-fb0cdbc553d288402ee7939dc72f4368eb9e8e1b.tar.gz uhd-fb0cdbc553d288402ee7939dc72f4368eb9e8e1b.tar.bz2 uhd-fb0cdbc553d288402ee7939dc72f4368eb9e8e1b.zip |
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp2p-next
Conflicts:
firmware/microblaze/lib/u2_init.c
host/lib/usrp/usrp2/clock_ctrl.cpp
host/lib/usrp/usrp2/fw_common.h
host/lib/usrp/usrp2/mboard_impl.cpp
host/lib/usrp/usrp2/usrp2_iface.cpp
host/lib/usrp/usrp2/usrp2_iface.hpp
Diffstat (limited to 'host/lib/usrp/usrp2/usrp2_impl.cpp')
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index a680708ad..5f549c4fd 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -21,6 +21,7 @@ #include <uhd/usrp/device_props.hpp> #include <uhd/utils/assert.hpp> #include <uhd/utils/static.hpp> +#include <uhd/utils/warning.hpp> #include <uhd/utils/algorithm.hpp> #include <boost/assign/list_of.hpp> #include <boost/format.hpp> @@ -61,7 +62,7 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){ if (if_addrs.inet == asio::ip::address_v4::loopback().to_string()) continue; //create a new hint with this broadcast address - device_addr_t new_hint; + device_addr_t new_hint = hint; new_hint["addr"] = if_addrs.bcast; //call discover with the new hint and append results @@ -101,19 +102,37 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){ while(true){ size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem), DISCOVERY_TIMEOUT_MS); //std::cout << len << "\n"; - if (len > offsetof(usrp2_ctrl_data_t, data)){ - //handle the received data - switch(ntohl(ctrl_data_in->id)){ - case USRP2_CTRL_ID_WAZZUP_DUDE: - //make a boost asio ipv4 with the raw addr in host byte order - boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr)); - device_addr_t new_addr; - new_addr["type"] = "usrp2"; - new_addr["addr"] = ip_addr.to_string(); - usrp2_addrs.push_back(new_addr); - //dont break here, it will exit the while loop - //just continue on to the next loop iteration + if (len > offsetof(usrp2_ctrl_data_t, data) and ntohl(ctrl_data_in->id) == USRP2_CTRL_ID_WAZZUP_DUDE){ + //make a boost asio ipv4 with the raw addr in host byte order + boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr)); + device_addr_t new_addr; + new_addr["type"] = "usrp2"; + new_addr["addr"] = ip_addr.to_string(); + //Attempt to read the name from the EEPROM and perform filtering. + //This operation can throw due to COMPAT mismatch. That is OK. + //We will allow the device to be found and the COMPAT mismatch + //will be thrown as an exception in the factory function. + try{ + mboard_eeprom_t mb_eeprom = usrp2_iface::make( + udp_simple::make_connected(new_addr["addr"], num2str(USRP2_UDP_CTRL_PORT)) + )->mb_eeprom; + new_addr["name"] = mb_eeprom["name"]; + new_addr["serial"] = mb_eeprom["serial"]; + if ( + (not hint.has_key("name") or hint["name"] == new_addr["name"]) and + (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]) + ){ + usrp2_addrs.push_back(new_addr); + } } + catch(const std::exception &e){ + uhd::warning::post( + std::string("Ignoring discovered device\n") + + e.what() + ); + } + //dont break here, it will exit the while loop + //just continue on to the next loop iteration } if (len == 0) break; //timeout } |