diff options
author | Martin Braun <martin.braun@ettus.com> | 2016-09-23 18:31:41 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-09-24 16:32:37 -0700 |
commit | 32566b9238c2a35fbb04d3b0e2e33d5860caa317 (patch) | |
tree | ed597b7a6d7b5936628b629759c11b604464e62d | |
parent | cb6386b2378ce269fb17970a800aafb38df86215 (diff) |
uhd: Updated minimum version to 3.5.5 and removed deprecated code
-rw-r--r-- | gr-uhd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-uhd/include/gnuradio/uhd/usrp_sink.h | 35 | ||||
-rw-r--r-- | gr-uhd/include/gnuradio/uhd/usrp_source.h | 35 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_block_impl.cc | 38 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_block_impl.h | 2 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_sink_impl.cc | 73 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_sink_impl.h | 12 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.cc | 77 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.h | 12 |
9 files changed, 19 insertions, 267 deletions
diff --git a/gr-uhd/CMakeLists.txt b/gr-uhd/CMakeLists.txt index cb4fda82af..f6d956c1e1 100644 --- a/gr-uhd/CMakeLists.txt +++ b/gr-uhd/CMakeLists.txt @@ -22,7 +22,7 @@ ######################################################################## include(GrBoost) -find_package(UHD) +find_package(UHD "3.5.5") ######################################################################## # Register component diff --git a/gr-uhd/include/gnuradio/uhd/usrp_sink.h b/gr-uhd/include/gnuradio/uhd/usrp_sink.h index 4ccb83f595..3b5a9a60e8 100644 --- a/gr-uhd/include/gnuradio/uhd/usrp_sink.h +++ b/gr-uhd/include/gnuradio/uhd/usrp_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010-2015 Free Software Foundation, Inc. + * Copyright 2010-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,28 +25,6 @@ #include <gnuradio/uhd/usrp_block.h> -// TODO In 3.8, UHD 3.4 will be required and we can remove all these ifdefs -#ifndef INCLUDED_UHD_STREAM_HPP -namespace uhd { - struct GR_UHD_API stream_args_t - { - stream_args_t(const std::string &cpu = "", - const std::string &otw = "") - { - cpu_format = cpu; - otw_format = otw; - } - std::string cpu_format; - std::string otw_format; - device_addr_t args; - std::vector<size_t> channels; - }; -} -# define INCLUDED_UHD_STREAM_HPP -#else -# define GR_UHD_USE_STREAM_API -#endif - namespace gr { namespace uhd { @@ -124,17 +102,6 @@ namespace gr { typedef boost::shared_ptr<usrp_sink> sptr; /*! - * \brief DEPRECATED Make a new USRP sink block using the deprecated io_type_t. - * \ingroup uhd_blk - * - * This function will be removed in the future. Please use the other make function, - * gr::uhd::usrp_sink::make(const ::uhd::device_addr_t, const ::uhd::stream_args_t, const std::string). - */ - static sptr make(const ::uhd::device_addr_t &device_addr, - const ::uhd::io_type_t &io_type, - size_t num_channels); - - /*! * \param device_addr the address to identify the hardware * \param stream_args the IO format and channel specification * \param tsb_tag_name the name of the tag identifying tagged stream length diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h b/gr-uhd/include/gnuradio/uhd/usrp_source.h index a0022b3876..552c518f1c 100644 --- a/gr-uhd/include/gnuradio/uhd/usrp_source.h +++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010-2015 Free Software Foundation, Inc. + * Copyright 2010-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -25,28 +25,6 @@ #include <gnuradio/uhd/usrp_block.h> -// TODO In 3.8, UHD 3.6 will be required and we can remove all these ifdefs -#ifndef INCLUDED_UHD_STREAM_HPP -namespace uhd { - struct GR_UHD_API stream_args_t - { - stream_args_t(const std::string &cpu = "", - const std::string &otw = "") - { - cpu_format = cpu; - otw_format = otw; - } - std::string cpu_format; - std::string otw_format; - device_addr_t args; - std::vector<size_t> channels; - }; -} -# define INCLUDED_UHD_STREAM_HPP -#else -# define GR_UHD_USE_STREAM_API -#endif - namespace gr { namespace uhd { @@ -83,17 +61,6 @@ namespace gr { typedef boost::shared_ptr<usrp_source> sptr; /*! - * \brief DEPRECATED Make a new USRP source block using the deprecated io_type_t. - * \ingroup uhd_blk - * - * This function will be removed in the future. Please use the other make function, - * gr::uhd::make(const ::uhd::device_addr_t, const ::uhd::stream_args_t, const std::string). - */ - static sptr make(const ::uhd::device_addr_t &device_addr, - const ::uhd::io_type_t &io_type, - size_t num_channels); - - /*! * \param device_addr the address to identify the hardware * \param stream_args the IO format and channel specification * \param issue_stream_cmd_on_start enable or disable continuous streaming when flowgraph diff --git a/gr-uhd/lib/usrp_block_impl.cc b/gr-uhd/lib/usrp_block_impl.cc index 7f3478c1a5..341e1a9fd8 100644 --- a/gr-uhd/lib/usrp_block_impl.cc +++ b/gr-uhd/lib/usrp_block_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2015 Free Software Foundation, Inc. + * Copyright 2015-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -245,62 +245,38 @@ void usrp_block_impl::set_time_source(const std::string &source, const size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API return _dev->set_time_source(source, mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } std::string usrp_block_impl::get_time_source(const size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API return _dev->get_time_source(mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } std::vector<std::string> usrp_block_impl::get_time_sources(const size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API return _dev->get_time_sources(mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void usrp_block_impl::set_clock_source(const std::string &source, const size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API return _dev->set_clock_source(source, mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } std::string usrp_block_impl::get_clock_source(const size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API return _dev->get_clock_source(mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } std::vector<std::string> usrp_block_impl::get_clock_sources(const size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API return _dev->get_clock_sources(mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } double @@ -373,21 +349,13 @@ void usrp_block_impl::set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API return _dev->set_command_time(time_spec, mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void usrp_block_impl::clear_command_time(size_t mboard) { -#ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API return _dev->clear_command_time(mboard); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void @@ -395,11 +363,7 @@ usrp_block_impl::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 } void diff --git a/gr-uhd/lib/usrp_block_impl.h b/gr-uhd/lib/usrp_block_impl.h index a1bbf97826..8285bda42c 100644 --- a/gr-uhd/lib/usrp_block_impl.h +++ b/gr-uhd/lib/usrp_block_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2015 Free Software Foundation, Inc. + * Copyright 2015-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc index d8f98fdd80..6288b80cc8 100644 --- a/gr-uhd/lib/usrp_sink_impl.cc +++ b/gr-uhd/lib/usrp_sink_impl.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010-2015 Free Software Foundation, Inc. + * Copyright 2010-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,26 +31,6 @@ namespace gr { usrp_sink::sptr usrp_sink::make(const ::uhd::device_addr_t &device_addr, - const ::uhd::io_type_t &io_type, - size_t num_channels) - { - //fill in the streamer args - ::uhd::stream_args_t stream_args; - switch(io_type.tid) { - case ::uhd::io_type_t::COMPLEX_FLOAT32: stream_args.cpu_format = "fc32"; break; - case ::uhd::io_type_t::COMPLEX_INT16: stream_args.cpu_format = "sc16"; break; - default: throw std::runtime_error("only complex float and shorts known to work"); - } - - stream_args.otw_format = "sc16"; //only sc16 known to work - for(size_t chan = 0; chan < num_channels; chan++) - stream_args.channels.push_back(chan); //linear mapping - - return usrp_sink::make(device_addr, stream_args, ""); - } - - usrp_sink::sptr - usrp_sink::make(const ::uhd::device_addr_t &device_addr, const ::uhd::stream_args_t &stream_args, const std::string &length_tag_name) { @@ -80,11 +60,7 @@ namespace gr { usrp_sink_impl::get_usrp_info(size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API return _dev->get_usrp_tx_info(chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void @@ -119,11 +95,7 @@ namespace gr { ::uhd::meta_range_t usrp_sink_impl::get_samp_rates(void) { -#ifdef UHD_USRP_MULTI_USRP_GET_RATES_API return _dev->get_tx_rates(_stream_args.channels[0]); -#else - throw std::runtime_error("not implemented in this version"); -#endif } ::uhd::tune_result_t @@ -274,11 +246,7 @@ namespace gr { size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_tx_dc_offset(offset, chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void @@ -286,11 +254,7 @@ namespace gr { size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_tx_iq_balance(correction, chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } ::uhd::sensor_value_t @@ -318,12 +282,9 @@ namespace gr { usrp_sink_impl::set_stream_args(const ::uhd::stream_args_t &stream_args) { _update_stream_args(stream_args); -#ifdef GR_UHD_USE_STREAM_API - if(_tx_stream) + if (_tx_stream) { _tx_stream.reset(); -#else - throw std::runtime_error("not implemented in this version"); -#endif + } } /*********************************************************************** @@ -367,15 +328,10 @@ namespace gr { } } -#ifdef GR_UHD_USE_STREAM_API //send all ninput_items with metadata - const size_t num_sent = _tx_stream->send - (input_items, ninput_items, _metadata, 1.0); -#else - const size_t num_sent = _dev->get_device()->send - (input_items, ninput_items, _metadata, - *_type, ::uhd::device::SEND_MODE_FULL_BUFF, 1.0); -#endif + const size_t num_sent = _tx_stream->send( + input_items, ninput_items, _metadata, 1.0 + ); //if using length_tags, decrement items left to send by the number of samples sent if(not pmt::is_null(_length_tag_key) && _nitems_to_send > 0) { @@ -569,9 +525,7 @@ namespace gr { bool usrp_sink_impl::start(void) { -#ifdef GR_UHD_USE_STREAM_API _tx_stream = _dev->get_tx_stream(_stream_args); -#endif _metadata.start_of_burst = true; _metadata.end_of_burst = false; @@ -586,14 +540,8 @@ namespace gr { _metadata.time_spec = get_time_now() + ::uhd::time_spec_t(0.15); } -#ifdef GR_UHD_USE_STREAM_API _tx_stream->send (gr_vector_const_void_star(_nchan), 0, _metadata, 1.0); -#else - _dev->get_device()->send - (gr_vector_const_void_star(_nchan), 0, _metadata, - *_type, ::uhd::device::SEND_MODE_ONE_PACKET, 1.0); -#endif return true; } @@ -607,14 +555,9 @@ namespace gr { _metadata.has_time_spec = false; _nitems_to_send = 0; -#ifdef GR_UHD_USE_STREAM_API - if(_tx_stream) + if (_tx_stream) { _tx_stream->send(gr_vector_const_void_star(_nchan), 0, _metadata, 1.0); -#else - _dev->get_device()->send - (gr_vector_const_void_star(_nchan), 0, _metadata, - *_type, ::uhd::device::SEND_MODE_ONE_PACKET, 1.0); -#endif + } return true; } diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h index d509baef90..304a02ca7b 100644 --- a/gr-uhd/lib/usrp_sink_impl.h +++ b/gr-uhd/lib/usrp_sink_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010-2015 Free Software Foundation, Inc. + * Copyright 2010-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -37,15 +37,7 @@ namespace gr { args_to_io_sig(const ::uhd::stream_args_t &args) { const size_t nchan = std::max<size_t>(args.channels.size(), 1); -#ifdef GR_UHD_USE_STREAM_API const size_t size = ::uhd::convert::get_bytes_per_item(args.cpu_format); -#else - size_t size = 0; - if(args.cpu_format == "fc32") - size = 8; - if(args.cpu_format == "sc16") - size = 4; -#endif return io_signature::make(nchan, nchan, size); } @@ -109,9 +101,7 @@ namespace gr { //! Like set_center_freq(), but uses _curr_freq and _curr_lo_offset ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan); -#ifdef GR_UHD_USE_STREAM_API ::uhd::tx_streamer::sptr _tx_stream; -#endif ::uhd::tx_metadata_t _metadata; double _sample_rate; diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index 0c624bf0d0..c840c43db1 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -35,26 +35,6 @@ namespace gr { usrp_source::sptr usrp_source::make(const ::uhd::device_addr_t &device_addr, - const ::uhd::io_type_t &io_type, - size_t num_channels) - { - //fill in the streamer args - ::uhd::stream_args_t stream_args; - switch(io_type.tid) { - case ::uhd::io_type_t::COMPLEX_FLOAT32: stream_args.cpu_format = "fc32"; break; - case ::uhd::io_type_t::COMPLEX_INT16: stream_args.cpu_format = "sc16"; break; - default: throw std::runtime_error("only complex float and shorts known to work"); - } - - stream_args.otw_format = "sc16"; //only sc16 known to work - for(size_t chan = 0; chan < num_channels; chan++) - stream_args.channels.push_back(chan); //linear mapping - - return usrp_source::make(device_addr, stream_args); - } - - usrp_source::sptr - usrp_source::make(const ::uhd::device_addr_t &device_addr, const ::uhd::stream_args_t &stream_args, const bool issue_stream_cmd_on_start) { @@ -80,9 +60,7 @@ namespace gr { _samp_rate = this->get_samp_rate(); _center_freq = this->get_center_freq(0); -#ifdef GR_UHD_USE_STREAM_API _samps_per_packet = 1; -#endif register_msg_cmd_handler(CMD_TAG_KEY, boost::bind(&usrp_source_impl::_cmd_handler_tag, this, _1)); } @@ -94,11 +72,7 @@ namespace gr { usrp_source_impl::get_usrp_info(size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API return _dev->get_usrp_rx_info(chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void @@ -133,11 +107,7 @@ namespace gr { ::uhd::meta_range_t usrp_source_impl::get_samp_rates(void) { -#ifdef UHD_USRP_MULTI_USRP_GET_RATES_API return _dev->get_rx_rates(_stream_args.channels[0]); -#else - throw std::runtime_error("not implemented in this version"); -#endif } ::uhd::tune_result_t @@ -384,11 +354,7 @@ namespace gr { usrp_source_impl::set_auto_dc_offset(const bool enable, size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_rx_dc_offset(enable, chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void @@ -396,11 +362,7 @@ namespace gr { size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_rx_dc_offset(offset, chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } void @@ -420,11 +382,7 @@ namespace gr { size_t chan) { chan = _stream_args.channels[chan]; -#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_rx_iq_balance(correction, chan); -#else - throw std::runtime_error("not implemented in this version"); -#endif } ::uhd::sensor_value_t @@ -452,12 +410,9 @@ namespace gr { usrp_source_impl::set_stream_args(const ::uhd::stream_args_t &stream_args) { _update_stream_args(stream_args); -#ifdef GR_UHD_USE_STREAM_API - if(_rx_stream) + if (_rx_stream) { _rx_stream.reset(); -#else - throw std::runtime_error("not implemented in this version"); -#endif + } } void @@ -488,12 +443,10 @@ namespace gr { usrp_source_impl::start(void) { boost::recursive_mutex::scoped_lock lock(d_mutex); -#ifdef GR_UHD_USE_STREAM_API - if(not _rx_stream){ + if (not _rx_stream) { _rx_stream = _dev->get_rx_stream(_stream_args); _samps_per_packet = _rx_stream->get_max_num_samps(); } -#endif if(_issue_stream_cmd_on_start){ //setup a stream command that starts streaming slightly in the future static const double reasonable_delay = 0.1; //order of magnitude over RTT @@ -522,19 +475,13 @@ namespace gr { outputs.push_back(&buffs[i].front()); } while(true) { -#ifdef GR_UHD_USE_STREAM_API const size_t bpi = ::uhd::convert::get_bytes_per_item(_stream_args.cpu_format); if(_rx_stream) // get the remaining samples out of the buffers _rx_stream->recv(outputs, nbytes/bpi, _metadata, 0.0); else // no rx streamer -- nothing to flush - break; -#else - _dev->get_device()->recv - (outputs, nbytes/_type->size, _metadata, *_type, - ::uhd::device::RECV_MODE_FULL_BUFF, 0.0); -#endif + break; if(_metadata.error_code == ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; } @@ -561,7 +508,6 @@ namespace gr { std::vector<std::vector<std::complex<float> > > usrp_source_impl::finite_acquisition_v(const size_t nsamps) { -#ifdef GR_UHD_USE_STREAM_API //kludgy way to ensure rx streamer exsists if(!_rx_stream) { this->start(); @@ -599,9 +545,6 @@ namespace gr { } return samps; -#else - throw std::runtime_error("not implemented in this version"); -#endif } int @@ -610,7 +553,6 @@ namespace gr { gr_vector_void_star &output_items) { boost::recursive_mutex::scoped_lock lock(d_mutex); -#ifdef GR_UHD_USE_STREAM_API //In order to allow for low-latency: //We receive all available packets without timeout. //This call can timeout under regular operation... @@ -621,17 +563,6 @@ namespace gr { _recv_timeout, true /* one packet -> minimize latency */ ); -#else - size_t num_samps = _dev->get_device()->recv - (output_items, noutput_items, _metadata, - *_type, ::uhd::device::RECV_MODE_FULL_BUFF, 0.0); - - if(_metadata.error_code == ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) { - num_samps = _dev->get_device()->recv - (output_items, noutput_items, _metadata, *_type, - ::uhd::device::RECV_MODE_ONE_PACKET, 1.0); - } -#endif //handle possible errors conditions switch(_metadata.error_code) { diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h index ab0f5c62c4..c1566e18d0 100644 --- a/gr-uhd/lib/usrp_source_impl.h +++ b/gr-uhd/lib/usrp_source_impl.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010-2016 Software Foundation, Inc. + * Copyright 2010-2016 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -36,15 +36,7 @@ namespace gr { args_to_io_sig(const ::uhd::stream_args_t &args) { const size_t nchan = std::max<size_t>(args.channels.size(), 1); -#ifdef GR_UHD_USE_STREAM_API const size_t size = ::uhd::convert::get_bytes_per_item(args.cpu_format); -#else - size_t size = 0; - if(args.cpu_format == "fc32") - size = 8; - if(args.cpu_format == "sc16") - size = 4; -#endif return io_signature::make(nchan, nchan, size); } @@ -123,11 +115,9 @@ namespace gr { ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan); void _cmd_handler_tag(const pmt::pmt_t &tag); -#ifdef GR_UHD_USE_STREAM_API ::uhd::rx_streamer::sptr _rx_stream; size_t _samps_per_packet; double _recv_timeout; -#endif bool _tag_now; ::uhd::rx_metadata_t _metadata; pmt::pmt_t _id; |