diff options
author | Niki <niki@aveer.io> | 2020-05-16 02:48:26 -0400 |
---|---|---|
committer | Martin Braun <martin@gnuradio.org> | 2021-01-17 00:46:25 -0800 |
commit | efc9ca261a68bd67f8cac1ef976fdabdf6d16ad4 (patch) | |
tree | d0073a5d77a7aa03de85cd91e69189856b7d09e6 /gr-uhd/lib/usrp_block_impl.cc | |
parent | 9fc6285d2f831e1de782e49e16c303cd54bb63a5 (diff) |
gr-uhd: Add command uhd handler for mtune ("manual tune")
This command implements uhd::tune_request_t completely (and not just a
subset). Also includes updates to the manual.
Signed-off-by: Martin Braun <martin@gnuradio.org>
Diffstat (limited to 'gr-uhd/lib/usrp_block_impl.cc')
-rw-r--r-- | gr-uhd/lib/usrp_block_impl.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gr-uhd/lib/usrp_block_impl.cc b/gr-uhd/lib/usrp_block_impl.cc index 6e664e6bd9..dcb2108994 100644 --- a/gr-uhd/lib/usrp_block_impl.cc +++ b/gr-uhd/lib/usrp_block_impl.cc @@ -56,6 +56,11 @@ const pmt::pmt_t gr::uhd::cmd_tune_key() static const pmt::pmt_t val = pmt::mp("tune"); return val; } +const pmt::pmt_t gr::uhd::cmd_mtune_key() +{ + static const pmt::pmt_t val = pmt::mp("mtune"); + return val; +} const pmt::pmt_t gr::uhd::cmd_lo_freq_key() { static const pmt::pmt_t val = pmt::mp("lo_freq"); @@ -156,6 +161,7 @@ usrp_block_impl::usrp_block_impl(const ::uhd::device_addr_t& device_addr, REGISTER_CMD_HANDLER(cmd_power_key(), _cmd_handler_power); REGISTER_CMD_HANDLER(cmd_lo_offset_key(), _cmd_handler_looffset); REGISTER_CMD_HANDLER(cmd_tune_key(), _cmd_handler_tune); + REGISTER_CMD_HANDLER(cmd_mtune_key(), _cmd_handler_mtune); REGISTER_CMD_HANDLER(cmd_lo_freq_key(), _cmd_handler_lofreq); REGISTER_CMD_HANDLER(cmd_dsp_freq_key(), _cmd_handler_dspfreq); REGISTER_CMD_HANDLER(cmd_rate_key(), _cmd_handler_rate); @@ -770,6 +776,53 @@ void usrp_block_impl::_cmd_handler_tune(const pmt::pmt_t& tune, _update_curr_tune_req(new_tune_request, chan); } +void usrp_block_impl::_cmd_handler_mtune(const pmt::pmt_t& tune, + int chan, + const pmt::pmt_t& msg) +{ + ::uhd::tune_request_t new_tune_request; + if (pmt::dict_has_key(tune, pmt::mp("dsp_freq"))) { + new_tune_request.dsp_freq = + pmt::to_double(pmt::dict_ref(tune, pmt::mp("dsp_freq"), 0)); + } + if (pmt::dict_has_key(tune, pmt::mp("rf_freq"))) { + new_tune_request.rf_freq = + pmt::to_double(pmt::dict_ref(tune, pmt::mp("rf_freq"), 0)); + } + if (pmt::dict_has_key(tune, pmt::mp("target_freq"))) { + new_tune_request.target_freq = + pmt::to_double(pmt::dict_ref(tune, pmt::mp("target_freq"), 0)); + } + if (pmt::dict_has_key(tune, pmt::mp("dsp_freq_policy"))) { + std::string policy = pmt::symbol_to_string( + pmt::dict_ref(tune, pmt::mp("dsp_freq_policy"), pmt::mp("A"))); + if (policy == "M") { + new_tune_request.dsp_freq_policy = ::uhd::tune_request_t::POLICY_MANUAL; + } else if (policy == "A") { + new_tune_request.dsp_freq_policy = ::uhd::tune_request_t::POLICY_AUTO; + } else { + new_tune_request.dsp_freq_policy = ::uhd::tune_request_t::POLICY_NONE; + } + } + if (pmt::dict_has_key(tune, pmt::mp("rf_freq_policy"))) { + std::string policy = pmt::symbol_to_string( + pmt::dict_ref(tune, pmt::mp("rf_freq_policy"), pmt::mp("A"))); + if (policy == "M") { + new_tune_request.rf_freq_policy = ::uhd::tune_request_t::POLICY_MANUAL; + } else if (policy == "A") { + new_tune_request.rf_freq_policy = ::uhd::tune_request_t::POLICY_AUTO; + } else { + new_tune_request.rf_freq_policy = ::uhd::tune_request_t::POLICY_NONE; + } + } + if (pmt::dict_has_key(tune, pmt::mp("args"))) { + new_tune_request.args = ::uhd::device_addr_t( + pmt::symbol_to_string(pmt::dict_ref(tune, pmt::mp("args"), pmt::mp("")))); + } + + _update_curr_tune_req(new_tune_request, chan); +} + void usrp_block_impl::_cmd_handler_bw(const pmt::pmt_t& bw, int chan, const pmt::pmt_t& msg) |