aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
Diffstat (limited to 'host/examples')
-rw-r--r--host/examples/benchmark_rx_rate.cpp39
-rw-r--r--host/examples/rx_ascii_art_dft.cpp53
2 files changed, 63 insertions, 29 deletions
diff --git a/host/examples/benchmark_rx_rate.cpp b/host/examples/benchmark_rx_rate.cpp
index 118bf413c..50af1b98b 100644
--- a/host/examples/benchmark_rx_rate.cpp
+++ b/host/examples/benchmark_rx_rate.cpp
@@ -114,7 +114,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args;
double duration;
- double only_rate;
+ double rate;
//setup the program options
po::options_description desc("Allowed options");
@@ -122,7 +122,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("help", "help message")
("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args")
("duration", po::value<double>(&duration)->default_value(10.0), "duration for each test in seconds")
- ("rate", po::value<double>(&only_rate), "specify to perform a single test as this rate (sps)")
+ ("rate", po::value<double>(&rate), "specify to perform a single test as this rate (sps)")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
@@ -134,26 +134,31 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
return ~0;
}
+ //verify that rate was specified
+ if (not vm.count("rate")){
+ std::cerr << "Please specify the sample rate with --rate" << std::endl;
+ return ~0;
+ }
+
//create a usrp device
std::cout << std::endl;
+ uhd::device_addrs_t device_addrs = uhd::device::find(args);
+ if (device_addrs.empty()){
+ std::cerr << "Could not find any devices for: " << args << std::endl;
+ return ~0;
+ }
+ if (device_addrs.at(0).get("type", "") == "usrp1"){
+ std::cerr << "*** Warning! ***" << std::endl;
+ std::cerr << "Benchmark RX results will be inaccurate on USRP1 due to soft-time control.\n" << 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);
+ uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(device_addrs.at(0));
std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl;
- if (not vm.count("rate")){
- usrp->set_rx_rate(500e3); //initial rate
- while(true){
- double rate = usrp->get_rx_rate();
- test_device(usrp, rate, duration);
- usrp->set_rx_rate(rate*2); //double the rate
- if (usrp->get_rx_rate() == rate) break;
- }
- }
- else{
- usrp->set_rx_rate(only_rate);
- double rate = usrp->get_rx_rate();
- test_device(usrp, rate, duration);
- }
+ //start the test
+ usrp->set_rx_rate(rate);
+ rate = usrp->get_rx_rate();
+ test_device(usrp, rate, duration);
//finished
std::cout << std::endl << "Done!" << std::endl << std::endl;
diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp
index c407ecf91..fa8c4d4a4 100644
--- a/host/examples/rx_ascii_art_dft.cpp
+++ b/host/examples/rx_ascii_art_dft.cpp
@@ -32,9 +32,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::set_thread_priority_safe();
//variables to be set by po
- std::string args;
+ std::string args, ant, subdev;
size_t num_bins;
- double rate, freq, gain, frame_rate;
+ double rate, freq, gain, bw, frame_rate;
float ref_lvl, dyn_rng;
//setup the program options
@@ -44,8 +44,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("args", po::value<std::string>(&args)->default_value(""), "multi uhd device address args")
// hardware parameters
("rate", po::value<double>(&rate), "rate of incoming samples (sps)")
- ("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")
+ ("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), "daughterboard antenna selection")
+ ("subdev", po::value<std::string>(&subdev), "daughterboard subdevice specification")
+ ("bw", po::value<double>(&bw), "daughterboard IF filter bandwidth in Hz")
// display parameters
("num-bins", po::value<size_t>(&num_bins)->default_value(512), "the number of bins in the DFT")
("frame-rate", po::value<double>(&frame_rate)->default_value(5), "frame rate of the display (fps)")
@@ -66,22 +69,48 @@ 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_rx_subdev_spec(subdev);
+
std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl;
- //set the rx sample rate
+ //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 RX Rate: %f Msps...") % (rate/1e6) << std::endl;
usrp->set_rx_rate(rate);
std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_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 RX Freq: %f MHz...") % (freq/1e6) << std::endl;
usrp->set_rx_freq(freq);
- std::cout << boost::format("Actual RX Freq: %f Mhz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl;
+ std::cout << boost::format("Actual RX Freq: %f MHz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl;
+
+ //set the rf gain
+ if (vm.count("gain")){
+ std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl;
+ usrp->set_rx_gain(gain);
+ std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl;
+ }
+
+ //set the IF filter bandwidth
+ if (vm.count("bw")){
+ std::cout << boost::format("Setting RX Bandwidth: %f MHz...") % bw << std::endl;
+ usrp->set_rx_bandwidth(bw);
+ std::cout << boost::format("Actual RX Bandwidth: %f MHz...") % usrp->get_rx_bandwidth() << std::endl << std::endl;
+ }
+
+ //set the antenna
+ if (vm.count("ant")) usrp->set_rx_antenna(ant);
- //set the rx rf gain
- std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl;
- usrp->set_rx_gain(gain);
- std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl;
+ boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time
//allocate recv buffer and metatdata
uhd::rx_metadata_t md;