diff options
author | Niki <niki@aveer.io> | 2020-07-13 21:37:02 -0400 |
---|---|---|
committer | Martin Braun <martin@gnuradio.org> | 2021-01-24 10:57:00 -0800 |
commit | f17a453de62681141641f1da414bdbed56a2e5a9 (patch) | |
tree | 24265e90ac1801b074f2bc73658773534038e3be /gr-uhd/lib/usrp_source_impl.cc | |
parent | c40e82ae17a9dfefc95b15ab22eaf8dbf1a45d29 (diff) |
uhd: Control of frequency and gain in both directions at the same moment
It implements the ability to control frequency and gain in both
directions (Tx and Rx) with use of a single UHD source or sink - in the
same moment. It is possible to do that in separate moments with current
UHD blocks but this way it is not possible to change both Rx and Tx
settings for the same burst. Now, a single message can do that.
Note that there is a bit of an oddity here: The GNU Radio USRP blocks
are either Rx or Tx (source or sink). However, they all encapsulate an
underlying multi_usrp object. That means that under the hood, a USRP
source or a USRP sink potentially has access to the "other" direction.
This is made use in this patch.
To use this feature, add a direction key to the message dictionary going
to the block.
Signed-off-by: Martin Braun <martin@gnuradio.org>
Diffstat (limited to 'gr-uhd/lib/usrp_source_impl.cc')
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index fa910f1a9f..33edea4ab0 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -100,12 +100,13 @@ usrp_source_impl::set_center_freq(const ::uhd::tune_request_t tune_request, size ::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, ant_direction_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]); + _tx_chans_to_tune.reset(chan); + return _dev->set_tx_freq(_curr_tx_tune_req[chan], _stream_args.channels[chan]); } else { - return _dev->set_rx_freq(_curr_tune_req[chan], _stream_args.channels[chan]); + _rx_chans_to_tune.reset(chan); + return _dev->set_rx_freq(_curr_rx_tune_req[chan], _stream_args.channels[chan]); } } @@ -121,10 +122,14 @@ double usrp_source_impl::get_center_freq(size_t chan) return _dev->get_rx_freq_range(chan); } -void usrp_source_impl::set_gain(double gain, size_t chan) +void usrp_source_impl::set_gain(double gain, size_t chan, pmt::pmt_t direction) { chan = _stream_args.channels[chan]; - return _dev->set_rx_gain(gain, chan); + if (pmt::eqv(direction, ant_direction_tx())) { + return _dev->set_tx_gain(gain, chan); + } else { + return _dev->set_rx_gain(gain, chan); + } } void usrp_source_impl::set_gain(double gain, const std::string& name, size_t chan) |