summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-04-10 14:29:28 -0700
committerJosh Blum <josh@joshknows.com>2012-04-10 14:29:28 -0700
commit12ea88585e83100ed6f229808c4492445ca53e28 (patch)
treed9d08ee28a552fe7f798293bf46b14490e324c4e /host
parent76f794330649b4fed0bff3617b13c9aa648b5382 (diff)
parentcc421709426601ded6949d041364dcf5b102b849 (diff)
downloaduhd-12ea88585e83100ed6f229808c4492445ca53e28.tar.gz
uhd-12ea88585e83100ed6f229808c4492445ca53e28.tar.bz2
uhd-12ea88585e83100ed6f229808c4492445ca53e28.zip
Merge branch 'master' into next
Diffstat (limited to 'host')
-rw-r--r--host/examples/transport_hammer.cpp530
-rw-r--r--host/include/uhd/usrp/multi_usrp.hpp21
-rw-r--r--host/include/uhd/version.hpp2
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_200.cpp6
-rw-r--r--host/lib/usrp/multi_usrp.cpp60
5 files changed, 337 insertions, 282 deletions
diff --git a/host/examples/transport_hammer.cpp b/host/examples/transport_hammer.cpp
index 8e588e2fb..597614050 100644
--- a/host/examples/transport_hammer.cpp
+++ b/host/examples/transport_hammer.cpp
@@ -19,330 +19,322 @@
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/program_options.hpp>
-#include <boost/thread/thread.hpp>
#include <boost/format.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/math/special_functions/round.hpp>
#include <iostream>
#include <complex>
-#include <time.h>
namespace po = boost::program_options;
-int UHD_SAFE_MAIN(int argc, char *argv[]){
+/************************************************************************
+ * RX Samples
+ ************************************************************************/
+
+void rx_hammer(uhd::usrp::multi_usrp::sptr usrp, double rx_rate, bool rx_rand, int rx_low, int rx_high, int rx_step, bool verbose){
uhd::set_thread_priority_safe();
- //variables to be set by po
- std::string args;
- double delay;
- size_t total_num_samps;
- double rate;
- int step;
- int rand_begin;
- int rand_end;
- size_t samp_begin;
- size_t samp_end;
- float ampl;
-
- //setup the program options
- po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args")
- ("delay", po::value<double>(&delay)->default_value(0.0), "delay between sample jumps")
- ("step", po::value<int>(&step)->default_value(1), "delta between number of samples collected/sent")
- ("samp_begin", po::value<size_t>(&samp_begin)->default_value(1), "Beginning number of samples")
- ("samp_end", po::value<size_t>(&samp_end)->default_value(32768), "End number of samples")
- ("rate", po::value<double>(&rate)->default_value(3.125e6), "rate of incoming samples")
- ("tx", "specify to use TX samples instead of RX samples")
- ("rx", "specify to use RX samples (already default")
- ("rand_vals", "specify to continuously use random numbers of samples")
- ("rand_begin", po::value<int>(&rand_begin)->default_value(0), "specify minimum value outputted by random number generator")
- ("rand_end", po::value<int>(&rand_end)->default_value(2000), "specify maximum value outputting by random number generator")
- ("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of each sample")
- ("verbose", "Enables verbosity")
- ;
- po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
+ //Set RX sample rate
+ std::cout << boost::format("Setting RX rate: %f Msps") % (rx_rate/1e6) << std::endl;
+ usrp->set_rx_rate(rx_rate);
+ std::cout << boost::format("Actual RX rate: %f Msps") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl;
+
+ if(rx_rand){
+ std::srand((unsigned int) time(NULL));
+
+ while(true){
+ size_t total_num_samps = (rand() % (rx_high - rx_low)) + rx_low;
+
+ usrp->set_time_now(uhd::time_spec_t(0.0));
+
+ //Create a receive streamer
+ uhd::stream_args_t stream_args("fc32");
+ uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
+
+ std::cout << boost::format("About to receive %u samples.") % total_num_samps << 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;
+ stream_cmd.stream_now = true;
+ usrp->issue_stream_cmd(stream_cmd);
+
+ //Metadata will be filled in by recv()
+ uhd::rx_metadata_t md;
+
+ //Allocate buffer to receive with samples
+ std::vector<std::complex<float> > buff(rx_stream->get_max_num_samps());
+ double timeout = 1;
+
+ size_t num_acc_samps = 0; //Number of accumulated samples
+ while(num_acc_samps < total_num_samps){
+ //Receive a single packet
+ size_t num_rx_samps = rx_stream->recv(
+ &buff.front(), buff.size(), md, timeout, true
+ );
+
+ //Handle the error code
+ if(md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){std::cout << "timeout" << std::endl; break;}
+ if(md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE && md.error_code != uhd::rx_metadata_t::ERROR_CODE_OVERFLOW){
+ std::cout << "Error" << std::endl;
+ throw std::runtime_error(str(boost::format(
+ "Unexpected error code 0x%x"
+ ) % md.error_code));
+ }
+ num_acc_samps += num_rx_samps;
+ }
- //print the help message
- if (vm.count("help")){
- std::cout << boost::format("UHD Transport Hammer - %s") % desc << std::endl;
- return ~0;
+ if(num_acc_samps < total_num_samps) std::cerr << "Received timeout before all samples were received..." << std::endl;
+ else std::cout << boost::format("Successfully received %u samples.") % total_num_samps << std::endl;
+ }
}
+ else{
+ for(int i = int(rx_low); i <= int(rx_high); i += rx_step){
+ usrp->set_time_now(uhd::time_spec_t(0.0));
+
+ //Create a receive streamer
+ uhd::stream_args_t stream_args("fc32");
+ uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
+
+ //Set up streaming
+ std::cout << boost::format ("About to receive %u samples.") % i << std::endl;
+ uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
+ stream_cmd.num_samps = i;
+ stream_cmd.stream_now = true;
+ usrp->issue_stream_cmd(stream_cmd);
+
+ //Metadata will be filled in by recv()
+ uhd::rx_metadata_t md;
+
+ //Allocate buffer to receive with samples
+ std::vector<std::complex<float> > buff(rx_stream->get_max_num_samps());
+
+ double timeout = 1;
+
+ size_t num_acc_samps = 0; //Number of accumulated samples
+ while(int(num_acc_samps) < i){
+ //Receive a single packet
+ size_t num_rx_samps = rx_stream->recv(
+ &buff.front(), buff.size(), md, timeout, true
+ );
+
+ //Handle the error code
+ if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
+ if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE && md.error_code != uhd::rx_metadata_t::ERROR_CODE_OVERFLOW){
+ throw std::runtime_error(str(boost::format(
+ "Unexpected error code 0x%x"
+ ) % md.error_code));
+ }
+
+ if(verbose) std::cout << boost::format("Received %u samples.") % num_rx_samps << std::endl;
+
+ num_acc_samps += num_rx_samps;
- bool use_tx = vm.count("tx") > 0;
- bool rand_vals = vm.count("rand_vals") > 0;
- bool verbose = vm.count("verbose") > 0;
-
- if (use_tx)
- {
- //create a usrp device
- 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);
- std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl;
-
- //set the tx sample rate
- std::cout << boost::format("Setting TX Rate: %f Msps...") % (rate/1e6) << std::endl;
- usrp->set_tx_rate(rate);
- std::cout << boost::format("Actual TX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl;
- usrp->set_time_now(uhd::time_spec_t(0.0));
-
- //create a transmit streamer
- uhd::stream_args_t stream_args("fc32"); //complex floats
- uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
-
- //allocate buffer with data to send
- std::vector<std::complex<float> > buff(tx_stream->get_max_num_samps(), std::complex<float>(ampl, ampl));
-
- //setup metadata for the first packet
- uhd::tx_metadata_t md;
- md.start_of_burst = false;
- md.end_of_burst = false;
- md.has_time_spec = false;
- //md.time_spec = uhd::time_spec_t(seconds_in_future);
+ }
+ std::cout << boost::format("Successfully received %u samples.") % i << std::endl;
+ if (int(num_acc_samps) < i) std::cerr << "Timeout received before all samples were received..." << std::endl;
- if(rand_vals){
+ }
+ }
+}
- std::srand((unsigned int) time(NULL));
+/************************************************************************
+ * TX Samples
+ ************************************************************************/
- while(true){
- size_t total_num_samps = (rand() % (rand_end - rand_begin)) + rand_begin;
- size_t num_acc_samps = 0;
- float timeout = 0;
+void tx_hammer(uhd::usrp::multi_usrp::sptr usrp, double tx_rate, bool tx_rand, int tx_low, int tx_high, int tx_step, double tx_ampl, bool verbose){
+ uhd::set_thread_priority_safe();
- std::cout << "----------------------------------------" << std::endl;
- std::cout << boost::format("About to send %u samples.") % total_num_samps << std::endl << std::endl;
+ //Set the TX sample rate
+ std::cout << boost::format("Setting TX Rate: %f Msps...") % (tx_rate / 1e6) << std::endl;
+ usrp->set_tx_rate(tx_rate);
+ std::cout << boost::format("Actual TX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl;
+ usrp->set_time_now(uhd::time_spec_t(0.0));
- usrp->set_time_now(uhd::time_spec_t(0.0));
+ //Create a transmit streamer
+ uhd::stream_args_t stream_args("fc32"); //complex floats
+ uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
- while(num_acc_samps < total_num_samps){
- size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size());
- if(verbose) std::cout << boost::format("Sent %u samples.") % samps_to_send << std::endl;
+ //Allocate buffer with data to send
+ std::vector<std::complex<float> > buff(tx_stream->get_max_num_samps(), std::complex<float>(tx_ampl, tx_ampl));
+ //Setup metadata for the first packet
+ uhd::tx_metadata_t md;
+ md.start_of_burst = false;
+ md.end_of_burst = false;
+ md.has_time_spec = false;
- //send a single packet
- size_t num_tx_samps = tx_stream->send(&buff.front(), samps_to_send, md, timeout);
+ if(tx_rand){
+ std::srand((unsigned int) time(NULL));
- if(num_tx_samps < samps_to_send) std::cerr << "Send timeout..." << std::endl;
- //if(verbose) std::cout << boost::format("Sent packet: %u samples") % num_tx_samps << std::endl;
+ while(true){
+ size_t total_num_samps = (rand() % (tx_high - tx_low)) + tx_low;
+ size_t num_acc_samps = 0;
+ float timeout = 1;
- num_acc_samps += num_tx_samps;
- }
+ std::cout << boost::format("About to send %u samples.") % total_num_samps << std::endl;
- md.end_of_burst = true;
- tx_stream->send("", 0, md);
+ usrp->set_time_now(uhd::time_spec_t(0.0));
- if(verbose) std::cout << std::endl;
- std::cout << "Waiting for async burst ACK... " << std::endl << std::flush;
- uhd::async_metadata_t async_md;
- bool got_async_burst_ack = false;
- //loop through all messages for the ACK packet (may have underflow messages in queue)
- while (not got_async_burst_ack and usrp->get_device()->recv_async_msg(async_md, timeout)){
- got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK);
- }
- std::cout << (got_async_burst_ack? "Success!" : "Failure...") << std::endl << std::endl;
+ while(num_acc_samps < total_num_samps){
+ size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size());
- std::cout << boost::format("Successfully sent %u samples.") % total_num_samps << std::endl << "----------------------------------------" << std::endl << std::endl;
+ //Send a single packet
+ size_t num_tx_samps = tx_stream->send(&buff.front(), samps_to_send, md, timeout);
- boost::this_thread::sleep(boost::posix_time::microseconds(long(delay*1e6)));
+ if(num_tx_samps < samps_to_send) std::cerr << "Send timeout..." << std::endl;
+ num_acc_samps += num_tx_samps;
}
- }
- else{
- float timeout = 0;
+ md.end_of_burst = true;
+ tx_stream->send("", 0, md);
- if(verbose){
- std::cout << "About to start sending samples." << std::endl;
- std::cout << boost::format("Samples will start at %u and end with %u with steps of %u.") % samp_begin % samp_end % step << std::endl;
+ if(verbose) std::cout << std::endl;
+ std::cout << "Waiting for async burst ACK... " << std::flush;
+ uhd::async_metadata_t async_md;
+ bool got_async_burst_ack = false;
- boost::this_thread::sleep(boost::posix_time::seconds(2));
+ //Loop through all messages for the ACK packet (may have underflow messages in queue)
+ while (not got_async_burst_ack and usrp->get_device()->recv_async_msg(async_md, timeout)){
+ got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK);
}
+ std::cout << (got_async_burst_ack? "Success!" : "Failure...") << std::endl;
- for(int i = int(samp_begin); i <= int(samp_end); i += step){
-
- std::cout << "----------------------------------------" << std::endl;
-
- usrp->set_time_now(uhd::time_spec_t(0.0));
-
- std::cout << boost::format("About to send %u samples.") % i << std::endl;
- if(verbose) std::cout << std::endl;
-
- size_t num_acc_samps = 0; //number of accumulated samples
- total_num_samps = i;
-
- while(num_acc_samps < total_num_samps){
- size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size());
-
- if(verbose) std::cout << boost::format("Sent %u samples.") % samps_to_send << std::endl;
-
- //send a single packet
- size_t num_tx_samps = tx_stream->send(
- &buff.front(), samps_to_send, md, timeout
- );
-
- if (num_tx_samps < samps_to_send) std::cerr << "Send timeout..." << std::endl;
-
- num_acc_samps += num_tx_samps;
- }
-
- //send a mini EOB packet
- md.end_of_burst = true;
- tx_stream->send("", 0, md);
-
- std::cout << std::endl << "Waiting for async burst ACK... " << std::endl << std::flush;
- uhd::async_metadata_t async_md;
- bool got_async_burst_ack = false;
- //loop through all messages for the ACK packet (may have underflow messages in queue)
- while (not got_async_burst_ack and usrp->get_device()->recv_async_msg(async_md, timeout)){
- got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK);
- }
- std::cout << (got_async_burst_ack? "Success!" : "Failure...") << std::endl << std::endl;
-
- std::cout << boost::format("Successfully sent %u samples.") % i << std::endl << "----------------------------------------" << std::endl << std::endl;
+ std::cout << boost::format("Successfully sent %u samples.") % total_num_samps << std::endl;
- boost::this_thread::sleep(boost::posix_time::microseconds(long(delay*1e6)));
- }
-
- //finished
- std::cout << "Done!" << std::endl << std::endl;
}
-
- return 0;
}
- else
- {
- //create a usrp device
- 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);
- 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;
- usrp->set_rx_rate(rate);
- std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl;
-
-
-
- if(rand_vals){
- //random here
-
- std::srand((unsigned int) time(NULL));
+ else{
+ float timeout = 1;
- while(true){
- total_num_samps = (rand() % (rand_end - rand_begin)) + rand_begin;
+ for(int i = int(tx_low); i <= int(tx_high); i += tx_step){
- usrp->set_time_now(uhd::time_spec_t(0.0));
+ usrp->set_time_now(uhd::time_spec_t(0.0));
- //create a receive streamer
- uhd::stream_args_t stream_args("fc32"); //complex floats
- uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
+ std::cout << boost::format("About to send %u samples.") % i << std::endl;
+ if(verbose) std::cout << std::endl;
- std::cout << std::endl << "----------------------------------------" << std::endl;
- std::cout << boost::format("About to receive %u samples.") % total_num_samps << std::endl << std::endl;
+ size_t num_acc_samps = 0; //Number of accumulated samples
+ size_t total_num_samps = i;
- uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
- stream_cmd.num_samps = total_num_samps;
- stream_cmd.stream_now = true;
- usrp->issue_stream_cmd(stream_cmd);
+ while(num_acc_samps < total_num_samps){
+ size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size());
- //meta-data will be filled in by recv()
- uhd::rx_metadata_t md;
-
- //allocate buffer to receive with samples
- std::vector<std::complex<float> > buff(rx_stream->get_max_num_samps());
- double timeout = 0;
-
- size_t num_acc_samps = 0; //number of accumulated samples
- while(num_acc_samps < total_num_samps){
- //receive a single packet
- size_t num_rx_samps = rx_stream->recv(
- &buff.front(), buff.size(), md, timeout, true
- );
-
- //handle the error code
- if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
- if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){
- throw std::runtime_error(str(boost::format(
- "Unexpected error code 0x%x"
- ) % md.error_code));
- }
- if(verbose) std::cout << boost::format("Received %u samples.") % num_rx_samps << std::endl;
- num_acc_samps += num_rx_samps;
- }
- boost::this_thread::sleep(boost::posix_time::microseconds(long(delay*1e6)));
+ //Send a single packet
+ size_t num_tx_samps = tx_stream->send(
+ &buff.front(), samps_to_send, md, timeout
+ );
- if (num_acc_samps < total_num_samps) std::cerr << "Receive timeout before all samples received..." << std::endl;
+ if (num_tx_samps < samps_to_send) std::cerr << "Send timeout..." << std::endl;
- if(verbose) std::cout << std::endl;
- std::cout << boost::format("Successfully received %u samples.") % total_num_samps << std::endl << "----------------------------------------" << std::endl;
+ num_acc_samps += num_tx_samps;
}
- }
- else{
- if(verbose) {
- std::cout << std::endl << "About to start receiving samples." << std::endl;
- std::cout << boost::format("Samples will start at %u and end with %u with steps of %u.") % samp_begin % samp_end % step << std::endl << std::endl;
+ //Send a mini EOB packet
+ md.end_of_burst = true;
+ tx_stream->send("", 0, md);
- boost::this_thread::sleep(boost::posix_time::seconds(2));
+ std::cout << std::endl << "Waiting for async burst ACK... " << std::flush;
+ uhd::async_metadata_t async_md;
+ bool got_async_burst_ack = false;
+ //Loop through all messages for the ACK packet (may have underflow messages in queue)
+ while (not got_async_burst_ack and usrp->get_device()->recv_async_msg(async_md, timeout)){
+ got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK);
}
+ std::cout << (got_async_burst_ack? "Success!" : "Failure...") << std::endl;
- for(int i = int(samp_begin); i <= int(samp_end); i += step){
-
- usrp->set_time_now(uhd::time_spec_t(0.0));
-
- //create a receive streamer
- uhd::stream_args_t stream_args("fc32"); //complex floats
- uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
-
- //setup streaming
- std::cout << std::endl;
- std::cout << "----------------------------------------" << std::endl;
- std::cout << boost::format("About to receive %u samples.") % i << std::endl << std::endl;
- uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
- stream_cmd.num_samps = i;
- stream_cmd.stream_now = true;
- usrp->issue_stream_cmd(stream_cmd);
-
- //meta-data will be filled in by recv()
- uhd::rx_metadata_t md;
-
- //allocate buffer to receive with samples
- std::vector<std::complex<float> > buff(rx_stream->get_max_num_samps());
-
- double timeout = 0;
-
- size_t num_acc_samps = 0; //number of accumulated samples
- while(int(num_acc_samps) < i){
- //receive a single packet
- size_t num_rx_samps = rx_stream->recv(
- &buff.front(), buff.size(), md, timeout, true
- );
+ }
+ //Finished
+ std::cout << "Done!" << std::endl;
+ }
+}
- //handle the error code
- if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
- if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){
- throw std::runtime_error(str(boost::format(
- "Unexpected error code 0x%x"
- ) % md.error_code));
- }
+/************************************************************************
+ * Main code + dispatcher
+ ************************************************************************/
- if(verbose) std::cout << boost::format("Received %u samples.") % num_rx_samps << std::endl;
+int UHD_SAFE_MAIN(int argc, char *argv[]){
+ uhd::set_thread_priority_safe();
- num_acc_samps += num_rx_samps;
+ //Variables to be set by program options
+ std::string args;
+ double rx_rate;
+ int rx_low;
+ int rx_high;
+ int rx_step;
+ double tx_rate;
+ int tx_low;
+ int tx_high;
+ int tx_step;
+ double tx_ampl;
+
+ //Set up the program options
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "Print this help message.")
+ ("args", po::value<std::string>(&args)->default_value(""), "Single UHD device address args.")
+ ("rx_rate", po::value<double>(&rx_rate), "RX sample rate.")
+ ("rx_rand", "Specify to use random amounts of RX samples (between rx_low and rx_high values).")
+ ("rx_low", po::value<int>(&rx_low)->default_value(1), "Lowest value of RX samples.")
+ ("rx_high", po::value<int>(&rx_high)->default_value(10000), "Highest value of RX samples.")
+ ("rx_step", po::value<int>(&rx_step)->default_value(10), "Delta between number of collected RX samples.")
+ ("tx_rate", po::value<double>(&tx_rate), "TX sample rate.")
+ ("tx_rand", "Specify to use random amounts of TX samples (between tx_low and tx_high values).")
+ ("tx_low", po::value<int>(&tx_low)->default_value(1), "Lowest value of TX samples.")
+ ("tx_high", po::value<int>(&tx_high)->default_value(10000), "Highest value of TX samples.")
+ ("tx_step", po::value<int>(&tx_step)->default_value(10), "Delta between number of sent TX samples.")
+ ("tx_ampl", po::value<double>(&tx_ampl)->default_value(0.5), "TX amplitude.")
+ ("verbose", "Enables verbosity")
+ ;
+ po::variables_map vm;
+ po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::notify(vm);
- }
- if(verbose) std::cout << std::endl;
- std::cout << boost::format("Successfully received %u samples.") % i << std::endl << "----------------------------------------" << std::endl;
+ //Set verbose or RX/TX random if requested by user
+ bool rx_rand = vm.count("rx_rand") > 0;
+ bool tx_rand = vm.count("tx_rand") > 0;
+ bool verbose = vm.count("verbose") > 0;
- boost::this_thread::sleep(boost::posix_time::microseconds(long(delay*1e6)));
+ //Print the help message
+
+ if (vm.count("help") or (vm.count("rx_rate") + vm.count("tx_rate")) == 0){
+ std::cout << boost::format("UHD Transport Hammer %s") % desc << std::endl;
+ std::cout <<
+ " Specify --rx_rate for a receive-only test.\n"
+ " Specify --tx_rate for a transmit-only test.\n"
+ " Specify both options for a full-duplex test.\n"
+ << std::endl;
+ return ~0;
+ }
+
+ //Create a USRP device
+ std::cout << std::endl;
+ uhd::device_addrs_t device_addrs = uhd::device::find(args);
+ 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);
+ std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl;
+
+ boost::thread_group thread_group;
+
+ //Spawn the receive test thread
+ if (vm.count("rx_rate")){
+ usrp->set_rx_rate(rx_rate);
+ thread_group.create_thread(boost::bind(&rx_hammer, usrp, rx_rate, rx_rand, rx_low, rx_high, rx_step, verbose));
+ }
+
+ //Spawn the transmit test thread
+ if (vm.count("tx_rate")){
+ usrp->set_tx_rate(tx_rate);
+ thread_group.create_thread(boost::bind(&tx_hammer, usrp, tx_rate, tx_rand, tx_low, tx_high, tx_step, tx_ampl, verbose));
+ }
- //std::cout << boost::format("num_acc_samps=%u, i=%u") % num_acc_samps % i << std::endl;
+ //Interrupt and join the threads
+ boost::this_thread::sleep(boost::posix_time::microseconds(long(1e6)));
+ thread_group.interrupt_all();
+ thread_group.join_all();
+ //Finished
+ std::cout << std::endl << "Done!" << std::endl << std::endl;
- if (int(num_acc_samps) < i) std::cerr << "Receive timeout before all samples received..." << std::endl;
- }
- }
return 0;
- }
}
diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp
index 88affa40c..429ae356b 100644
--- a/host/include/uhd/usrp/multi_usrp.hpp
+++ b/host/include/uhd/usrp/multi_usrp.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2012 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
@@ -25,6 +25,7 @@
#define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
#define UHD_USRP_MULTI_USRP_BW_RANGE_API
#define UHD_USRP_MULTI_USRP_USER_REGS_API
+#define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
#include <uhd/config.hpp>
#include <uhd/device.hpp>
@@ -127,6 +128,24 @@ public:
return this->get_device()->get_tx_stream(args);
}
+ /*!
+ * Returns identifying information about this USRP's configuration.
+ * Returns motherboard ID, name, and serial.
+ * Returns daughterboard RX ID, subdev name, and serial.
+ * \param chan channel index 0 to N-1
+ * \return RX info
+ */
+ virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
+
+ /*!
+ * Returns identifying information about this USRP's configuration.
+ * Returns motherboard ID, name, and serial.
+ * Returns daughterboard TX ID, subdev name, and serial.
+ * \param chan channel index 0 to N-1
+ * \return TX info
+ */
+ virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
+
/*******************************************************************
* Mboard methods
******************************************************************/
diff --git a/host/include/uhd/version.hpp b/host/include/uhd/version.hpp
index ee0c4fe43..9a95b4786 100644
--- a/host/include/uhd/version.hpp
+++ b/host/include/uhd/version.hpp
@@ -27,7 +27,7 @@
* The format is oldest ABI compatible release - ABI compat number.
* The compatibility number allows pre-release ABI to be versioned.
*/
-#define UHD_VERSION_ABI_STRING "3.4.0-0"
+#define UHD_VERSION_ABI_STRING "3.4.0-1"
namespace uhd{
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp
index 4b60f111c..cf8db1927 100644
--- a/host/lib/usrp/cores/rx_dsp_core_200.cpp
+++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp
@@ -38,13 +38,12 @@
#define REG_RX_CTRL_STREAM_CMD _ctrl_base + 0
#define REG_RX_CTRL_TIME_HI _ctrl_base + 4
#define REG_RX_CTRL_TIME_LO _ctrl_base + 8
-#define REG_RX_CTRL_CLEAR _ctrl_base + 12
+#define REG_RX_CTRL_FORMAT _ctrl_base + 12
#define REG_RX_CTRL_VRT_HDR _ctrl_base + 16
#define REG_RX_CTRL_VRT_SID _ctrl_base + 20
#define REG_RX_CTRL_VRT_TLR _ctrl_base + 24
#define REG_RX_CTRL_NSAMPS_PP _ctrl_base + 28
#define REG_RX_CTRL_NCHANNELS _ctrl_base + 32
-#define REG_RX_CTRL_FORMAT REG_RX_CTRL_CLEAR //re-use clear address
template <class T> T ceil_log2(T num){
return std::ceil(std::log(num)/std::log(T(2)));
@@ -78,8 +77,7 @@ public:
}
void clear(void){
- _iface->poke32(REG_RX_CTRL_CLEAR, 1); //reset
- _iface->poke32(REG_RX_CTRL_NCHANNELS, 1);
+ _iface->poke32(REG_RX_CTRL_NCHANNELS, 1); //also reset
_iface->poke32(REG_RX_CTRL_VRT_HDR, 0
| (0x1 << 28) //if data with stream id
| (0x1 << 26) //has trailer
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index e2efa9a00..43dd3bf14 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2012 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
@@ -21,6 +21,10 @@
#include <uhd/exception.hpp>
#include <uhd/utils/msg.hpp>
#include <uhd/utils/gain_group.hpp>
+#include <uhd/usrp/dboard_id.hpp>
+#include <uhd/usrp/mboard_eeprom.hpp>
+#include <uhd/usrp/dboard_eeprom.hpp>
+#include <boost/assign/list_of.hpp>
#include <boost/thread.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
@@ -214,6 +218,48 @@ public:
return _dev;
}
+ dict<std::string, std::string> get_usrp_rx_info(size_t chan){
+ mboard_chan_pair mcp = rx_chan_to_mcp(chan);
+ dict<std::string, std::string> usrp_info;
+
+ mboard_eeprom_t mb_eeprom = _tree->access<mboard_eeprom_t>(mb_root(mcp.mboard) / "eeprom").get();
+ dboard_eeprom_t db_eeprom = _tree->access<dboard_eeprom_t>(rx_rf_fe_root(mcp.chan).branch_path().branch_path() / "rx_eeprom").get();
+
+ usrp_info["mboard_id"] = _tree->access<std::string>(mb_root(mcp.mboard) / "name").get();
+ usrp_info["mboard_name"] = mb_eeprom["name"];
+ usrp_info["mboard_serial"] = mb_eeprom["serial"];
+ usrp_info["rx_id"] = db_eeprom.id.to_pp_string();
+ usrp_info["rx_subdev_name"] = _tree->access<std::string>(rx_rf_fe_root(mcp.chan) / "name").get();
+ usrp_info["rx_subdev_spec"] = _tree->access<subdev_spec_t>(mb_root(mcp.mboard) / "rx_subdev_spec").get().to_string();
+ usrp_info["rx_serial"] = db_eeprom.serial;
+ usrp_info["rx_antenna"] = _tree->access<std::string>(rx_rf_fe_root(mcp.chan) / "antenna" / "value").get();
+
+ return usrp_info;
+ }
+
+ dict<std::string, std::string> get_usrp_tx_info(size_t chan){
+ mboard_chan_pair mcp = tx_chan_to_mcp(chan);
+ dict<std::string, std::string> usrp_info;
+
+ mboard_eeprom_t mb_eeprom = _tree->access<mboard_eeprom_t>(mb_root(mcp.mboard) / "eeprom").get();
+ dboard_eeprom_t gdb_eeprom = _tree->access<dboard_eeprom_t>(tx_rf_fe_root(mcp.chan).branch_path().branch_path() / "gdb_eeprom").get();
+ dboard_eeprom_t db_eeprom;
+
+ if(gdb_eeprom.id != dboard_id_t::none()) db_eeprom = gdb_eeprom;
+ else db_eeprom = _tree->access<dboard_eeprom_t>(tx_rf_fe_root(mcp.chan).branch_path().branch_path() / "tx_eeprom").get();
+
+ usrp_info["mboard_id"] = _tree->access<std::string>(mb_root(mcp.mboard) / "name").get();
+ usrp_info["mboard_name"] = mb_eeprom["name"];
+ usrp_info["mboard_serial"] = mb_eeprom["serial"];
+ usrp_info["tx_id"] = db_eeprom.id.to_pp_string();
+ usrp_info["tx_subdev_name"] = _tree->access<std::string>(tx_rf_fe_root(mcp.chan) / "name").get();
+ usrp_info["tx_subdev_spec"] = _tree->access<subdev_spec_t>(mb_root(mcp.mboard) / "tx_subdev_spec").get().to_string();
+ usrp_info["tx_serial"] = db_eeprom.serial;
+ usrp_info["tx_antenna"] = _tree->access<std::string>(tx_rf_fe_root(mcp.chan) / "antenna" / "value").get();
+
+ return usrp_info;
+ }
+
/*******************************************************************
* Mboard methods
******************************************************************/
@@ -394,8 +440,8 @@ public:
std::string clock_source;
switch(clock_config.ref_source){
case clock_config_t::REF_INT: clock_source = "internal"; break;
- case clock_config_t::PPS_SMA: clock_source = "external"; break;
- case clock_config_t::PPS_MIMO: clock_source = "mimo"; break;
+ case clock_config_t::REF_SMA: clock_source = "external"; break;
+ case clock_config_t::REF_MIMO: clock_source = "mimo"; break;
default: clock_source = "unknown";
}
this->set_clock_source(clock_source, mboard);
@@ -636,10 +682,6 @@ public:
return _tree->access<subdev_spec_t>(mb_root(mboard) / "tx_subdev_spec").get();
}
- std::string get_tx_subdev_name(size_t chan){
- return _tree->access<std::string>(tx_rf_fe_root(chan) / "name").get();
- }
-
size_t get_tx_num_channels(void){
size_t sum = 0;
for (size_t m = 0; m < get_num_mboards(); m++){
@@ -648,6 +690,10 @@ public:
return sum;
}
+ std::string get_tx_subdev_name(size_t chan){
+ return _tree->access<std::string>(tx_rf_fe_root(chan) / "name").get();
+ }
+
void set_tx_rate(double rate, size_t chan){
if (chan != ALL_CHANS){
_tree->access<double>(tx_dsp_root(chan) / "rate" / "value").set(rate);