From fc0014a77681c6ab539ea6ed76fa3bccf52933dd Mon Sep 17 00:00:00 2001 From: bstapleton Date: Thu, 29 Jun 2017 13:20:00 -0700 Subject: x300: Changed discovery to return early if we find the serial requested --- host/lib/usrp/x300/x300_impl.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'host') diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 71cb7f341..8f6e52523 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -333,7 +333,21 @@ device_addrs_t x300_find(const device_addr_t &hint_) //call discover with the new hint and append results device_addrs_t new_addrs = x300_find(new_hint); - addrs.insert(addrs.begin(), new_addrs.begin(), new_addrs.end()); + //if we are looking for a serial, only add the one device with a matching serial + if (hint.has_key("serial")) { + bool found_serial = false; //signal to break out of the interface loop + for (device_addrs_t::iterator new_addr_it=new_addrs.begin(); new_addr_it != new_addrs.end(); new_addr_it++) { + if ((*new_addr_it)["serial"] == hint["serial"]) { + addrs.emplace(addrs.begin(), *new_addr_it); + found_serial = true; + break; + } + } + if (found_serial) break; + } else { + // Otherwise, add all devices we find + addrs.insert(addrs.begin(), new_addrs.begin(), new_addrs.end()); + } } } -- cgit v1.2.3