diff options
| -rw-r--r-- | host/include/uhd/device.hpp | 4 | ||||
| -rw-r--r-- | host/lib/transport/convert_types.cpp | 9 | ||||
| -rw-r--r-- | host/lib/transport/vrt_packet_handler.hpp | 26 | 
3 files changed, 21 insertions, 18 deletions
| diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index 27b461184..d3e9015c4 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -120,7 +120,7 @@ public:          const boost::asio::const_buffer &buff,          const tx_metadata_t &metadata,          const io_type_t &io_type, -        send_mode_t send_mode = SEND_MODE_ONE_PACKET +        send_mode_t send_mode      ) = 0;      /*! @@ -159,7 +159,7 @@ public:          const boost::asio::mutable_buffer &buff,          rx_metadata_t &metadata,          const io_type_t &io_type, -        recv_mode_t recv_mode = RECV_MODE_ONE_PACKET +        recv_mode_t recv_mode      ) = 0;      /*! diff --git a/host/lib/transport/convert_types.cpp b/host/lib/transport/convert_types.cpp index 510d39454..43503025a 100644 --- a/host/lib/transport/convert_types.cpp +++ b/host/lib/transport/convert_types.cpp @@ -15,6 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // +#include <uhd/config.hpp>  #include <uhd/transport/convert_types.hpp>  #include <uhd/utils/assert.hpp>  #include <boost/asio.hpp> //endianness conversion @@ -49,7 +50,7 @@ static const bool is_big_endian = true;  static const bool is_big_endian = false;  #endif -static inline void host_floats_to_usrp2_items( +static UHD_INLINE void host_floats_to_usrp2_items(      boost::uint32_t *usrp2_items,      const fc32_t *host_floats,      size_t num_samps @@ -62,7 +63,7 @@ static inline void host_floats_to_usrp2_items(      unrolled_loop(host_floats_to_usrp2_items_i, num_samps);  } -static inline void usrp2_items_to_host_floats( +static UHD_INLINE void usrp2_items_to_host_floats(      fc32_t *host_floats,      const boost::uint32_t *usrp2_items,      size_t num_samps @@ -76,7 +77,7 @@ static inline void usrp2_items_to_host_floats(      unrolled_loop(usrp2_items_to_host_floats_i, num_samps);  } -static inline void host_items_to_usrp2_items( +static UHD_INLINE void host_items_to_usrp2_items(      boost::uint32_t *usrp2_items,      const boost::uint32_t *host_items,      size_t num_samps @@ -90,7 +91,7 @@ static inline void host_items_to_usrp2_items(      }  } -static inline void usrp2_items_to_host_items( +static UHD_INLINE void usrp2_items_to_host_items(      boost::uint32_t *host_items,      const boost::uint32_t *usrp2_items,      size_t num_samps diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index 5b73c82bf..2a7f995a1 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -193,22 +193,24 @@ namespace vrt_packet_handler{          ////////////////////////////////////////////////////////////////          case uhd::device::RECV_MODE_FULL_BUFF:{          //////////////////////////////////////////////////////////////// -            size_t num_samps = 0; +            size_t accum_num_samps = 0;              uhd::rx_metadata_t tmp_md; -            while(num_samps < total_num_samps){ -                num_samps += _recv1( +            while(accum_num_samps < total_num_samps){ +                size_t num_samps = _recv1(                      state, -                    boost::asio::buffer_cast<boost::uint8_t *>(buff) + (num_samps*io_type.size), -                    total_num_samps - num_samps, -                    (num_samps == 0)? metadata : tmp_md, //only the first metadata gets kept +                    boost::asio::buffer_cast<boost::uint8_t *>(buff) + (accum_num_samps*io_type.size), +                    total_num_samps - accum_num_samps, +                    (accum_num_samps == 0)? metadata : tmp_md, //only the first metadata gets kept                      io_type, otw_type,                      tick_rate,                      zc_iface,                      vrt_header_offset_words32,                      recv_cb                  ); +                if (num_samps == 0) break; //had a recv timeout or error, break loop +                accum_num_samps += num_samps;              } -            return total_num_samps; +            return accum_num_samps;          }          default: throw std::runtime_error("unknown recv mode"); @@ -298,6 +300,7 @@ namespace vrt_packet_handler{          const send_cb_t& send_cb = &send_cb_nop      ){          const size_t total_num_samps = boost::asio::buffer_size(buff)/io_type.size; +        if (total_num_samps <= max_samples_per_packet) send_mode = uhd::device::SEND_MODE_ONE_PACKET;          switch(send_mode){          //////////////////////////////////////////////////////////////// @@ -322,7 +325,6 @@ namespace vrt_packet_handler{          case uhd::device::SEND_MODE_FULL_BUFF:{          ////////////////////////////////////////////////////////////////              //calculate constants for fragmentation -            const size_t final_packet_samps = total_num_samps%max_samples_per_packet;              const size_t num_fragments = (total_num_samps+max_samples_per_packet-1)/max_samples_per_packet;              static const size_t first_fragment_index = 0;              const size_t final_fragment_index = num_fragments-1; @@ -334,15 +336,15 @@ namespace vrt_packet_handler{              for (size_t n = first_fragment_index; n <= final_fragment_index; n++){                  //calculate new flags for the fragments -                md.has_time_spec  = md.has_time_spec  and (n == first_fragment_index); -                md.start_of_burst = md.start_of_burst and (n == first_fragment_index); -                md.end_of_burst   = md.end_of_burst   and (n == final_fragment_index); +                md.has_time_spec  = metadata.has_time_spec  and (n == first_fragment_index); +                md.start_of_burst = metadata.start_of_burst and (n == first_fragment_index); +                md.end_of_burst   = metadata.end_of_burst   and (n == final_fragment_index);                  //send the fragment with the helper function                  _send1(                      state,                      boost::asio::buffer_cast<const boost::uint8_t *>(buff) + (n*max_samples_per_packet*io_type.size), -                    (n == final_fragment_index)?final_packet_samps:max_samples_per_packet, +                    (n == final_fragment_index)?(total_num_samps%max_samples_per_packet):max_samples_per_packet,                      md,                      io_type, otw_type,                      tick_rate, | 
