summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2017-10-05 15:04:28 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2017-10-05 15:04:28 -0700
commit5a99d225cb5422b165c1af7cea484a3ad43a82a4 (patch)
tree70bf3248dcbb93f7d0e47d15348156eaad2f36d4
parent2fec31c0919d001b7b53a994fae5cf2220251545 (diff)
parent6b720a9ea43be61e210f645615392a388a0dfdd0 (diff)
Merge remote-tracking branch 'github/pr/1437'
-rw-r--r--gr-uhd/include/gnuradio/uhd/usrp_source.h27
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc12
-rw-r--r--gr-uhd/lib/usrp_source_impl.h4
3 files changed, 42 insertions, 1 deletions
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h b/gr-uhd/include/gnuradio/uhd/usrp_source.h
index a0022b3876..027202e764 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_source.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h
@@ -131,6 +131,33 @@ namespace gr {
*/
virtual void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd) = 0;
+ /*! Configure the timeout value on the UHD recv() call
+ *
+ * This is an advanced use parameter. Changing the timeout value affects
+ * the latency of this block; a high timeout value can be more optimal
+ * for high-throughput applications (e.g., 1 second) and setting it to
+ * zero will have the best latency. Changing the timeout value may also
+ * be useful for custom FPGA modifications, where traffic might not be
+ * continuously streaming.
+ * For specialized high-performance use cases, twiddling these knobs may
+ * improve performance, but changes are not generally applicable.
+ *
+ * Note that UHD's recv() call may block until the timeout is over, which
+ * means this block might also block for up to the timeout value.
+ *
+ * \param timeout Timeout parameter in seconds. Cf. the UHD manual for
+ * uhd::rx_streamer::recv() for more details. A lower
+ * value will mean lower latency, but higher CPU load.
+ * \param one_packet If true, only receive one packet at a time. Cf. the
+ * UHD manual for uhd::rx_streamer::recv() for more
+ * details. A value of true will mean lower latency,
+ * but higher CPU load.
+ */
+ virtual void set_recv_timeout(
+ const double timeout,
+ const bool one_packet=true
+ ) = 0;
+
/*!
* Returns identifying information about this USRP's configuration.
* Returns motherboard ID, name, and serial.
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index 034e8207ba..894a6d849b 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -71,6 +71,7 @@ namespace gr {
args_to_io_sig(stream_args)),
usrp_block_impl(device_addr, stream_args, ""),
_recv_timeout(0.1), // seconds
+ _recv_one_packet(true),
_tag_now(false),
_issue_stream_cmd_on_start(issue_stream_cmd_on_start)
{
@@ -499,6 +500,15 @@ namespace gr {
_tag_now = true;
}
+ void
+ usrp_source_impl::set_recv_timeout(
+ const double timeout,
+ const bool one_packet
+ ) {
+ _recv_timeout = timeout;
+ _recv_one_packet = one_packet;
+ }
+
bool
usrp_source_impl::start(void)
{
@@ -635,7 +645,7 @@ namespace gr {
noutput_items,
_metadata,
_recv_timeout,
- true /* one packet -> minimize latency */
+ _recv_one_packet
);
#else
size_t num_samps = _dev->get_device()->recv
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index 2a53159f4e..d91fcec754 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -107,6 +107,7 @@ namespace gr {
double set_lo_freq(double freq, const std::string &name, size_t chan);
void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd);
+ void set_recv_timeout(const double timeout, const bool one_packet);
void flush(void);
bool start(void);
bool stop(void);
@@ -126,7 +127,10 @@ namespace gr {
#ifdef GR_UHD_USE_STREAM_API
::uhd::rx_streamer::sptr _rx_stream;
size_t _samps_per_packet;
+ //! Timeout value for UHD's recv() call. Lower values mean lower latency.
double _recv_timeout;
+ //! one_packet value for UHD's recv() call. 'true' is lower latency.
+ bool _recv_one_packet;
#endif
bool _tag_now;
::uhd::rx_metadata_t _metadata;