summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-uhd/include/gr_uhd_usrp_source.h6
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc23
2 files changed, 25 insertions, 4 deletions
diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h
index 80d80bcb8..b5acabee4 100644
--- a/gr-uhd/include/gr_uhd_usrp_source.h
+++ b/gr-uhd/include/gr_uhd_usrp_source.h
@@ -60,11 +60,17 @@ class uhd_usrp_source;
*
* The following tag keys will be produced by the work function:
* - pmt::pmt_string_to_symbol("rx_time")
+ * - pmt::pmt_string_to_symbol("rx_rate")
+ * - pmt::pmt_string_to_symbol("rx_freq")
*
* The timstamp tag value is a pmt tuple of the following:
* (uint64 seconds, and double fractional seconds).
* A timestamp tag is produced at start() and after overflows.
*
+ * The sample rate and center frequency tags are doubles,
+ * representing the sample rate in Sps and frequency in Hz.
+ * These tags are produced upon the user changing parameters.
+ *
* See the UHD manual for more detailed documentation:
* http://code.ettus.com/redmine/ettus/projects/uhd/wiki
*
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
index 8aa965401..ad4cb4d81 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;
};