diff options
Diffstat (limited to 'gr-uhd/lib/gr_uhd_usrp_sink.cc')
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_sink.cc | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 05237100c..66be056df 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,13 +57,23 @@ 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); _dev = uhd::usrp::multi_usrp::make(device_addr); } + uhd::dict<std::string, std::string> get_usrp_info(size_t mboard, size_t chan){ + #ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API + return _dev->get_usrp_info(mboard, chan); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + void set_subdev_spec(const std::string &spec, size_t mboard){ return _dev->set_tx_subdev_spec(spec, mboard); } @@ -278,6 +289,15 @@ public: return _dev; } + void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API + _dev->set_user_register(addr, data, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + + /*********************************************************************** * Work **********************************************************************/ @@ -372,6 +392,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){ @@ -381,8 +407,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( @@ -423,9 +455,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; }; @@ -456,6 +492,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) ); |