diff options
author | Tom Rondeau <trondeau@vt.edu> | 2012-09-06 12:01:23 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2012-09-06 12:01:23 -0400 |
commit | c9dc582402d2551ead29a60256fdf64a1d43534c (patch) | |
tree | 4e9fe56c173a8e080c84c4c113a5ac5c5f1c236c /gr-uhd/lib | |
parent | 1300d48af4752037feac4fae7c3c64187cc0a5a8 (diff) | |
parent | a4e2e8a9a2c8a6bbd6d676a17b0e2732e11af09f (diff) |
Merge branch 'master' into gr_log
Conflicts:
CMakeLists.txt
cmake/Modules/GrMiscUtils.cmake
docs/doxygen/other/build_guide.dox
gnuradio-core/CMakeLists.txt
gr-digital/lib/CMakeLists.txt
Diffstat (limited to 'gr-uhd/lib')
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_source.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 8aa9654015..ad4cb4d81c 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -24,10 +24,13 @@ #include <stdexcept> #include <iostream> #include <boost/format.hpp> +#include <boost/thread/thread.hpp> #include <boost/make_shared.hpp> #include "gr_uhd_common.h" static const pmt::pmt_t TIME_KEY = pmt::pmt_string_to_symbol("rx_time"); +static const pmt::pmt_t RATE_KEY = pmt::pmt_string_to_symbol("rx_rate"); +static const pmt::pmt_t FREQ_KEY = pmt::pmt_string_to_symbol("rx_freq"); #include <uhd/convert.hpp> inline gr_io_signature_sptr args_to_io_sig(const uhd::stream_args_t &args){ @@ -88,6 +91,8 @@ public: void set_samp_rate(double rate){ _dev->set_rx_rate(rate); + _samp_rate = this->get_samp_rate(); + _tag_now = true; } double get_samp_rate(void){ @@ -105,7 +110,10 @@ public: uhd::tune_result_t set_center_freq( const uhd::tune_request_t tune_request, size_t chan ){ - return _dev->set_rx_freq(tune_request, chan); + const uhd::tune_result_t res = _dev->set_rx_freq(tune_request, chan); + _center_freq = this->get_center_freq(chan); + _tag_now = true; + return res; } double get_center_freq(size_t chan){ @@ -330,9 +338,10 @@ public: //If receive resulted in a timeout condition: //We now receive a single packet with a large timeout. - if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){ + while (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){ + if (boost::this_thread::interruption_requested()) return WORK_DONE; num_samps = _rx_stream->recv( - output_items, noutput_items, _metadata, 1.0, true/*one pkt*/ + output_items, noutput_items, _metadata, 0.1, true/*one pkt*/ ); } #else @@ -358,9 +367,11 @@ public: pmt::pmt_from_uint64(_metadata.time_spec.get_full_secs()), pmt::pmt_from_double(_metadata.time_spec.get_frac_secs()) ); - //create a timestamp tag for each channel + //create a tag set for each channel for (size_t i = 0; i < _nchan; i++){ this->add_item_tag(i, nitems_written(0), TIME_KEY, val, _id); + this->add_item_tag(i, nitems_written(0), RATE_KEY, pmt::pmt_from_double(_samp_rate), _id); + this->add_item_tag(i, nitems_written(0), FREQ_KEY, pmt::pmt_from_double(_center_freq), _id); } } break; @@ -508,6 +519,10 @@ private: uhd::time_spec_t _start_time; bool _start_time_set; + + //tag shadows + double _samp_rate; + double _center_freq; }; |