diff options
author | Josh Blum <josh@joshknows.com> | 2011-03-11 12:02:59 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-03-11 12:02:59 -0800 |
commit | 60db6edf5209e3e2407db354bdb8a0691e8e4ef4 (patch) | |
tree | 450102e6a517108c2497a2dc1ead37eafc029566 /host/examples/tx_samples_from_file.cpp | |
parent | 1ab3803180009399aba8d8c58d5fae2645ac1ff3 (diff) | |
download | uhd-60db6edf5209e3e2407db354bdb8a0691e8e4ef4.tar.gz uhd-60db6edf5209e3e2407db354bdb8a0691e8e4ef4.tar.bz2 uhd-60db6edf5209e3e2407db354bdb8a0691e8e4ef4.zip |
uhd: a lot of tweaking, new parameters, and sig handler for to/from file examples
Diffstat (limited to 'host/examples/tx_samples_from_file.cpp')
-rw-r--r-- | host/examples/tx_samples_from_file.cpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index 0483eaa76..7824f4389 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -60,9 +60,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po - std::string args, file, type; + std::string args, file, type, ant, subdev; size_t spb; - double rate, freq, gain; + double rate, freq, gain, bw; //setup the program options po::options_description desc("Allowed options"); @@ -70,11 +70,14 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "multi uhd device address args") ("file", po::value<std::string>(&file)->default_value("usrp_samples.dat"), "name of the file to read binary samples from") - ("type", po::value<std::string>(&type)->default_value("float"), "choose the sample type: double, float, or short") + ("type", po::value<std::string>(&type)->default_value("float"), "sample type: double, float, or short") ("spb", po::value<size_t>(&spb)->default_value(10000), "samples per buffer") - ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of outgoing samples") - ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz") - ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain") + ("rate", po::value<double>(&rate), "rate of outgoing samples") + ("freq", po::value<double>(&freq), "rf center frequency in Hz") + ("gain", po::value<double>(&gain), "gain for the RF chain") + ("ant", po::value<std::string>(&ant), "select antenna") + ("subdev", po::value<std::string>(&subdev), "select subdevice") + ("bw", po::value<double>(&bw), "select IF filter bandwidth in Hz") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -90,22 +93,46 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); + + //always select the subdevice first, the channel mapping affects the other settings + if (vm.count("subdev")) usrp->set_tx_subdev_spec(subdev); + std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; - //set the rx sample rate - std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl; + //set the sample rate + if (not vm.count("rate")){ + std::cerr << "Please specify the sample rate with --rate" << std::endl; + return ~0; + } + std::cout << boost::format("Setting TX Rate: %f Msps...") % (rate/1e6) << std::endl; usrp->set_tx_rate(rate); - std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl; + std::cout << boost::format("Actual TX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl; - //set the rx center frequency - std::cout << boost::format("Setting RX Freq: %f Mhz...") % (freq/1e6) << std::endl; + //set the center frequency + if (not vm.count("freq")){ + std::cerr << "Please specify the center frequency with --freq" << std::endl; + return ~0; + } + std::cout << boost::format("Setting TX Freq: %f MHz...") % (freq/1e6) << std::endl; usrp->set_tx_freq(freq); - std::cout << boost::format("Actual RX Freq: %f Mhz...") % (usrp->get_tx_freq()/1e6) << std::endl << std::endl; + std::cout << boost::format("Actual TX Freq: %f MHz...") % (usrp->get_tx_freq()/1e6) << std::endl << std::endl; + + //set the rf gain + if (vm.count("gain")){ + std::cout << boost::format("Setting TX Gain: %f dB...") % gain << std::endl; + usrp->set_tx_gain(gain); + std::cout << boost::format("Actual TX Gain: %f dB...") % usrp->get_tx_gain() << std::endl << std::endl; + } + + //set the IF filter bandwidth + if (vm.count("bw")){ + std::cout << boost::format("Setting TX Bandwidth: %f MHz...") % bw << std::endl; + usrp->set_tx_bandwidth(bw); + std::cout << boost::format("Actual TX Bandwidth: %f MHz...") % usrp->get_tx_bandwidth() << std::endl << std::endl; + } - //set the rx rf gain - std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl; - usrp->set_tx_gain(gain); - std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_tx_gain() << std::endl << std::endl; + //set the antenna + if (vm.count("ant")) usrp->set_tx_antenna(ant); boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time |