diff options
| -rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 28 | 
1 files changed, 16 insertions, 12 deletions
| diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index cb92b1921..48443bba4 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -105,33 +105,37 @@ static device_addrs_t usrp2_find(const device_addr_t &hint_){          size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem));          //std::cout << len << "\n";          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 compatibility mismatch. -            //In this case, the discovered device will be ignored.              try{                  mboard_eeprom_t mb_eeprom = usrp2_iface::make(udp_simple::make_connected(                      new_addr["addr"], boost::lexical_cast<std::string>(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() -                ); +            catch(const std::exception &){ +                //set these values as empty string so the device may still be found +                //and the filter's below can still operate on the discovered device +                new_addr["name"] = ""; +                new_addr["serial"] = "";              } + +            //filter the discovered device below by matching optional keys +            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); +            } +              //dont break here, it will exit the while loop              //just continue on to the next loop iteration          } | 
