summaryrefslogtreecommitdiff
path: root/gr-uhd/lib/usrp_source_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd/lib/usrp_source_impl.cc')
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc142
1 files changed, 127 insertions, 15 deletions
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index eeb9521a5a..f0450a604d 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -31,6 +31,8 @@
namespace gr {
namespace uhd {
+ const pmt::pmt_t CMD_TAG_KEY = pmt::mp("tag");
+
usrp_source::sptr
usrp_source::make(const ::uhd::device_addr_t &device_addr,
const ::uhd::io_type_t &io_type,
@@ -53,20 +55,23 @@ namespace gr {
usrp_source::sptr
usrp_source::make(const ::uhd::device_addr_t &device_addr,
- const ::uhd::stream_args_t &stream_args)
+ const ::uhd::stream_args_t &stream_args,
+ const bool issue_stream_cmd_on_start)
{
check_abi();
return usrp_source::sptr
- (new usrp_source_impl(device_addr, stream_args_ensure(stream_args)));
+ (new usrp_source_impl(device_addr, stream_args_ensure(stream_args), issue_stream_cmd_on_start));
}
usrp_source_impl::usrp_source_impl(const ::uhd::device_addr_t &device_addr,
- const ::uhd::stream_args_t &stream_args):
+ const ::uhd::stream_args_t &stream_args,
+ const bool issue_stream_cmd_on_start):
usrp_block("gr uhd usrp source",
io_signature::make(0, 0, 0),
args_to_io_sig(stream_args)),
usrp_block_impl(device_addr, stream_args, ""),
- _tag_now(false)
+ _tag_now(false),
+ _issue_stream_cmd_on_start(issue_stream_cmd_on_start)
{
std::stringstream str;
str << name() << unique_id();
@@ -77,6 +82,7 @@ namespace gr {
#ifdef GR_UHD_USE_STREAM_API
_samps_per_packet = 1;
#endif
+ register_msg_cmd_handler(CMD_TAG_KEY, boost::bind(&usrp_source_impl::_cmd_handler_tag, this, _1));
}
usrp_source_impl::~usrp_source_impl()
@@ -275,6 +281,104 @@ namespace gr {
return _dev->get_rx_bandwidth_range(chan);
}
+ std::vector<std::string>
+ usrp_source_impl::get_lo_names(size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->get_rx_lo_names(chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ const std::string
+ usrp_source_impl::get_lo_source(const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->get_rx_lo_source(name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_lo_sources(const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->get_rx_lo_sources(name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_lo_source(const std::string &src, const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->set_rx_lo_source(src, name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ bool
+ usrp_source_impl::get_lo_export_enabled(const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->get_rx_lo_export_enabled(name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_lo_export_enabled(bool enabled, const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->set_rx_lo_export_enabled(enabled, name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::freq_range_t
+ usrp_source_impl::get_lo_freq_range(const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->get_rx_lo_freq_range(name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ double
+ usrp_source_impl::get_lo_freq(const std::string &name, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->get_rx_lo_freq(name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ double
+ usrp_source_impl::set_lo_freq(double freq, const std::string &name, size_t chan) {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+ chan = _stream_args.channels[chan];
+ return _dev->set_rx_lo_freq(freq, name, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
void
usrp_source_impl::set_auto_dc_offset(const bool enable, size_t chan)
{
@@ -356,6 +460,12 @@ namespace gr {
}
void
+ usrp_source_impl::_cmd_handler_tag(const pmt::pmt_t &tag)
+ {
+ _tag_now = true;
+ }
+
+ void
usrp_source_impl::set_start_time(const ::uhd::time_spec_t &time)
{
_start_time = time;
@@ -382,18 +492,20 @@ namespace gr {
_samps_per_packet = _rx_stream->get_max_num_samps();
}
#endif
- //setup a stream command that starts streaming slightly in the future
- static const double reasonable_delay = 0.1; //order of magnitude over RTT
- ::uhd::stream_cmd_t stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
- stream_cmd.stream_now = _stream_now;
- if(_start_time_set) {
- _start_time_set = false; //cleared for next run
- stream_cmd.time_spec = _start_time;
- }
- else {
- stream_cmd.time_spec = get_time_now() + ::uhd::time_spec_t(reasonable_delay);
+ if(_issue_stream_cmd_on_start){
+ //setup a stream command that starts streaming slightly in the future
+ static const double reasonable_delay = 0.1; //order of magnitude over RTT
+ ::uhd::stream_cmd_t stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+ stream_cmd.stream_now = _stream_now;
+ if(_start_time_set) {
+ _start_time_set = false; //cleared for next run
+ stream_cmd.time_spec = _start_time;
+ }
+ else {
+ stream_cmd.time_spec = get_time_now() + ::uhd::time_spec_t(reasonable_delay);
+ }
+ this->issue_stream_cmd(stream_cmd);
}
- this->issue_stream_cmd(stream_cmd);
_tag_now = true;
return true;
}