diff options
-rw-r--r-- | host/lib/transport/udp_simple.cpp | 13 | ||||
-rw-r--r-- | host/test/convert_types_test.cpp | 15 |
2 files changed, 22 insertions, 6 deletions
diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp index 5829b462b..6799ac7b2 100644 --- a/host/lib/transport/udp_simple.cpp +++ b/host/lib/transport/udp_simple.cpp @@ -35,6 +35,8 @@ using namespace uhd::transport; static bool wait_available( boost::asio::ip::udp::socket &socket, double timeout ){ + #if defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32) + //setup timeval for timeout timeval tv; tv.tv_sec = 0; @@ -46,6 +48,17 @@ static bool wait_available( FD_SET(socket.native(), &rset); return ::select(socket.native()+1, &rset, NULL, NULL, &tv) > 0; + + #else /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/ + + //FIXME: why does select fail on macintosh? + for (size_t i = 0; i < size_t(timeout*1e3); i++){ + if (socket.available()) return true; + boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + } + return false; + + #endif /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/ } /*********************************************************************** diff --git a/host/test/convert_types_test.cpp b/host/test/convert_types_test.cpp index 2148302b6..378e184de 100644 --- a/host/test/convert_types_test.cpp +++ b/host/test/convert_types_test.cpp @@ -38,6 +38,9 @@ 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) + /*********************************************************************** * Loopback runner: * convert input buffer into intermediate buffer @@ -130,8 +133,8 @@ static void test_convert_types_fc32( //run the loopback and test loopback(nsamps, io_type, otw_type, input, output); for (size_t i = 0; i < nsamps; i++){ - BOOST_CHECK_CLOSE_FRACTION(input[i].real(), output[i].real(), float(0.01)); - BOOST_CHECK_CLOSE_FRACTION(input[i].imag(), output[i].imag(), float(0.01)); + MY_CHECK_CLOSE(input[i].real(), output[i].real(), float(0.01)); + MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), float(0.01)); } } @@ -195,8 +198,8 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ - BOOST_CHECK_CLOSE_FRACTION(input[i].real(), output[i].real()/float(32767), float(0.01)); - BOOST_CHECK_CLOSE_FRACTION(input[i].imag(), output[i].imag()/float(32767), float(0.01)); + MY_CHECK_CLOSE(input[i].real(), output[i].real()/float(32767), float(0.01)); + MY_CHECK_CLOSE(input[i].imag(), output[i].imag()/float(32767), float(0.01)); } } @@ -236,7 +239,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){ //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ - BOOST_CHECK_CLOSE_FRACTION(input[i].real()/float(32767), output[i].real(), float(0.01)); - BOOST_CHECK_CLOSE_FRACTION(input[i].imag()/float(32767), output[i].imag(), float(0.01)); + MY_CHECK_CLOSE(input[i].real()/float(32767), output[i].real(), float(0.01)); + MY_CHECK_CLOSE(input[i].imag()/float(32767), output[i].imag(), float(0.01)); } } |