diff options
author | Josh Blum <josh@joshknows.com> | 2010-06-17 22:33:32 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-06-17 22:33:32 +0000 |
commit | 2f9b6d5530df140a5a03120adc98a5ad32a69cc4 (patch) | |
tree | 9acfe34f05c8b6dc60249cae6a7287fc322c6282 /host/lib | |
parent | 19275ada864baef57f0e97e9df131e9b64f5be07 (diff) | |
download | uhd-2f9b6d5530df140a5a03120adc98a5ad32a69cc4.tar.gz uhd-2f9b6d5530df140a5a03120adc98a5ad32a69cc4.tar.bz2 uhd-2f9b6d5530df140a5a03120adc98a5ad32a69cc4.zip |
usrp-e: added verbose for bad poll and read values
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/usrp_e/io_impl.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/host/lib/usrp/usrp_e/io_impl.cpp b/host/lib/usrp/usrp_e/io_impl.cpp index 829e923b5..c168d6304 100644 --- a/host/lib/usrp/usrp_e/io_impl.cpp +++ b/host/lib/usrp/usrp_e/io_impl.cpp @@ -28,9 +28,13 @@ using namespace uhd; +/*********************************************************************** + * Constants + **********************************************************************/ static const size_t MAX_BUFF_SIZE = 2048; - static const size_t vrt_header_offset_words32 = offsetof(usrp_transfer_frame, buf)/sizeof(boost::uint32_t); +static const bool usrp_e_io_impl_verbose = true; +static const size_t recv_timeout_ms = 100; /*********************************************************************** * Data Transport (phony zero-copy with read/write) @@ -82,15 +86,28 @@ private: pollfd pfd; pfd.fd = _fd; pfd.events = POLLIN; - if (poll(&pfd, 1, 100 /*ms*/) <= 0) return 0; //timeout + ssize_t poll_ret = poll(&pfd, 1, recv_timeout_ms); + if (poll_ret <= 0){ + if (usrp_e_io_impl_verbose) std::cerr << boost::format( + "usrp-e io impl recv(): poll() returned non-positive value: %d\n" + " -> return 0 for timeout" + ) % poll_ret << std::endl; + return 0; //timeout + } //perform the blocking read(...) - ssize_t ret = read( + ssize_t read_ret = read( _fd, boost::asio::buffer_cast<void *>(buff), boost::asio::buffer_size(buff) ); - if (ret < ssize_t(sizeof(usrp_transfer_frame))) return 0; + if (read_ret < ssize_t(sizeof(usrp_transfer_frame))){ + if (usrp_e_io_impl_verbose) std::cerr << boost::format( + "usrp-e io impl recv(): read() returned small value: %d\n" + " -> return 0 for error" + ) % read_ret << std::endl; + return 0; + } //overwrite the vrt header length with the transfer frame length size_t frame_size = boost::asio::buffer_cast<usrp_transfer_frame *>(buff)->len; |