summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-19 15:09:31 -0700
committerJosh Blum <josh@joshknows.com>2010-05-19 15:09:31 -0700
commitb46c5abe79dcd70cd21f7dce56f29e962237d6c9 (patch)
tree8f2c8bbeb1e1ecc5c4843ad1c2a95f5904027bd0
parentfd28cd7056867ec1ab81f7fb408c382e110ddaa1 (diff)
downloaduhd-b46c5abe79dcd70cd21f7dce56f29e962237d6c9.tar.gz
uhd-b46c5abe79dcd70cd21f7dce56f29e962237d6c9.tar.bz2
uhd-b46c5abe79dcd70cd21f7dce56f29e962237d6c9.zip
Fixed some bugs in the send and recv full buffer modes.
Dealing with samples counts, metadata flags, etc..
-rw-r--r--host/lib/transport/convert_types.cpp9
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp14
2 files changed, 12 insertions, 11 deletions
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 ab1b7e16c..2a7f995a1 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -198,8 +198,8 @@ namespace vrt_packet_handler{
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,
+ 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,
@@ -300,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){
////////////////////////////////////////////////////////////////
@@ -324,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;
@@ -336,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,