diff options
-rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 8 | ||||
-rw-r--r-- | host/docs/usrp2.rst | 28 | ||||
-rw-r--r-- | host/lib/transport/udp_zero_copy_asio.cpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 2 |
4 files changed, 29 insertions, 18 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 45e5ff5fe..21803b199 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -177,7 +177,7 @@ void handle_udp_ctrl_packet( unsigned char *payload, int payload_len ){ //printf("Got ctrl packet #words: %d\n", (int)payload_len); - usrp2_ctrl_data_t *ctrl_data_in = (usrp2_ctrl_data_t *)payload; + const usrp2_ctrl_data_t *ctrl_data_in = (usrp2_ctrl_data_t *)payload; uint32_t ctrl_data_in_id = ctrl_data_in->id; //ensure that the protocol versions match @@ -288,15 +288,15 @@ void handle_udp_ctrl_packet( case USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO: switch(ctrl_data_in->data.poke_args.num_bytes){ case sizeof(uint32_t): - ctrl_data_in->data.poke_args.data = *((uint32_t *) ctrl_data_in->data.poke_args.addr); + ctrl_data_out.data.poke_args.data = *((uint32_t *) ctrl_data_in->data.poke_args.addr); break; case sizeof(uint16_t): - ctrl_data_in->data.poke_args.data = *((uint16_t *) ctrl_data_in->data.poke_args.addr); + ctrl_data_out.data.poke_args.data = *((uint16_t *) ctrl_data_in->data.poke_args.addr); break; case sizeof(uint8_t): - ctrl_data_in->data.poke_args.data = *((uint8_t *) ctrl_data_in->data.poke_args.addr); + ctrl_data_out.data.poke_args.data = *((uint8_t *) ctrl_data_in->data.poke_args.addr); break; } diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 09987b3fa..aff0d0454 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -158,10 +158,25 @@ buffer incoming samples faster than they can be processed. However, if you application cannot process samples fast enough, no amount of buffering can save you. +By default, the UHD will try to request a reasonably large buffer size for both send and receive. +A warning will be printed on instantiation if the actual buffer size is insufficient. +See the OS specific notes below: + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +OS specific notes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +On linux, the maximum buffer sizes are capped by the sysctl values +**net.core.rmem_max** and **net.core.wmem_max**. +To change the maximum values, run the following commands: +:: + + sudo sysctl -w net.core.rmem_max=<new value> + sudo sysctl -w net.core.wmem_max=<new value> + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Device address params ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -To set the size of the buffers, +To manually set the size of the buffers, the usrp2 will accept two optional parameters in the device address. Each parameter will accept a numeric value for the number of bytes. @@ -172,14 +187,3 @@ Example, set the args string to the following: :: addr=192.168.10.2, recv_buff_size=100e6 - -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -OS specific notes -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -On linux, the maximum buffer sizes are capped by the sysctl values -**net.core.rmem_max** and **net.core.wmem_max**. -To change the maximum values, run the following commands: -:: - - sudo sysctl -w net.core.rmem_max=<new value> - sudo sysctl -w net.core.wmem_max=<new value> diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp index c3c02707e..7f9292d24 100644 --- a/host/lib/transport/udp_zero_copy_asio.cpp +++ b/host/lib/transport/udp_zero_copy_asio.cpp @@ -27,7 +27,8 @@ using namespace uhd::transport; /*********************************************************************** * Constants **********************************************************************/ -static const size_t MIN_SOCK_BUFF_SIZE = size_t(100e3); +//enough buffering for half a second of samples at full rate on usrp2 +static const size_t MIN_SOCK_BUFF_SIZE = size_t(sizeof(boost::uint32_t) * 25e6 * 0.5); static const size_t MAX_DGRAM_SIZE = 1500; //assume max size on send and recv static const double RECV_TIMEOUT = 0.1; //100 ms @@ -159,6 +160,12 @@ template<typename Opt> static void resize_buff_helper( //otherwise, ensure that the buffer is at least the minimum size else if (udp_trans->get_buff_size<Opt>() < MIN_SOCK_BUFF_SIZE){ resize_buff_helper<Opt>(udp_trans, MIN_SOCK_BUFF_SIZE, name); + if (udp_trans->get_buff_size<Opt>() < MIN_SOCK_BUFF_SIZE){ + std::cerr << boost::format( + "Warning: the %s buffer size is smaller than the recommended size of %d bytes.\n" + " See the USRP2 application notes on buffer resizing." + ) % name % MIN_SOCK_BUFF_SIZE << std::endl; + } } } diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 83e98904e..66a1a57f6 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -200,7 +200,7 @@ private: //send and recv usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); UHD_ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE); - return T(ntohl(out_data.data.poke_args.data)); + return T(ntohl(in_data.data.poke_args.data)); } }; |