From 8604d76df35dee69c8e5fa7b34c361964418eadb Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Wed, 27 Aug 2014 21:37:39 +0200 Subject: [PATCH] uhd: disable dynamic signature change due to gnuradio bug #719 details: http://gnuradio.org/redmine/issues/719 --- lib/uhd/uhd_sink_c.cc | 25 +++++++++++++++++++------ lib/uhd/uhd_source_c.cc | 22 ++++++++++++++++++---- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/lib/uhd/uhd_sink_c.cc b/lib/uhd/uhd_sink_c.cc index f7646d2..f09f437 100644 --- a/lib/uhd/uhd_sink_c.cc +++ b/lib/uhd/uhd_sink_c.cc @@ -35,9 +35,23 @@ uhd_sink_c_sptr make_uhd_sink_c(const std::string &args) return gnuradio::get_initial_sptr(new uhd_sink_c(args)); } +static size_t parse_nchan(const std::string &args) +{ + size_t nchan = 1; + + dict_t dict = params_to_dict(args); + + if (dict.count("nchan")) + nchan = boost::lexical_cast< size_t >( dict["nchan"] ); + + return nchan; +} + uhd_sink_c::uhd_sink_c(const std::string &args) : gr::hier_block2("uhd_sink_c", - gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(parse_nchan(args), + parse_nchan(args), + sizeof(gr_complex)), gr::io_signature::make(0, 0, 0)), _center_freq(0.0f), _freq_corr(0.0f), @@ -92,23 +106,22 @@ uhd_sink_c::uhd_sink_c(const std::string &args) : _snk = gr::uhd::usrp_sink::make( arguments, stream_args ); - if (dict.count("subdev")) { + if (dict.count("subdev")) _snk->set_subdev_spec( dict["subdev"] ); - } std::cerr << "-- Using subdev spec '" << _snk->get_subdev_spec() << "'." << std::endl; if (0.0 != _lo_offset) std::cerr << "-- Using LO offset of " << _lo_offset << " Hz." << std::endl; - +#if 0 std::vector sizes = _snk->input_signature()->sizeof_stream_items(); while ( sizes.size() > nchan ) sizes.erase( sizes.end() ); - + // TODO: setting the input signature is broken for hier blocks (gnuradio bug #719) set_input_signature( gr::io_signature::makev( nchan, nchan, sizes ) ); - +#endif for ( size_t i = 0; i < nchan; i++ ) connect( self(), i, _snk, i ); } diff --git a/lib/uhd/uhd_source_c.cc b/lib/uhd/uhd_source_c.cc index 3fa6000..f800b0d 100644 --- a/lib/uhd/uhd_source_c.cc +++ b/lib/uhd/uhd_source_c.cc @@ -36,10 +36,24 @@ uhd_source_c_sptr make_uhd_source_c(const std::string &args) return gnuradio::get_initial_sptr(new uhd_source_c(args)); } +static size_t parse_nchan(const std::string &args) +{ + size_t nchan = 1; + + dict_t dict = params_to_dict(args); + + if (dict.count("nchan")) + nchan = boost::lexical_cast< size_t >( dict["nchan"] ); + + return nchan; +} + uhd_source_c::uhd_source_c(const std::string &args) : gr::hier_block2("uhd_source_c", gr::io_signature::make(0, 0, 0), - gr::io_signature::make(1, 1, sizeof(gr_complex))), + gr::io_signature::make(parse_nchan(args), + parse_nchan(args), + sizeof(gr_complex))), _center_freq(0.0f), _freq_corr(0.0f), _lo_offset(0.0f) @@ -101,14 +115,14 @@ uhd_source_c::uhd_source_c(const std::string &args) : if (0.0 != _lo_offset) std::cerr << "-- Using LO offset of " << _lo_offset << " Hz." << std::endl; - +#if 0 std::vector sizes = _src->output_signature()->sizeof_stream_items(); while ( sizes.size() > nchan ) sizes.erase( sizes.end() ); - + // TODO: setting the output signature is broken for hier blocks (gnuradio bug #719) set_output_signature( gr::io_signature::makev( nchan, nchan, sizes ) ); - +#endif for ( size_t i = 0; i < nchan; i++ ) connect( _src, i, self(), i ); }