summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2015-01-27 11:42:52 +0100
committerMartin Braun <martin.braun@ettus.com>2015-02-03 18:30:41 +0100
commitec2d27866933d4ec9f361d0b794f208ce0a7b2ad (patch)
tree24cb5acc7f55c7635752ba06ba8430fa0ca22fbe /gr-uhd
parentc815a018b9ee2e072239f900f1eb08000c18194d (diff)
uhd: Added set_stream_args() method to sink & source
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/include/gnuradio/uhd/usrp_sink.h17
-rw-r--r--gr-uhd/include/gnuradio/uhd/usrp_source.h17
-rw-r--r--gr-uhd/lib/usrp_common.h15
-rw-r--r--gr-uhd/lib/usrp_sink_impl.cc12
-rw-r--r--gr-uhd/lib/usrp_sink_impl.h3
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc13
-rw-r--r--gr-uhd/lib/usrp_source_impl.h1
7 files changed, 74 insertions, 4 deletions
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_sink.h b/gr-uhd/include/gnuradio/uhd/usrp_sink.h
index affdfbf9d2..dd1bd6a73a 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_sink.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_sink.h
@@ -570,6 +570,23 @@ namespace gr {
virtual void set_user_register(const uint8_t addr,
const uint32_t data,
size_t mboard = 0) = 0;
+
+ /*!
+ * Update the stream args for this device.
+ *
+ * This update will only take effect after a restart of the
+ * streaming, or before streaming and after construction.
+ * This will also delete the current streamer.
+ * Note you cannot change the I/O signature of this block using
+ * this function, or it will throw.
+ *
+ * It is possible to leave the 'channels' fields of \p stream_args
+ * unset. In this case, the previous channels field is used.
+ *
+ * \param stream_args New stream args.
+ * \throws std::runtime_error if new settings are invalid.
+ */
+ virtual void set_stream_args(const ::uhd::stream_args_t &stream_args) = 0;
};
} /* namespace uhd */
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h b/gr-uhd/include/gnuradio/uhd/usrp_source.h
index 478c875aaa..61f63bdf3b 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_source.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h
@@ -567,6 +567,23 @@ namespace gr {
size_t mboard = 0) = 0;
/*!
+ * Update the stream args for this device.
+ *
+ * This update will only take effect after a restart of the
+ * streaming, or before streaming and after construction.
+ * This will also delete the current streamer.
+ * Note you cannot change the I/O signature of this block using
+ * this function, or it will throw.
+ *
+ * It is possible to leave the 'channels' fields of \p stream_args
+ * unset. In this case, the previous channels field is used.
+ *
+ * \param stream_args New stream args.
+ * \throws std::runtime_error if new settings are invalid.
+ */
+ virtual void set_stream_args(const ::uhd::stream_args_t &stream_args) = 0;
+
+ /*!
* Convenience function for finite data acquisition.
* This is not to be used with the scheduler; rather,
* one can request samples from the USRP in python.
diff --git a/gr-uhd/lib/usrp_common.h b/gr-uhd/lib/usrp_common.h
index 29caa585cf..41f443922c 100644
--- a/gr-uhd/lib/usrp_common.h
+++ b/gr-uhd/lib/usrp_common.h
@@ -180,9 +180,22 @@ namespace gr {
return true;
}
+ void _update_stream_args(const ::uhd::stream_args_t &stream_args_)
+ {
+ ::uhd::stream_args_t stream_args(stream_args_);
+ if (stream_args.channels.empty()) {
+ stream_args.channels = _stream_args.channels;
+ }
+ if (stream_args.cpu_format != _stream_args.cpu_format ||
+ stream_args.channels.size() != _stream_args.channels.size()) {
+ throw std::runtime_error("Cannot change I/O signatures while updating stream args!");
+ }
+ _stream_args = stream_args;
+ }
+
//! Shared pointer to the underlying multi_usrp object
::uhd::usrp::multi_usrp::sptr _dev;
- const ::uhd::stream_args_t _stream_args;
+ ::uhd::stream_args_t _stream_args;
boost::shared_ptr< ::uhd::io_type_t > _type;
//! Number of channels (i.e. number of in- or outputs)
size_t _nchan;
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index dccab65c22..60f0a3997e 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2010-2013 Free Software Foundation, Inc.
+ * Copyright 2010-2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -546,6 +546,16 @@ namespace gr {
#endif
}
+ void
+ usrp_sink_impl::set_stream_args(const ::uhd::stream_args_t &stream_args)
+ {
+ _update_stream_args(stream_args);
+#ifdef GR_UHD_USE_STREAM_API
+ _tx_stream.reset();
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
/***********************************************************************
* Work
diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h
index 0cc7f59af0..e0cb5a9a60 100644
--- a/gr-uhd/lib/usrp_sink_impl.h
+++ b/gr-uhd/lib/usrp_sink_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2010-2014 Free Software Foundation, Inc.
+ * Copyright 2010-2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -113,6 +113,7 @@ namespace gr {
void set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard);
void clear_command_time(size_t mboard);
void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard);
+ void set_stream_args(const ::uhd::stream_args_t &stream_args);
void set_start_time(const ::uhd::time_spec_t &time);
bool start(void);
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index c3b67533b5..b3eca9eb46 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2010-2013 Free Software Foundation, Inc.
+ * Copyright 2010-2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -522,6 +522,17 @@ namespace gr {
}
void
+ usrp_source_impl::set_stream_args(const ::uhd::stream_args_t &stream_args)
+ {
+ _update_stream_args(stream_args);
+#ifdef GR_UHD_USE_STREAM_API
+ _rx_stream.reset();
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
usrp_source_impl::set_start_time(const ::uhd::time_spec_t &time)
{
_start_time = time;
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index c4a96aab42..d5bd2f4149 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -113,6 +113,7 @@ namespace gr {
void set_time_unknown_pps(const ::uhd::time_spec_t &time_spec);
void set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard);
void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard);
+ void set_stream_args(const ::uhd::stream_args_t &stream_args);
void set_start_time(const ::uhd::time_spec_t &time);
void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd);