summaryrefslogtreecommitdiff
path: root/gr-uhd/lib/gr_uhd_usrp_sink.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd/lib/gr_uhd_usrp_sink.cc')
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_sink.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc
index 7d173d972..7e7875898 100644
--- a/gr-uhd/lib/gr_uhd_usrp_sink.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 Free Software Foundation, Inc.
+ * Copyright 2010-2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -23,6 +23,7 @@
#include <gr_io_signature.h>
#include <stdexcept>
#include <boost/make_shared.hpp>
+#include "gr_uhd_common.h"
static const pmt::pmt_t SOB_KEY = pmt::pmt_string_to_symbol("tx_sob");
static const pmt::pmt_t EOB_KEY = pmt::pmt_string_to_symbol("tx_eob");
@@ -56,7 +57,9 @@ public:
gr_make_io_signature(0, 0, 0)
),
_stream_args(stream_args),
- _nchan(std::max<size_t>(1, stream_args.channels.size()))
+ _nchan(std::max<size_t>(1, stream_args.channels.size())),
+ _stream_now(_nchan == 1),
+ _start_time_set(false)
{
if (stream_args.cpu_format == "fc32") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_FLOAT32);
if (stream_args.cpu_format == "sc16") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_INT16);
@@ -381,6 +384,12 @@ public:
}
}
+ void set_start_time(const uhd::time_spec_t &time){
+ _start_time = time;
+ _start_time_set = true;
+ _stream_now = false;
+ }
+
//Send an empty start-of-burst packet to begin streaming.
//Set at a time in the near future to avoid late packets.
bool start(void){
@@ -390,8 +399,14 @@ public:
_metadata.start_of_burst = true;
_metadata.end_of_burst = false;
- _metadata.has_time_spec = _nchan > 1;
- _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01);
+ _metadata.has_time_spec = not _stream_now;
+ if (_start_time_set){
+ _start_time_set = false; //cleared for next run
+ _metadata.time_spec = _start_time;
+ }
+ else{
+ _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01);
+ }
#ifdef GR_UHD_USE_STREAM_API
_tx_stream->send(
@@ -432,9 +447,13 @@ private:
uhd::tx_streamer::sptr _tx_stream;
#endif
size_t _nchan;
+ bool _stream_now;
uhd::tx_metadata_t _metadata;
double _sample_rate;
+ uhd::time_spec_t _start_time;
+ bool _start_time_set;
+
//stream tags related stuff
std::vector<gr_tag_t> _tags;
};
@@ -465,6 +484,7 @@ boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
const uhd::device_addr_t &device_addr,
const uhd::stream_args_t &stream_args
){
+ gr_uhd_check_abi();
return boost::shared_ptr<uhd_usrp_sink>(
new uhd_usrp_sink_impl(device_addr, stream_args)
);