From b285d23f5eba9b65f9baf799fee3f1389c132632 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 7 Jul 2010 22:55:14 +0000 Subject: usrp-e: fixed send and recv logic in io impl to deal with frame length correctly --- host/lib/usrp/usrp_e/io_impl.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/usrp_e/io_impl.cpp b/host/lib/usrp/usrp_e/io_impl.cpp index 9ebd55eac..8bcff1352 100644 --- a/host/lib/usrp/usrp_e/io_impl.cpp +++ b/host/lib/usrp/usrp_e/io_impl.cpp @@ -22,7 +22,6 @@ #include #include //read, write #include //transfer frame struct -#include //offsetof #include #include #include @@ -34,7 +33,7 @@ using namespace uhd::usrp; * Constants **********************************************************************/ static const size_t MAX_BUFF_SIZE = 2048; -static const size_t vrt_header_offset_words32 = offsetof(usrp_transfer_frame, buf)/sizeof(boost::uint32_t); +static const size_t vrt_header_offset_words32 = sizeof(usrp_transfer_frame)/sizeof(boost::uint32_t); static const bool usrp_e_io_impl_verbose = true; static const size_t recv_timeout_ms = 100; @@ -71,7 +70,7 @@ private: //and the send buffer commit method will set the length. const_cast( boost::asio::buffer_cast(buff) - )->len = boost::asio::buffer_size(buff); + )->len = boost::asio::buffer_size(buff) - sizeof(usrp_transfer_frame); return write( _fd, boost::asio::buffer_cast(buff), @@ -112,16 +111,16 @@ private: } //overwrite the vrt header length with the transfer frame length - size_t frame_size = boost::asio::buffer_cast(buff)->len; - boost::uint32_t *vrt_header = boost::asio::buffer_cast(buff) + vrt_header_offset_words32; - vrt_header[0] = (vrt_header[0] & ~0xffff) | ((frame_size/sizeof(boost::uint32_t)) & 0xffff); + usrp_transfer_frame *frame = boost::asio::buffer_cast(buff); + boost::uint32_t *vrt_header = reinterpret_cast(frame->buf); + vrt_header[0] = (vrt_header[0] & ~0xffff) | ((frame->len/sizeof(boost::uint32_t)) & 0xffff); - //std::cout << "len " << int(boost::asio::buffer_cast(buff)->len) << std::endl; + //std::cout << "len " << int(frame->len) << std::endl; //for (size_t i = 0; i < 7; i++){ // std::cout << boost::format(" 0x%08x") % boost::asio::buffer_cast(buff)[i] << std::endl; //} - return frame_size; + return read_ret; } }; @@ -230,6 +229,7 @@ size_t usrp_e_impl::recv( io_type, recv_otw_type, //input and output types to convert MASTER_CLOCK_RATE, //master clock tick rate uhd::transport::vrt::if_hdr_unpack_le, - boost::bind(get_recv_buffs, &_io_impl->transport, _1) + boost::bind(get_recv_buffs, &_io_impl->transport, _1), + vrt_header_offset_words32 ); } -- cgit v1.2.3