summaryrefslogtreecommitdiff
path: root/gr-uhd/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd/lib')
-rw-r--r--gr-uhd/lib/CMakeLists.txt4
-rw-r--r--gr-uhd/lib/usrp_block_impl.cc38
-rw-r--r--gr-uhd/lib/usrp_block_impl.h2
-rw-r--r--gr-uhd/lib/usrp_sink_impl.cc79
-rw-r--r--gr-uhd/lib/usrp_sink_impl.h12
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc83
-rw-r--r--gr-uhd/lib/usrp_source_impl.h12
7 files changed, 24 insertions, 206 deletions
diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt
index be77e22556..d58f0dd01c 100644
--- a/gr-uhd/lib/CMakeLists.txt
+++ b/gr-uhd/lib/CMakeLists.txt
@@ -75,7 +75,7 @@ list(APPEND uhd_libs
add_library(gnuradio-uhd SHARED ${gr_uhd_sources})
target_link_libraries(gnuradio-uhd ${uhd_libs})
-GR_LIBRARY_FOO(gnuradio-uhd RUNTIME_COMPONENT "uhd_runtime" DEVEL_COMPONENT "uhd_devel")
+GR_LIBRARY_FOO(gnuradio-uhd)
########################################################################
# Build static libraries if enabled
@@ -91,7 +91,7 @@ if(ENABLE_STATIC_LIBS)
endif(NOT WIN32)
install(TARGETS gnuradio-uhd_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "uhd_devel" # .lib file
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
)
else(UHD_VERSION VERSION_GREATER "3.8.1")
message(STATUS "Not building gr-uhd static library; requires UHD >= 3.8.2")
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 8b3412b025..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)
{
@@ -62,9 +42,9 @@ namespace gr {
usrp_sink_impl::usrp_sink_impl(const ::uhd::device_addr_t &device_addr,
const ::uhd::stream_args_t &stream_args,
const std::string &length_tag_name)
- : usrp_block("gr uhd usrp sink",
- args_to_io_sig(stream_args),
- io_signature::make(0, 0, 0)),
+ : usrp_block("usrp_sink",
+ args_to_io_sig(stream_args),
+ io_signature::make(0, 0, 0)),
usrp_block_impl(device_addr, stream_args, length_tag_name),
_length_tag_key(length_tag_name.empty() ? pmt::PMT_NIL : pmt::string_to_symbol(length_tag_name)),
_nitems_to_send(0)
@@ -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 b48b15165d..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)
{
@@ -66,9 +46,9 @@ namespace gr {
usrp_source_impl::usrp_source_impl(const ::uhd::device_addr_t &device_addr,
const ::uhd::stream_args_t &stream_args,
const bool issue_stream_cmd_on_start):
- usrp_block("gr uhd usrp source",
- io_signature::make(0, 0, 0),
- args_to_io_sig(stream_args)),
+ usrp_block("usrp_source",
+ io_signature::make(0, 0, 0),
+ args_to_io_sig(stream_args)),
usrp_block_impl(device_addr, stream_args, ""),
_recv_timeout(0.1), // seconds
_tag_now(false),
@@ -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;