diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-19 22:23:46 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-19 22:23:46 -0800 |
commit | 9239878b0b81c3a368bf11cfc2fe48bfb05ff902 (patch) | |
tree | f41a5e58eac89b35cb99537a0a0b64662384a9f2 /host/examples | |
parent | fc138381ee4bd8d191795230b7447071a85e1f28 (diff) | |
parent | 7d918c5f6acc9a5d2c8ae03e2e67b403f7efd5ff (diff) | |
download | uhd-9239878b0b81c3a368bf11cfc2fe48bfb05ff902.tar.gz uhd-9239878b0b81c3a368bf11cfc2fe48bfb05ff902.tar.bz2 uhd-9239878b0b81c3a368bf11cfc2fe48bfb05ff902.zip |
Merge branch 'next'
Conflicts:
host/lib/usrp/usrp2/codec_impl.cpp
Diffstat (limited to 'host/examples')
-rw-r--r-- | host/examples/rx_ascii_art_dft.cpp | 8 | ||||
-rw-r--r-- | host/examples/rx_samples_to_file.cpp | 7 | ||||
-rw-r--r-- | host/examples/rx_samples_to_udp.cpp | 7 | ||||
-rw-r--r-- | host/examples/rx_timed_samples.cpp | 8 | ||||
-rw-r--r-- | host/examples/test_pps_input.cpp | 37 | ||||
-rw-r--r-- | host/examples/tx_from_file.cpp | 15 | ||||
-rw-r--r-- | host/examples/tx_timed_samples.cpp | 16 | ||||
-rw-r--r-- | host/examples/tx_waveforms.cpp | 10 |
8 files changed, 42 insertions, 66 deletions
diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp index 5a24867b4..260feca24 100644 --- a/host/examples/rx_ascii_art_dft.cpp +++ b/host/examples/rx_ascii_art_dft.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -34,8 +34,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; size_t num_bins; - double rate, freq, frame_rate; - float gain, ref_lvl, dyn_rng; + double rate, freq, gain, frame_rate; + float ref_lvl, dyn_rng; //setup the program options po::options_description desc("Allowed options"); @@ -45,7 +45,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ // 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<float>(&gain)->default_value(0), "gain for the RF chain") + ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain") // 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)") diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index c80d2a6de..81977035e 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -33,8 +33,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args, file; size_t total_num_samps; - double rate, freq; - float gain; + double rate, freq, gain; //setup the program options po::options_description desc("Allowed options"); @@ -45,7 +44,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive") ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples") ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz") - ("gain", po::value<float>(&gain)->default_value(0), "gain for the RF chain") + ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index 488c95494..55b9a50ba 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -33,8 +33,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; size_t total_num_samps; - double rate, freq; - float gain; + double rate, freq, gain; std::string addr, port; //setup the program options @@ -45,7 +44,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive") ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples") ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz") - ("gain", po::value<float>(&gain)->default_value(0), "gain for the RF chain") + ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain") ("port", po::value<std::string>(&port)->default_value("7124"), "server udp port") ("addr", po::value<std::string>(&addr)->default_value("192.168.1.10"), "resolvable server address") ; diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 8a810811f..a19532f50 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -30,7 +30,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; - time_t seconds_in_future; + double seconds_in_future; size_t total_num_samps; double rate, freq; @@ -39,7 +39,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args") - ("secs", po::value<time_t>(&seconds_in_future)->default_value(3), "number of seconds in the future to receive") + ("secs", po::value<double>(&seconds_in_future)->default_value(3), "number of seconds in the future to receive") ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive") ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples") ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz") @@ -80,7 +80,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //setup streaming std::cout << std::endl; std::cout << boost::format( - "Begin streaming %u samples, %d seconds in the future..." + "Begin streaming %u samples, %f seconds in the future..." ) % total_num_samps % seconds_in_future << std::endl; uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); stream_cmd.num_samps = total_num_samps; diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp index 4b2bb62a3..273c73df0 100644 --- a/host/examples/test_pps_input.cpp +++ b/host/examples/test_pps_input.cpp @@ -17,7 +17,7 @@ #include <uhd/utils/thread_priority.hpp> #include <uhd/utils/safe_main.hpp> -#include <uhd/usrp/single_usrp.hpp> +#include <uhd/usrp/multi_usrp.hpp> #include <boost/program_options.hpp> #include <boost/format.hpp> #include <boost/thread.hpp> @@ -31,7 +31,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; - double seconds; //setup the program options po::options_description desc("Allowed options"); @@ -52,35 +51,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //create a usrp device std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; - uhd::usrp::single_usrp::sptr sdev = uhd::usrp::single_usrp::make(args); + uhd::usrp::multi_usrp::sptr sdev = uhd::usrp::multi_usrp::make(args); uhd::device::sptr dev = sdev->get_device(); std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl; - //set a known time value - std::cout << "Set time to known value (100.0) without regard to pps:" << std::endl; - sdev->set_time_now(uhd::time_spec_t(100.0)); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl; - - //store the time to see if PPS resets it - seconds = sdev->get_time_now().get_real_secs(); - - //set a known time at next PPS, check that time increments - uhd::time_spec_t time_spec = uhd::time_spec_t(0.0); - std::cout << "Set time to known value (0.0) at next pps:" << std::endl; - sdev->set_time_next_pps(time_spec); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl; - - //finished - if (seconds > sdev->get_time_now().get_real_secs()){ - std::cout << std::endl << "Success!" << std::endl << std::endl; - return 0; - } else { - std::cout << std::endl << "Failed!" << std::endl << std::endl - << "If you expected PPS to work:" << std::endl - << "\tsee Device App Notes for PPS level information" - << std::endl << std::endl; - return -1; - } + //set the time at an unknown pps (will throw if no pps) + std::cout << std::endl << "Attempt to detect the PPS and set the time..." << std::endl << std::endl; + sdev->set_time_unknown_pps(uhd::time_spec_t(0.0)); + std::cout << std::endl << "Success!" << std::endl << std::endl; + return 0; } diff --git a/host/examples/tx_from_file.cpp b/host/examples/tx_from_file.cpp index 9611cf47c..8af9b0f4a 100644 --- a/host/examples/tx_from_file.cpp +++ b/host/examples/tx_from_file.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -31,24 +31,23 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; - time_t seconds_in_future; + double seconds_in_future; size_t total_num_samps; size_t samps_per_packet; - double tx_rate, freq; + double tx_rate, freq, gain; float ampl; - float tx_gain; //setup the program options po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args") - ("secs", po::value<time_t>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit") + ("secs", po::value<double>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit") ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to transmit") ("txrate", po::value<double>(&tx_rate)->default_value(100e6/16), "rate of outgoing samples") ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz") ("ampl", po::value<float>(&l)->default_value(float(0.3)), "amplitude of each sample") - ("gain", po::value<float>(&tx_gain)->default_value(float(0)), "amplitude of each sample") + ("gain", po::value<double>(&gain)->default_value(0), "amplitude of each sample") ("dilv", "specify to disable inner-loop verbose") ; po::variables_map vm; @@ -78,7 +77,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ sdev->set_tx_freq(freq); sdev->set_time_now(uhd::time_spec_t(0.0)); - sdev->set_tx_gain(tx_gain); + sdev->set_gain(gain); //allocate data to send std::vector<std::complex<short> > buff; @@ -102,7 +101,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet; for (size_t i = 0; i < num_packets; i++){ //setup the metadata flags and time spec - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = (i == 0); //only first packet has SOB md.end_of_burst = (i == num_packets-1); //only last packet has EOB md.has_time_spec = (i == 0); //only first packet has time md.time_spec = uhd::time_spec_t(seconds_in_future); diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 799da37e0..6d6aa7010 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -30,7 +30,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; - time_t seconds_in_future; + double seconds_in_future; size_t total_num_samps; size_t samps_per_packet; double rate, freq; @@ -41,7 +41,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args") - ("secs", po::value<time_t>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit") + ("secs", po::value<double>(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit") ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to transmit") ("spp", po::value<size_t>(&samps_per_packet)->default_value(1000), "number of samples per packet") ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of outgoing samples") @@ -84,15 +84,17 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //allocate data to send std::vector<std::complex<float> > buff(samps_per_packet, std::complex<float>(ampl, ampl)); + uhd::tx_metadata_t md; + md.time_spec = uhd::time_spec_t(seconds_in_future); + //send the data in multiple packets size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet; for (size_t i = 0; i < num_packets; i++){ - //setup the metadata flags and time spec - uhd::tx_metadata_t md; - md.start_of_burst = true; //always SOB (good for continuous streaming) + + //setup the metadata flags per fragment + md.start_of_burst = (i == 0); //only first packet has SOB md.end_of_burst = (i == num_packets-1); //only last packet has EOB md.has_time_spec = (i == 0); //only first packet has time - md.time_spec = uhd::time_spec_t(seconds_in_future); size_t samps_to_send = std::min(total_num_samps - samps_per_packet*i, samps_per_packet); diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 50982cf88..7cc1f5ae0 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -63,8 +63,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args, wave_type; size_t total_duration, spb; - double rate, freq, wave_freq; - float ampl, gain; + double rate, freq, gain, wave_freq; + float ampl; //setup the program options po::options_description desc("Allowed options"); @@ -76,7 +76,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("rate", po::value<double>(&rate)->default_value(1.5e6), "rate of outgoing samples") ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz") ("ampl", po::value<float>(&l)->default_value(float(0.3)), "amplitude of the waveform") - ("gain", po::value<float>(&gain)->default_value(float(0)), "gain for the RF chain") + ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain") ("wave-type", po::value<std::string>(&wave_type)->default_value("CONST"), "waveform type (CONST, SQUARE, RAMP, SINE)") ("wave-freq", po::value<double>(&wave_freq)->default_value(0), "waveform frequency in Hz") ; @@ -142,7 +142,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //setup the metadata flags uhd::tx_metadata_t md; - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = false; //never SOB when continuous md.end_of_burst = false; //send the data in multiple packets |