aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-04-29 14:27:04 -0700
committerJosh Blum <josh@joshknows.com>2011-04-29 14:27:04 -0700
commit0479162ae39d3d4708ab332107c25f4710275232 (patch)
tree68e257a69642312da250a01b13b8284201967aaf /host/lib/usrp
parent6bd7281f83d5311675847b31746525841657c057 (diff)
downloaduhd-0479162ae39d3d4708ab332107c25f4710275232.tar.gz
uhd-0479162ae39d3d4708ab332107c25f4710275232.tar.bz2
uhd-0479162ae39d3d4708ab332107c25f4710275232.zip
usrp2: allow devices to be discovered when usrp2_iface::make throws
If the discovery throws an exception, we can still yeild a discovered device. The error (which is a problem) will re-appear at make/factory time. The side effect is that a device w/ error will be discovered w/ empty serial and names. We protect against this by supporing older firmwares where i2c proto is compatible.
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp28
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
}