diff options
-rw-r--r-- | gr-uhd/lib/uhd_single_usrp_source.cc | 66 |
1 files changed, 15 insertions, 51 deletions
diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index c33c8c0b0..907e8be54 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -24,16 +24,13 @@ #include <stdexcept> #include <iostream> #include <boost/format.hpp> -#include <gr_tag_info.h> /*********************************************************************** * UHD Single USRP Source **********************************************************************/ uhd_single_usrp_source::uhd_single_usrp_source(gr_io_signature_sptr sig) - :gr_sync_block("uhd single_usrp source", gr_make_io_signature(0, 0, 0), sig) -{ - d_num_packet_samps = 0; - d_tstamp_pair = pmt::mp(pmt::mp(0), pmt::mp(0)); +:gr_sync_block("uhd single_usrp source", gr_make_io_signature(0, 0, 0), sig){ + /* NOP */ } /*********************************************************************** @@ -52,8 +49,6 @@ public: _type(io_type) { _dev = uhd::usrp::single_usrp::make(device_addr); - - d_tag_srcid = pmt::mp("uhd_single_usrp_source"); } void set_subdev_spec(const std::string &spec){ @@ -136,55 +131,25 @@ public: ){ uhd::rx_metadata_t metadata; //not passed out of this block - size_t total_samps = 0; - while(total_samps + 362 < (size_t)noutput_items) { - size_t num_samps = _dev->get_device()->recv( - output_items, noutput_items, metadata, - //_type, uhd::device::RECV_MODE_FULL_BUFF - _type, uhd::device::RECV_MODE_ONE_PACKET - ); - total_samps += num_samps; - - switch(metadata.error_code){ - case uhd::rx_metadata_t::ERROR_CODE_NONE: - //keep track of the number of accumulated samples in this packet - if (metadata.fragment_offset == 0) { - d_num_packet_samps = 0; - d_tstamp_pair = pmt::mp(pmt::mp(metadata.time_spec.get_full_secs()), - pmt::mp(metadata.time_spec.get_frac_secs())); - } - d_num_packet_samps += num_samps; - - //don't push on to the queue until we get the final fragment - if (!metadata.more_fragments) { - // Create tags with time and num samples - pmt::pmt_t tsamp, nsamp; - pmt::pmt_t nsamp_val = pmt::mp((int)d_num_packet_samps); - - add_item_tag(0, nitems_written(0), - //gr_tags::key_time, - pmt::pmt_string_to_symbol("time"), - d_tstamp_pair, - d_tag_srcid); - add_item_tag(0, nitems_written(0), - pmt::mp("num_packet_samples"), - nsamp_val, - d_tag_srcid); - } - return num_samps; - - case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: + 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: + + default: std::cout << boost::format( "UHD source block got error code 0x%x" ) % metadata.error_code << std::endl; return num_samps; - } - } - return -1; + } } bool start(void){ @@ -200,7 +165,6 @@ public: private: uhd::usrp::single_usrp::sptr _dev; const uhd::io_type_t _type; - pmt::pmt_t d_tag_srcid; }; |