[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/09: uhd: Added set_stream_args() method
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/09: uhd: Added set_stream_args() method to sink & source |
Date: |
Wed, 4 Feb 2015 21:59:34 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit ec2d27866933d4ec9f361d0b794f208ce0a7b2ad
Author: Martin Braun <address@hidden>
Date: Tue Jan 27 11:42:52 2015 +0100
uhd: Added set_stream_args() method to sink & source
---
gr-uhd/include/gnuradio/uhd/usrp_sink.h | 17 +++++++++++++++++
gr-uhd/include/gnuradio/uhd/usrp_source.h | 17 +++++++++++++++++
gr-uhd/lib/usrp_common.h | 15 ++++++++++++++-
gr-uhd/lib/usrp_sink_impl.cc | 12 +++++++++++-
gr-uhd/lib/usrp_sink_impl.h | 3 ++-
gr-uhd/lib/usrp_source_impl.cc | 13 ++++++++++++-
gr-uhd/lib/usrp_source_impl.h | 1 +
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 affdfbf..dd1bd6a 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 478c875..61f63bd 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 29caa58..41f4439 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 dccab65..60f0a39 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 0cc7f59..e0cb5a9 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 c3b6753..b3eca9e 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 c4a96aa..d5bd2f4 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);
- [Commit-gnuradio] [gnuradio] branch master updated (c815a01 -> 42c1d6d), git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 01/09: digital: update control loop frequency limits in fll_band_edge_cc when samps_per_sym is changed, git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 03/09: runtime: possible bug fix for limited-run flowgraphs with message-only blocks., git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 05/09: Merge branch 'maint', git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 02/09: uhd: Added set_stream_args() method to sink & source,
git <=
- [Commit-gnuradio] [gnuradio] 08/09: Merge remote-tracking branch 'tom/runtime_msg_passing_finished', git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 04/09: blocks: the API for the peak_detector blocks incorrectly uses int instead of float for setting alpha., git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 07/09: Merge remote-tracking branch 'mbr0wn/uhd/stream_args', git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 09/09: Merge remote-tracking branch 'tom/blocks/peak_det_api', git, 2015/02/04
- [Commit-gnuradio] [gnuradio] 06/09: Merge remote-tracking branch 'nowls/master', git, 2015/02/04