aboutsummaryrefslogtreecommitdiffstats
path: root/lib/uhd/uhd_source_c.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/uhd/uhd_source_c.cc')
-rw-r--r--lib/uhd/uhd_source_c.cc57
1 files changed, 43 insertions, 14 deletions
diff --git a/lib/uhd/uhd_source_c.cc b/lib/uhd/uhd_source_c.cc
index c41f0d3..3fa6000 100644
--- a/lib/uhd/uhd_source_c.cc
+++ b/lib/uhd/uhd_source_c.cc
@@ -39,13 +39,14 @@ uhd_source_c_sptr make_uhd_source_c(const std::string &args)
uhd_source_c::uhd_source_c(const std::string &args) :
gr::hier_block2("uhd_source_c",
gr::io_signature::make(0, 0, 0),
- args_to_io_signature(args)),
+ gr::io_signature::make(1, 1, sizeof(gr_complex))),
_center_freq(0.0f),
_freq_corr(0.0f),
_lo_offset(0.0f)
{
size_t nchan = 1;
dict_t dict = params_to_dict(args);
+ uhd::stream_args_t stream_args;
if (dict.count("nchan"))
nchan = boost::lexical_cast< size_t >( dict["nchan"] );
@@ -57,28 +58,56 @@ uhd_source_c::uhd_source_c(const std::string &args) :
_lo_offset = boost::lexical_cast< double >( dict["lo_offset"] );
std::string arguments; // rebuild argument string without internal arguments
- BOOST_FOREACH( dict_t::value_type &entry, dict ) {
- if ( "uhd" != entry.first &&
- "nchan" != entry.first &&
- "subdev" != entry.first &&
- "lo_offset" != entry.first ) {
- arguments += entry.first + "=" + entry.second + ",";
- }
+ BOOST_FOREACH( dict_t::value_type &entry, dict )
+ {
+ if ( "cpu_format" == entry.first ||
+ "otw_format" == entry.first ||
+ "fullscale" == entry.first ||
+ "peak" == entry.first ||
+ "nchan" == entry.first ||
+ "subdev" == entry.first ||
+ "lo_offset" == entry.first ||
+ "uhd" == entry.first )
+ continue;
+
+ arguments += entry.first + "=" + entry.second + ",";
}
- _src = gr::uhd::usrp_source::make( arguments,
- uhd::io_type_t::COMPLEX_FLOAT32,
- nchan );
+ stream_args.cpu_format = "fc32";
+ stream_args.otw_format = "sc16";
+
+ if (dict.count("cpu_format") )
+ stream_args.cpu_format = dict["cpu_format"];
+
+ if (dict.count("otw_format") )
+ stream_args.otw_format = dict["otw_format"];
+
+ for (size_t chan = 0; chan < nchan; chan++)
+ stream_args.channels.push_back(chan); // linear mapping
+
+ if (dict.count("peak") )
+ stream_args.args["peak"] = dict["peak"];
- if (dict.count("subdev")) {
+ if (dict.count("fullscale") )
+ stream_args.args["fullscale"] = dict["fullscale"];
+
+ _src = gr::uhd::usrp_source::make( arguments, stream_args );
+
+ if (dict.count("subdev"))
_src->set_subdev_spec( dict["subdev"] );
- }
std::cerr << "-- Using subdev spec '" << _src->get_subdev_spec() << "'."
<< std::endl;
if (0.0 != _lo_offset)
- std::cerr << "-- Using lo offset of " << _lo_offset << " Hz." << std::endl;
+ std::cerr << "-- Using LO offset of " << _lo_offset << " Hz." << std::endl;
+
+ std::vector<int> sizes = _src->output_signature()->sizeof_stream_items();
+
+ while ( sizes.size() > nchan )
+ sizes.erase( sizes.end() );
+
+ set_output_signature( gr::io_signature::makev( nchan, nchan, sizes ) );
for ( size_t i = 0; i < nchan; i++ )
connect( _src, i, self(), i );