summaryrefslogtreecommitdiff
path: root/gr-uhd/lib
diff options
context:
space:
mode:
authorJacob Gilbert <mrjacobagilbert@gmail.com>2017-09-12 13:36:34 -0700
committerJacob Gilbert <mrjacobagilbert@gmail.com>2017-09-12 13:36:34 -0700
commitcfb6e49e33d7f664268000e312367d091a60b9c3 (patch)
treeab10f5c49462e79fb2c6fc02fb26856dbe32d361 /gr-uhd/lib
parent811bee8c54bdca5c53c2ccbc6ef6d1bbca55eaae (diff)
gr-uhd: Added modification to UHD message-based tuning which will allow for timed tune command order to be ensured across TX/RX by enabling tuning of RX path from the sink block or TX path from source block. Doxygen also updated to reflect the new command.
Diffstat (limited to 'gr-uhd/lib')
-rw-r--r--gr-uhd/lib/usrp_block_impl.cc16
-rw-r--r--gr-uhd/lib/usrp_block_impl.h12
-rw-r--r--gr-uhd/lib/usrp_sink_impl.cc12
-rw-r--r--gr-uhd/lib/usrp_sink_impl.h2
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc14
-rw-r--r--gr-uhd/lib/usrp_source_impl.h2
6 files changed, 38 insertions, 20 deletions
diff --git a/gr-uhd/lib/usrp_block_impl.cc b/gr-uhd/lib/usrp_block_impl.cc
index 7f3478c1a5..803cfd71ec 100644
--- a/gr-uhd/lib/usrp_block_impl.cc
+++ b/gr-uhd/lib/usrp_block_impl.cc
@@ -39,6 +39,7 @@ const pmt::pmt_t CMD_BANDWIDTH_KEY = pmt::mp("bandwidth");
const pmt::pmt_t CMD_TIME_KEY = pmt::mp("time");
const pmt::pmt_t CMD_MBOARD_KEY = pmt::mp("mboard");
const pmt::pmt_t CMD_ANTENNA_KEY = pmt::mp("antenna");
+const pmt::pmt_t CMD_DIRECTION_KEY = pmt::mp("direction");
/**********************************************************************
@@ -209,11 +210,11 @@ bool usrp_block_impl::_check_mboard_sensors_locked()
}
void
-usrp_block_impl::_set_center_freq_from_internals_allchans()
+usrp_block_impl::_set_center_freq_from_internals_allchans(pmt::pmt_t direction)
{
while (_chans_to_tune.any()) {
// This resets() bits, so this loop should not run indefinitely
- _set_center_freq_from_internals(_chans_to_tune.find_first());
+ _set_center_freq_from_internals(_chans_to_tune.find_first(), direction);
}
}
@@ -539,8 +540,14 @@ void usrp_block_impl::msg_handler_command(pmt::pmt_t msg)
}
}
- /// 4) Check if we need to re-tune
- _set_center_freq_from_internals_allchans();
+ /// 4) See if a direction was specified
+ pmt::pmt_t direction = pmt::dict_ref(
+ msg, CMD_DIRECTION_KEY,
+ pmt::PMT_NIL // Anything except "TX" or "RX will default to the messaged block direction"
+ );
+
+ /// 5) Check if we need to re-tune
+ _set_center_freq_from_internals_allchans(direction);
}
@@ -699,4 +706,3 @@ void usrp_block_impl::_cmd_handler_dspfreq(const pmt::pmt_t &dspfreq, int chan,
_update_curr_tune_req(new_tune_request, chan);
}
-
diff --git a/gr-uhd/lib/usrp_block_impl.h b/gr-uhd/lib/usrp_block_impl.h
index a1bbf97826..6b097505e1 100644
--- a/gr-uhd/lib/usrp_block_impl.h
+++ b/gr-uhd/lib/usrp_block_impl.h
@@ -29,13 +29,6 @@
#include <boost/dynamic_bitset.hpp>
#include <boost/bind.hpp>
-#define SET_CENTER_FREQ_FROM_INTERNALS(usrp_class, tune_method) \
- ::uhd::tune_result_t \
- usrp_class::_set_center_freq_from_internals(size_t chan) \
- { \
- _chans_to_tune.reset(chan); \
- return _dev->tune_method(_curr_tune_req[chan], _stream_args.channels[chan]); \
- }
namespace gr {
namespace uhd {
@@ -213,10 +206,10 @@ namespace gr {
}
//! Like set_center_freq(), but uses _curr_freq and _curr_lo_offset
- virtual ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan) = 0;
+ virtual ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan, pmt::pmt_t direction) = 0;
//! Calls _set_center_freq_from_internals() on all channels
- void _set_center_freq_from_internals_allchans();
+ void _set_center_freq_from_internals_allchans(pmt::pmt_t direction);
/**********************************************************************
* Members
@@ -247,4 +240,3 @@ namespace gr {
} /* namespace gr */
#endif /* INCLUDED_GR_UHD_BLOCK_IMPL_H */
-
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index 2d347e3823..117b6e0a7d 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -135,7 +135,17 @@ namespace gr {
return _dev->set_tx_freq(tune_request, chan);
}
- SET_CENTER_FREQ_FROM_INTERNALS(usrp_sink_impl, set_tx_freq);
+ ::uhd::tune_result_t
+ usrp_sink_impl::_set_center_freq_from_internals(size_t chan, pmt::pmt_t direction)
+ {
+ _chans_to_tune.reset(chan);
+ if (pmt::eqv(direction, pmt::mp("RX"))) {
+ // TODO: what happens if the RX device is not instantiated? Catch error?
+ return _dev->set_rx_freq(_curr_tune_req[chan], _stream_args.channels[chan]);
+ } else {
+ return _dev->set_tx_freq(_curr_tune_req[chan], _stream_args.channels[chan]);
+ }
+ }
double
usrp_sink_impl::get_center_freq(size_t chan)
diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h
index d509baef90..f46d57cc0c 100644
--- a/gr-uhd/lib/usrp_sink_impl.h
+++ b/gr-uhd/lib/usrp_sink_impl.h
@@ -107,7 +107,7 @@ namespace gr {
private:
//! Like set_center_freq(), but uses _curr_freq and _curr_lo_offset
- ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan);
+ ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan, pmt::pmt_t direction);
#ifdef GR_UHD_USE_STREAM_API
::uhd::tx_streamer::sptr _tx_stream;
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index 23b94c684f..034e8207ba 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -149,7 +149,17 @@ namespace gr {
return res;
}
- SET_CENTER_FREQ_FROM_INTERNALS(usrp_source_impl, set_rx_freq);
+ ::uhd::tune_result_t
+ usrp_source_impl::_set_center_freq_from_internals(size_t chan, pmt::pmt_t direction)
+ {
+ _chans_to_tune.reset(chan);
+ if (pmt::eqv(direction, pmt::mp("TX"))) {
+ // TODO: what happens if the TX device is not instantiated? Catch error?
+ return _dev->set_tx_freq(_curr_tune_req[chan], _stream_args.channels[chan]);
+ } else {
+ return _dev->set_rx_freq(_curr_tune_req[chan], _stream_args.channels[chan]);
+ }
+ }
double
usrp_source_impl::get_center_freq(size_t chan)
@@ -534,7 +544,7 @@ namespace gr {
_rx_stream->recv(outputs, nbytes/bpi, _metadata, 0.0);
else
// no rx streamer -- nothing to flush
- break;
+ break;
#else
_dev->get_device()->recv
(outputs, nbytes/_type->size, _metadata, *_type,
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index 7ee5a138d4..2a53159f4e 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -120,7 +120,7 @@ namespace gr {
private:
//! Like set_center_freq(), but uses _curr_freq and _curr_lo_offset
- ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan);
+ ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan, pmt::pmt_t direction);
void _cmd_handler_tag(const pmt::pmt_t &tag);
#ifdef GR_UHD_USE_STREAM_API