diff options
author | Josh Blum <josh@joshknows.com> | 2011-04-13 10:04:42 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-04-13 10:04:42 -0700 |
commit | f9e1f06e81109573d2e600a18c288aafd1438f64 (patch) | |
tree | fd544730caea96a621c9f35b02c268958ca48709 | |
parent | 2f102fbff2b7245d3d038e7dfffaa2de856b61aa (diff) | |
download | uhd-f9e1f06e81109573d2e600a18c288aafd1438f64.tar.gz uhd-f9e1f06e81109573d2e600a18c288aafd1438f64.tar.bz2 uhd-f9e1f06e81109573d2e600a18c288aafd1438f64.zip |
usrp2: add check for holler protocol, we can support backwards
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 42 |
2 files changed, 29 insertions, 15 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 227233917..6e1d69044 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -248,7 +248,7 @@ public: while(true){ size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CTRL_RECV_TIMEOUT); boost::uint32_t compat = ntohl(ctrl_data_in->proto_ver); - if(len >= sizeof(boost::uint32_t) and hi >= compat and lo <= compat){ + if(len >= sizeof(boost::uint32_t) and (hi < compat or lo > compat)){ throw uhd::runtime_error(str(boost::format( "Expected protocol compatibility number %s, but got %d:\n" "The firmware build is not compatible with the host code build." diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index f42be321b..cb92b1921 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -171,6 +171,15 @@ static mtu_result_t determine_mtu(const std::string &addr){ usrp2_ctrl_data_t *ctrl_data = reinterpret_cast<usrp2_ctrl_data_t *>(buffer); static const double echo_timeout = 0.020; //20 ms + //test holler - check if its supported in this fw version + ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO); + ctrl_data->proto_ver = htonl(USRP2_FW_COMPAT_NUM); + ctrl_data->data.echo_args.len = htonl(sizeof(usrp2_ctrl_data_t)); + udp_sock->send(boost::asio::buffer(buffer, sizeof(usrp2_ctrl_data_t))); + udp_sock->recv(boost::asio::buffer(buffer), echo_timeout); + if (ntohl(ctrl_data->id) != USRP2_CTRL_ID_HOLLER_BACK_DUDE) + throw uhd::not_implemented_error("holler protocol not implemented"); + size_t min_recv_mtu = sizeof(usrp2_ctrl_data_t), max_recv_mtu = sizeof(buffer); size_t min_send_mtu = sizeof(usrp2_ctrl_data_t), max_send_mtu = sizeof(buffer); @@ -233,23 +242,28 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ device_addrs_t device_args = separate_device_addr(device_addr); - //calculate the minimum send and recv mtu of all devices - mtu_result_t mtu = determine_mtu(device_args[0]["addr"]); - for (size_t i = 1; i < device_args.size(); i++){ - mtu_result_t mtu_i = determine_mtu(device_args[i]["addr"]); - mtu.recv_mtu = std::min(mtu.recv_mtu, mtu_i.recv_mtu); - mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu); - } + try{ + //calculate the minimum send and recv mtu of all devices + mtu_result_t mtu = determine_mtu(device_args[0]["addr"]); + for (size_t i = 1; i < device_args.size(); i++){ + mtu_result_t mtu_i = determine_mtu(device_args[i]["addr"]); + mtu.recv_mtu = std::min(mtu.recv_mtu, mtu_i.recv_mtu); + mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu); + } - //use the discovered mtu or clip the users requested mtu - mtu.recv_mtu = std::min(size_t(device_addr.cast<double>("recv_frame_size", 9000)), mtu.recv_mtu); - mtu.send_mtu = std::min(size_t(device_addr.cast<double>("send_frame_size", 9000)), mtu.send_mtu); + //use the discovered mtu or clip the users requested mtu + mtu.recv_mtu = std::min(size_t(device_addr.cast<double>("recv_frame_size", 9000)), mtu.recv_mtu); + mtu.send_mtu = std::min(size_t(device_addr.cast<double>("send_frame_size", 9000)), mtu.send_mtu); - device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu); - device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu); + device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu); + device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu); - std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; - std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; + std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + } + catch(const uhd::not_implemented_error &){ + //just ignore this error, makes older fw work... + } device_args = separate_device_addr(device_addr); //update args for new frame sizes |