summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
authorJosh Blum2012-06-20 13:15:01 -0700
committerJosh Blum2012-06-20 13:15:01 -0700
commite56c2c75fb656fd0663303407415c728da7526e1 (patch)
tree0419b708838c2a949dad2c20fce6acb95ebdafc2 /gr-uhd
parent1827d7faf6030f67dd482d4933fb172150ebd8a6 (diff)
downloadgnuradio-e56c2c75fb656fd0663303407415c728da7526e1.tar.gz
gnuradio-e56c2c75fb656fd0663303407415c728da7526e1.tar.bz2
gnuradio-e56c2c75fb656fd0663303407415c728da7526e1.zip
uhd: added rx tagging for changes in sample rate and center freq
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/include/gr_uhd_usrp_source.h6
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc17
2 files changed, 21 insertions, 2 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 876bf400d..ad4cb4d81 100644
--- a/gr-uhd/lib/gr_uhd_usrp_source.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_source.cc
@@ -29,6 +29,8 @@
#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){
@@ -89,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){
@@ -106,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){
@@ -360,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;
@@ -510,6 +519,10 @@ private:
uhd::time_spec_t _start_time;
bool _start_time_set;
+
+ //tag shadows
+ double _samp_rate;
+ double _center_freq;
};