summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/docs/CMakeLists.txt2
-rw-r--r--host/lib/transport/CMakeLists.txt2
-rw-r--r--host/lib/transport/vrt_packet_handler.hpp12
-rw-r--r--host/test/CMakeLists.txt2
-rw-r--r--host/test/convert_test.cpp (renamed from host/test/convert_types_test.cpp)85
5 files changed, 47 insertions, 56 deletions
diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt
index 592d66526..cd17b648a 100644
--- a/host/docs/CMakeLists.txt
+++ b/host/docs/CMakeLists.txt
@@ -36,7 +36,7 @@ SET(manual_sources
# Setup Manual
########################################################################
MESSAGE(STATUS "")
-FIND_PACKAGE(Docutils REQUIRED)
+FIND_PACKAGE(Docutils)
LIBUHD_REGISTER_COMPONENT("Manual" ENABLE_MANUAL ON "DOCUTILS_FOUND" OFF)
diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt
index 0d6226e4c..a929897dc 100644
--- a/host/lib/transport/CMakeLists.txt
+++ b/host/lib/transport/CMakeLists.txt
@@ -23,7 +23,7 @@
# Setup libusb
########################################################################
MESSAGE(STATUS "")
-FIND_PACKAGE(USB1 REQUIRED)
+FIND_PACKAGE(USB1)
LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF)
diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp
index 278bcfeaa..dc29d1ae5 100644
--- a/host/lib/transport/vrt_packet_handler.hpp
+++ b/host/lib/transport/vrt_packet_handler.hpp
@@ -26,7 +26,7 @@
#include <uhd/types/otw_type.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
-#include <uhd/transport/convert_types.hpp>
+#include <uhd/convert.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <boost/function.hpp>
#include <stdexcept>
@@ -198,8 +198,9 @@ template <typename T> UHD_INLINE T get_context_code(
}
//copy-convert the samples from the recv buffer
- uhd::transport::convert_otw_type_to_io_type(
- state.copy_buffs[i], otw_type, io_buffs, io_type, nsamps_to_copy_per_io_buff
+ uhd::convert::input_type otw_buffs(1, state.copy_buffs[i]);
+ uhd::convert::otw_type_to_io_type(
+ io_type, otw_type, otw_buffs, io_buffs, nsamps_to_copy_per_io_buff
);
//update the rx copy buffer to reflect the bytes copied
@@ -337,8 +338,9 @@ template <typename T> UHD_INLINE T get_context_code(
otw_mem += if_packet_info.num_header_words32;
//copy-convert the samples into the send buffer
- uhd::transport::convert_io_type_to_otw_type(
- io_buffs, io_type, otw_mem, otw_type, num_samps
+ uhd::convert::output_type otw_buffs(1, otw_mem);
+ uhd::convert::io_type_to_otw_type(
+ io_type, otw_type, io_buffs, otw_buffs, num_samps
);
//commit the samples to the zero-copy interface
diff --git a/host/test/CMakeLists.txt b/host/test/CMakeLists.txt
index bdbde4b2c..581799d98 100644
--- a/host/test/CMakeLists.txt
+++ b/host/test/CMakeLists.txt
@@ -22,7 +22,7 @@ SET(test_sources
addr_test.cpp
buffer_test.cpp
byteswap_test.cpp
- convert_types_test.cpp
+ convert_test.cpp
dict_test.cpp
error_test.cpp
gain_group_test.cpp
diff --git a/host/test/convert_types_test.cpp b/host/test/convert_test.cpp
index 378e184de..de0245c1d 100644
--- a/host/test/convert_types_test.cpp
+++ b/host/test/convert_test.cpp
@@ -15,14 +15,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include <uhd/transport/convert_types.hpp>
+#include <uhd/convert.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp>
#include <boost/cstdint.hpp>
-#include <boost/asio/buffer.hpp>
#include <complex>
#include <vector>
#include <cstdlib>
+#include <iostream>
using namespace uhd;
@@ -30,14 +30,6 @@ using namespace uhd;
typedef std::complex<boost::int16_t> sc16_t;
typedef std::complex<float> fc32_t;
-//extract pointer to POD since using &vector.front() throws in MSVC
-template <typename T> void * pod2ptr(T &pod){
- return boost::asio::buffer_cast<void *>(boost::asio::buffer(pod));
-}
-template <typename T> const void * pod2ptr(const T &pod){
- return boost::asio::buffer_cast<const void *>(boost::asio::buffer(pod));
-}
-
#define MY_CHECK_CLOSE(a, b, f) if ((std::abs(a) > (f) and std::abs(b) > (f))) \
BOOST_CHECK_CLOSE_FRACTION(a, b, f)
@@ -54,20 +46,19 @@ template <typename Range> static void loopback(
Range &output
){
//item32 is largest device type
- std::vector<boost::uint32_t> dev(nsamps);
+ std::vector<boost::uint32_t> interm(nsamps);
- //convert to dev type
- transport::convert_io_type_to_otw_type(
- pod2ptr(input), io_type,
- pod2ptr(dev), otw_type,
- nsamps
+ convert::input_type input0(1, &input[0]), input1(1, &interm[0]);
+ convert::output_type output0(1, &interm[0]), output1(1, &output[0]);
+
+ //convert to intermediate type
+ convert::io_type_to_otw_type(
+ io_type, otw_type, input0, output0, nsamps
);
//convert back to host type
- transport::convert_otw_type_to_io_type(
- pod2ptr(dev), otw_type,
- pod2ptr(output), io_type,
- nsamps
+ convert::otw_type_to_io_type(
+ io_type, otw_type, input1, output1, nsamps
);
}
@@ -98,7 +89,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_sc16(nsamps, io_type, otw_type);
}
}
@@ -110,7 +101,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_sc16(nsamps, io_type, otw_type);
}
}
@@ -145,7 +136,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_fc32(nsamps, io_type, otw_type);
}
}
@@ -157,7 +148,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32){
otw_type.width = 16;
//try various lengths to test edge cases
- for (size_t nsamps = 0; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++){
test_convert_types_fc32(nsamps, io_type, otw_type);
}
}
@@ -179,21 +170,20 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){
(std::rand()/float(RAND_MAX/2)) - 1,
(std::rand()/float(RAND_MAX/2)) - 1
);
+ std::vector<boost::uint32_t> interm(nsamps);
+ std::vector<sc16_t> output(nsamps);
- //convert float to dev
- std::vector<boost::uint32_t> tmp(nsamps);
- transport::convert_io_type_to_otw_type(
- pod2ptr(input), io_type_in,
- pod2ptr(tmp), otw_type,
- nsamps
+ convert::input_type input0(1, &input[0]), input1(1, &interm[0]);
+ convert::output_type output0(1, &interm[0]), output1(1, &output[0]);
+
+ //convert float to intermediate
+ convert::io_type_to_otw_type(
+ io_type_in, otw_type, input0, output0, nsamps
);
- //convert dev to short
- std::vector<sc16_t> output(nsamps);
- transport::convert_otw_type_to_io_type(
- pod2ptr(tmp), otw_type,
- pod2ptr(output), io_type_out,
- nsamps
+ //convert intermediate to short
+ convert::otw_type_to_io_type(
+ io_type_out, otw_type, input1, output1, nsamps
);
//test that the inputs and outputs match
@@ -220,21 +210,20 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){
std::rand()-(RAND_MAX/2),
std::rand()-(RAND_MAX/2)
);
+ std::vector<boost::uint32_t> interm(nsamps);
+ std::vector<fc32_t> output(nsamps);
- //convert short to dev
- std::vector<boost::uint32_t> tmp(nsamps);
- transport::convert_io_type_to_otw_type(
- pod2ptr(input), io_type_in,
- pod2ptr(tmp), otw_type,
- nsamps
+ convert::input_type input0(1, &input[0]), input1(1, &interm[0]);
+ convert::output_type output0(1, &interm[0]), output1(1, &output[0]);
+
+ //convert short to intermediate
+ convert::io_type_to_otw_type(
+ io_type_in, otw_type, input0, output0, nsamps
);
- //convert dev to float
- std::vector<fc32_t> output(nsamps);
- transport::convert_otw_type_to_io_type(
- pod2ptr(tmp), otw_type,
- pod2ptr(output), io_type_out,
- nsamps
+ //convert intermediate to float
+ convert::otw_type_to_io_type(
+ io_type_out, otw_type, input1, output1, nsamps
);
//test that the inputs and outputs match