diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2013-08-26 13:51:30 -0700 |
---|---|---|
committer | Nicholas Corgan <nick.corgan@ettus.com> | 2013-08-26 16:04:18 -0700 |
commit | 96e50aebb7a4b3f98aac3c11aa1a3f06c14c0849 (patch) | |
tree | 33ae54ed19b82a396749581c9c0f56bfc847f5aa /host/examples/rx_multi_samples.cpp | |
parent | 970afec3803677c739ecef0e37e45f77323820dd (diff) | |
download | uhd-96e50aebb7a4b3f98aac3c11aa1a3f06c14c0849.tar.gz uhd-96e50aebb7a4b3f98aac3c11aa1a3f06c14c0849.tar.bz2 uhd-96e50aebb7a4b3f98aac3c11aa1a3f06c14c0849.zip |
examples: changed examples that force usage of all channels to allow user to input which channels to use
Diffstat (limited to 'host/examples/rx_multi_samples.cpp')
-rw-r--r-- | host/examples/rx_multi_samples.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index 4f312ad36..9e5970978 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -21,6 +21,8 @@ #include <boost/program_options.hpp> #include <boost/format.hpp> #include <boost/thread.hpp> +#include <boost/lexical_cast.hpp> +#include <boost/algorithm/string.hpp> #include <iostream> #include <complex> @@ -30,7 +32,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po - std::string args, sync, subdev; + std::string args, sync, subdev, channel_list; double seconds_in_future; size_t total_num_samps; double rate; @@ -46,6 +48,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("sync", po::value<std::string>(&sync)->default_value("now"), "synchronization method: now, pps, mimo") ("subdev", po::value<std::string>(&subdev), "subdev spec (homogeneous across motherboards)") ("dilv", "specify to disable inner-loop verbose") + ("channels", po::value<std::string>(&channel_list)->default_value("0"), "which channel(s) to use (specify \"0\", \"1\", \"0,1\", etc)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -110,11 +113,22 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ boost::this_thread::sleep(boost::posix_time::milliseconds(100)); } + //detect which channels to use + std::vector<std::string> channel_strings; + std::vector<size_t> channel_nums; + boost::split(channel_strings, channel_list, boost::is_any_of("\"',")); + for(size_t ch = 0; ch < channel_strings.size(); ch++){ + size_t chan = boost::lexical_cast<int>(channel_strings[ch]); + if(chan >= usrp->get_rx_num_channels()){ + throw std::runtime_error("Invalid channel(s) specified."); + } + else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); + } + //create a receive streamer //linearly map channels (index0 = channel0, index1 = channel1, ...) uhd::stream_args_t stream_args("fc32"); //complex floats - for (size_t chan = 0; chan < usrp->get_rx_num_channels(); chan++) - stream_args.channels.push_back(chan); //linear mapping + stream_args.channels = channel_nums; uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); //setup streaming |