From 951ed3d66c343460450d2c3bc022298c1ccb2490 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Jul 2011 15:22:21 -0700 Subject: usrp2: try/catch for socket open on discovery, use large send buffers windows --- host/lib/usrp/usrp2/usrp2_impl.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 45db0d081..9a8269e6f 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -86,11 +86,17 @@ static device_addrs_t usrp2_find(const device_addr_t &hint_){ return usrp2_addrs; } - //create a udp transport to communicate - std::string ctrl_port = boost::lexical_cast(USRP2_UDP_CTRL_PORT); - udp_simple::sptr udp_transport = udp_simple::make_broadcast( - hint["addr"], ctrl_port - ); + //Create a UDP transport to communicate: + //Some devices will cause a throw when opened for a broadcast address. + //We print and recover so the caller can loop through all bcast addrs. + udp_simple::sptr udp_transport; + try{ + udp_transport = udp_simple::make_broadcast(hint["addr"], BOOST_STRINGIZE(USRP2_UDP_CTRL_PORT)); + } + catch(const std::exception &e){ + UHD_MSG(error) << boost::format("Cannot open UDP transport on %s\n%s") % hint["addr"] % e.what() << std::endl; + return usrp2_addrs; //dont throw, but return empty address so caller can insert + } //send a hello control packet usrp2_ctrl_data_t ctrl_data_out = usrp2_ctrl_data_t(); @@ -277,6 +283,12 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ device_addr["recv_buff_size"] = "50e6"; #endif } + if (not device_addr.has_key("send_buff_size")){ + #if defined(UHD_PLATFORM_WIN32) + //a large send buff is ok to have on windows + device_addr["send_buff_size"] = "50e6"; + #endif + } device_addrs_t device_args = separate_device_addr(device_addr); -- cgit v1.2.3