diff options
author | Josh Blum | 2010-09-24 16:09:38 -0700 |
---|---|---|
committer | Josh Blum | 2010-09-24 16:09:38 -0700 |
commit | d2452adf306502b1f7489f49454e8814bc84c6d4 (patch) | |
tree | 7679c293f1e80d7c3402aa4290a171d34f72f0a1 | |
parent | 1fe3790faed05b92ca4ad3a27da6eb23632d7e57 (diff) | |
download | gnuradio-d2452adf306502b1f7489f49454e8814bc84c6d4.tar.gz gnuradio-d2452adf306502b1f7489f49454e8814bc84c6d4.tar.bz2 gnuradio-d2452adf306502b1f7489f49454e8814bc84c6d4.zip |
uhd: handle error codes in uhd source blocks
-rw-r--r-- | gr-uhd/lib/uhd_simple_source.cc | 19 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_single_usrp_source.cc | 19 |
2 files changed, 36 insertions, 2 deletions
diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 2ace1da68..c1e11e85d 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -23,6 +23,8 @@ #include <uhd_simple_source.h> #include <gr_io_signature.h> #include <stdexcept> +#include <iostream> +#include <boost/format.hpp> #include "utils.h" /*********************************************************************** @@ -132,10 +134,25 @@ public: uhd::rx_metadata_t metadata; //not passed out of this block - return _dev->get_device()->recv( + size_t num_samps = _dev->get_device()->recv( output_items, noutput_items, metadata, _type, uhd::device::RECV_MODE_FULL_BUFF ); + + switch(metadata.error_code){ + case uhd::rx_metadata_t::ERROR_CODE_NONE: + return num_samps; + + case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: + //ignore overflows and try work again + return work(noutput_items, input_items, output_items); + + default: + std::cout << boost::format( + "UHD source block got error code 0x%x" + ) % metadata.error_code << std::endl; + return num_samps; + } } private: diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 5da4385b2..ff9ba0653 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -22,6 +22,8 @@ #include <uhd_single_usrp_source.h> #include <gr_io_signature.h> #include <stdexcept> +#include <iostream> +#include <boost/format.hpp> #include "utils.h" /*********************************************************************** @@ -132,10 +134,25 @@ public: uhd::rx_metadata_t metadata; //not passed out of this block - return _dev->get_device()->recv( + size_t num_samps = _dev->get_device()->recv( output_items, noutput_items, metadata, _type, uhd::device::RECV_MODE_FULL_BUFF ); + + switch(metadata.error_code){ + case uhd::rx_metadata_t::ERROR_CODE_NONE: + return num_samps; + + case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: + //ignore overflows and try work again + return work(noutput_items, input_items, output_items); + + default: + std::cout << boost::format( + "UHD source block got error code 0x%x" + ) % metadata.error_code << std::endl; + return num_samps; + } } private: |