From 96e50aebb7a4b3f98aac3c11aa1a3f06c14c0849 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Mon, 26 Aug 2013 13:51:30 -0700 Subject: examples: changed examples that force usage of all channels to allow user to input which channels to use --- host/examples/benchmark_rate.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'host/examples/benchmark_rate.cpp') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 02e5ef60a..3b2ab8a1f 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Ettus Research LLC +// Copyright 2011-2013 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -167,6 +169,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string rx_otw, tx_otw; std::string rx_cpu, tx_cpu; std::string mode; + std::string channel_list; //setup the program options po::options_description desc("Allowed options"); @@ -181,6 +184,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("rx_cpu", po::value(&rx_cpu)->default_value("fc32"), "specify the host/cpu sample mode for RX") ("tx_cpu", po::value(&tx_cpu)->default_value("fc32"), "specify the host/cpu sample mode for TX") ("mode", po::value(&mode)->default_value("none"), "multi-channel sync mode option: none, mimo") + ("channels", po::value(&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); @@ -216,13 +220,24 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ boost::thread_group thread_group; + //detect which channels to use + std::vector channel_strings; + std::vector 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(channel_strings[ch]); + if(chan >= usrp->get_tx_num_channels() or chan >= usrp->get_tx_num_channels()){ + throw std::runtime_error("Invalid channel(s) specified."); + } + else channel_nums.push_back(boost::lexical_cast(channel_strings[ch])); + } + //spawn the receive test thread if (vm.count("rx_rate")){ usrp->set_rx_rate(rx_rate); //create a receive streamer uhd::stream_args_t stream_args(rx_cpu, rx_otw); - for (size_t ch = 0; ch < usrp->get_rx_num_channels(); ch++) //linear channel mapping - stream_args.channels.push_back(ch); + stream_args.channels = channel_nums; uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); thread_group.create_thread(boost::bind(&benchmark_rx_rate, usrp, rx_cpu, rx_stream)); } @@ -232,8 +247,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_tx_rate(tx_rate); //create a transmit streamer uhd::stream_args_t stream_args(tx_cpu, tx_otw); - for (size_t ch = 0; ch < usrp->get_tx_num_channels(); ch++) //linear channel mapping - stream_args.channels.push_back(ch); + stream_args.channels = channel_nums; uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); thread_group.create_thread(boost::bind(&benchmark_tx_rate, usrp, tx_cpu, tx_stream)); thread_group.create_thread(boost::bind(&benchmark_tx_rate_async_helper, tx_stream)); -- cgit v1.2.3