From d7317dac9360f26444da4043ca066a46749917b3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 09:21:04 -0800 Subject: udp: added polling alternative to select for mac --- host/lib/transport/udp_simple.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'host') 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)*/ } /*********************************************************************** -- cgit v1.2.3 From 8e8c93a268e8e8eec268a5c829f360154ff9d7d0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 09:54:56 -0800 Subject: uhd: git diff --- host/test/convert_types_test.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'host') 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 const void * pod2ptr(const T &pod){ return boost::asio::buffer_cast(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)); } } -- cgit v1.2.3