summaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2013-07-15 15:44:42 -0700
committerJosh Blum <josh@joshknows.com>2013-07-15 15:44:42 -0700
commitc464a63e87e32bea2b4c430ff29b0b5e0829893a (patch)
tree9e6967a7e9f1e4d2b17c43d3bb497709f2fdeb8a /host/examples
parent1f97c6c1e1ed05dbef94f74f52f1ed3370ebfd26 (diff)
downloaduhd-c464a63e87e32bea2b4c430ff29b0b5e0829893a.tar.gz
uhd-c464a63e87e32bea2b4c430ff29b0b5e0829893a.tar.bz2
uhd-c464a63e87e32bea2b4c430ff29b0b5e0829893a.zip
uhd: added new calls to streamer object + support work
* The transmit streamer gives access to the async msg queue. * The receive streamer gives access to the issue stream cmd. * Supporting usrp implementation files updated. * Example applications updated to use this API.
Diffstat (limited to 'host/examples')
-rw-r--r--host/examples/benchmark_rate.cpp62
-rw-r--r--host/examples/latency_test.cpp4
-rw-r--r--host/examples/rx_ascii_art_dft.cpp4
-rw-r--r--host/examples/rx_multi_samples.cpp2
-rw-r--r--host/examples/rx_samples_to_file.cpp2
-rw-r--r--host/examples/rx_samples_to_udp.cpp2
-rw-r--r--host/examples/rx_timed_samples.cpp2
-rw-r--r--host/examples/test_messages.cpp20
-rw-r--r--host/examples/test_timed_commands.cpp2
-rw-r--r--host/examples/transport_hammer.cpp47
-rw-r--r--host/examples/tx_bursts.cpp2
-rw-r--r--host/examples/tx_timed_samples.cpp2
-rw-r--r--host/examples/txrx_loopback_to_file.cpp2
13 files changed, 80 insertions, 73 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp
index ed3a8580a..3a69e001b 100644
--- a/host/examples/benchmark_rate.cpp
+++ b/host/examples/benchmark_rate.cpp
@@ -42,37 +42,32 @@ unsigned long long num_seq_errors = 0;
/***********************************************************************
* Benchmark RX Rate
**********************************************************************/
-void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, const std::string &rx_otw){
+void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, uhd::rx_streamer::sptr rx_stream){
uhd::set_thread_priority_safe();
- //create a receive streamer
- uhd::stream_args_t stream_args(rx_cpu, rx_otw);
- for (size_t ch = 0; ch < usrp->get_num_mboards(); ch++) //linear channel mapping
- stream_args.channels.push_back(ch);
- uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
-
//print pre-test summary
std::cout << boost::format(
- "Testing receive rate %f Msps"
- ) % (usrp->get_rx_rate()/1e6) << std::endl;
+ "Testing receive rate %f Msps on %u channels"
+ ) % (usrp->get_rx_rate()/1e6) % rx_stream->get_num_channels() << std::endl;
//setup variables and allocate buffer
uhd::rx_metadata_t md;
const size_t max_samps_per_packet = rx_stream->get_max_num_samps();
std::vector<char> buff(max_samps_per_packet*uhd::convert::get_bytes_per_item(rx_cpu));
std::vector<void *> buffs;
- for (size_t ch = 0; ch < stream_args.channels.size(); ch++)
+ for (size_t ch = 0; ch < rx_stream->get_num_channels(); ch++)
buffs.push_back(&buff.front()); //same buffer for each channel
bool had_an_overflow = false;
uhd::time_spec_t last_time;
const double rate = usrp->get_rx_rate();
+ issue_new_stream_cmd:
uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
cmd.time_spec = usrp->get_time_now() + uhd::time_spec_t(0.05);
cmd.stream_now = (buffs.size() == 1);
- usrp->issue_stream_cmd(cmd);
+ rx_stream->issue_stream_cmd(cmd);
while (not boost::this_thread::interruption_requested()){
- num_rx_samps += rx_stream->recv(buffs, max_samps_per_packet, md);
+ num_rx_samps += rx_stream->recv(buffs, max_samps_per_packet, md)*rx_stream->get_num_channels();
//handle the error codes
switch(md.error_code){
@@ -87,6 +82,11 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_c
had_an_overflow = true;
last_time = md.time_spec;
num_overflows++;
+ if (rx_stream->get_num_channels() > 1)
+ {
+ rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
+ goto issue_new_stream_cmd;
+ }
break;
default:
@@ -96,25 +96,19 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_c
}
}
- usrp->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
+ rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
}
/***********************************************************************
* Benchmark TX Rate
**********************************************************************/
-void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_cpu, const std::string &tx_otw){
+void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_cpu, uhd::tx_streamer::sptr tx_stream){
uhd::set_thread_priority_safe();
- //create a transmit streamer
- uhd::stream_args_t stream_args(tx_cpu, tx_otw);
- for (size_t ch = 0; ch < usrp->get_num_mboards(); ch++) //linear channel mapping
- stream_args.channels.push_back(ch);
- uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
-
//print pre-test summary
std::cout << boost::format(
- "Testing transmit rate %f Msps"
- ) % (usrp->get_tx_rate()/1e6) << std::endl;
+ "Testing transmit rate %f Msps on %u channels"
+ ) % (usrp->get_tx_rate()/1e6) % tx_stream->get_num_channels() << std::endl;
//setup variables and allocate buffer
uhd::tx_metadata_t md;
@@ -122,12 +116,12 @@ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_c
const size_t max_samps_per_packet = tx_stream->get_max_num_samps();
std::vector<char> buff(max_samps_per_packet*uhd::convert::get_bytes_per_item(tx_cpu));
std::vector<const void *> buffs;
- for (size_t ch = 0; ch < stream_args.channels.size(); ch++)
+ for (size_t ch = 0; ch < tx_stream->get_num_channels(); ch++)
buffs.push_back(&buff.front()); //same buffer for each channel
md.has_time_spec = (buffs.size() != 1);
while (not boost::this_thread::interruption_requested()){
- num_tx_samps += tx_stream->send(buffs, max_samps_per_packet, md);
+ num_tx_samps += tx_stream->send(buffs, max_samps_per_packet, md)*tx_stream->get_num_channels();;
md.has_time_spec = false;
}
@@ -136,13 +130,13 @@ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_c
tx_stream->send(buffs, 0, md);
}
-void benchmark_tx_rate_async_helper(uhd::usrp::multi_usrp::sptr usrp){
+void benchmark_tx_rate_async_helper(uhd::tx_streamer::sptr tx_stream){
//setup variables and allocate buffer
uhd::async_metadata_t async_md;
while (not boost::this_thread::interruption_requested()){
- if (not usrp->get_device()->recv_async_msg(async_md)) continue;
+ if (not tx_stream->recv_async_msg(async_md)) continue;
//handle the error codes
switch(async_md.event_code){
@@ -232,14 +226,24 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//spawn the receive test thread
if (vm.count("rx_rate")){
usrp->set_rx_rate(rx_rate);
- thread_group.create_thread(boost::bind(&benchmark_rx_rate, usrp, rx_cpu, rx_otw));
+ //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);
+ 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));
}
//spawn the transmit test thread
if (vm.count("tx_rate")){
usrp->set_tx_rate(tx_rate);
- thread_group.create_thread(boost::bind(&benchmark_tx_rate, usrp, tx_cpu, tx_otw));
- thread_group.create_thread(boost::bind(&benchmark_tx_rate_async_helper, usrp));
+ //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);
+ 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));
}
//sleep for the required duration
diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp
index 461ac9bf8..da06086f9 100644
--- a/host/examples/latency_test.cpp
+++ b/host/examples/latency_test.cpp
@@ -103,7 +103,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
stream_cmd.num_samps = buffer.size();
stream_cmd.stream_now = false;
stream_cmd.time_spec = usrp->get_time_now() + uhd::time_spec_t(0.01);
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
/***************************************************************
* Receive the requested packet
@@ -133,7 +133,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
* Check the async messages for result
**************************************************************/
uhd::async_metadata_t async_md;
- if (not usrp->get_device()->recv_async_msg(async_md)){
+ if (not tx_stream->recv_async_msg(async_md)){
std::cout << boost::format("failed:\n Async message recv timed out.\n") << std::endl;
continue;
}
diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp
index 1aede51a4..df3256b09 100644
--- a/host/examples/rx_ascii_art_dft.cpp
+++ b/host/examples/rx_ascii_art_dft.cpp
@@ -148,7 +148,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//-- Initialize
//------------------------------------------------------------------
initscr(); //curses init
- usrp->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+ rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
boost::system_time next_refresh = boost::get_system_time();
//------------------------------------------------------------------
@@ -189,7 +189,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//------------------------------------------------------------------
//-- Cleanup
//------------------------------------------------------------------
- usrp->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
+ rx_stream->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
endwin(); //curses done
//finished
diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp
index 83d648eb5..4f312ad36 100644
--- a/host/examples/rx_multi_samples.cpp
+++ b/host/examples/rx_multi_samples.cpp
@@ -126,7 +126,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
stream_cmd.num_samps = total_num_samps;
stream_cmd.stream_now = false;
stream_cmd.time_spec = uhd::time_spec_t(seconds_in_future);
- usrp->issue_stream_cmd(stream_cmd); //tells all channels to stream
+ rx_stream->issue_stream_cmd(stream_cmd); //tells all channels to stream
//meta-data will be filled in by recv()
uhd::rx_metadata_t md;
diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp
index d0a02a6c1..1e833defa 100644
--- a/host/examples/rx_samples_to_file.cpp
+++ b/host/examples/rx_samples_to_file.cpp
@@ -58,7 +58,7 @@ template<typename samp_type> void recv_to_file(
stream_cmd.num_samps = num_requested_samples;
stream_cmd.stream_now = true;
stream_cmd.time_spec = uhd::time_spec_t();
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
while(not stop_signal_called and (num_requested_samples != num_total_samps or num_requested_samples == 0)){
size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md, 3.0);
diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp
index f637f9313..0b3c6dce3 100644
--- a/host/examples/rx_samples_to_udp.cpp
+++ b/host/examples/rx_samples_to_udp.cpp
@@ -127,7 +127,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
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);
+ rx_stream->issue_stream_cmd(stream_cmd);
//loop until total number of samples reached
size_t num_acc_samps = 0; //number of accumulated samples
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index f0d49b4bd..0eea2ffee 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -83,7 +83,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
stream_cmd.num_samps = total_num_samps;
stream_cmd.stream_now = false;
stream_cmd.time_spec = uhd::time_spec_t(seconds_in_future);
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
//meta-data will be filled in by recv()
uhd::rx_metadata_t md;
diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp
index 6f2ddfe28..e39a8bd30 100644
--- a/host/examples/test_messages.cpp
+++ b/host/examples/test_messages.cpp
@@ -46,7 +46,7 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame
stream_cmd.num_samps = rx_stream->get_max_num_samps();
stream_cmd.stream_now = false;
stream_cmd.time_spec = uhd::time_spec_t(100.0); //time in the past
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
std::vector<std::complex<float> > buff(rx_stream->get_max_num_samps());
uhd::rx_metadata_t md;
@@ -90,7 +90,7 @@ bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE);
stream_cmd.stream_now = true;
stream_cmd.num_samps = rx_stream->get_max_num_samps();
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
std::vector<std::complex<float> > buff(rx_stream->get_max_num_samps());
uhd::rx_metadata_t md;
@@ -132,7 +132,7 @@ bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame
* Send a burst of many samples that will fragment internally.
* We expect to get an burst ack async message.
*/
-bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){
+bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){
std::cout << "Test burst ack message... " << std::flush;
uhd::tx_metadata_t md;
@@ -148,7 +148,7 @@ bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::
);
uhd::async_metadata_t async_md;
- if (not usrp->get_device()->recv_async_msg(async_md)){
+ if (not tx_stream->recv_async_msg(async_md)){
std::cout << boost::format(
"failed:\n"
" Async message recv timed out.\n"
@@ -178,7 +178,7 @@ bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::
* Send a start of burst packet with no following end of burst.
* We expect to get an underflow(within a burst) async message.
*/
-bool test_underflow_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){
+bool test_underflow_message(uhd::usrp::multi_usrp::sptr, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){
std::cout << "Test underflow message... " << std::flush;
uhd::tx_metadata_t md;
@@ -189,7 +189,7 @@ bool test_underflow_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::
tx_stream->send("", 0, md);
uhd::async_metadata_t async_md;
- if (not usrp->get_device()->recv_async_msg(async_md, 1)){
+ if (not tx_stream->recv_async_msg(async_md, 1)){
std::cout << boost::format(
"failed:\n"
" Async message recv timed out.\n"
@@ -233,7 +233,7 @@ bool test_time_error_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer:
tx_stream->send("", 0, md);
uhd::async_metadata_t async_md;
- if (not usrp->get_device()->recv_async_msg(async_md)){
+ if (not tx_stream->recv_async_msg(async_md)){
std::cout << boost::format(
"failed:\n"
" Async message recv timed out.\n"
@@ -258,9 +258,9 @@ bool test_time_error_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer:
}
}
-void flush_async(uhd::usrp::multi_usrp::sptr usrp){
+void flush_async(uhd::tx_streamer::sptr tx_stream){
uhd::async_metadata_t async_md;
- while (usrp->get_device()->recv_async_msg(async_md)){}
+ while (tx_stream->recv_async_msg(async_md)){}
}
void flush_recv(uhd::rx_streamer::sptr rx_stream){
@@ -331,7 +331,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
for (size_t n = 0; n < ntests; n++){
std::string key = tests.keys()[std::rand() % tests.size()];
bool pass = tests[key](usrp, rx_stream, tx_stream);
- flush_async(usrp);
+ flush_async(tx_stream);
flush_recv(rx_stream);
//store result
diff --git a/host/examples/test_timed_commands.cpp b/host/examples/test_timed_commands.cpp
index cecf1607c..5dee58887 100644
--- a/host/examples/test_timed_commands.cpp
+++ b/host/examples/test_timed_commands.cpp
@@ -97,7 +97,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
stream_cmd.stream_now = true;
const uhd::time_spec_t stream_time = usrp->get_time_now() + uhd::time_spec_t(0.1);
usrp->set_command_time(stream_time);
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
usrp->clear_command_time();
//meta-data will be filled in by recv()
diff --git a/host/examples/transport_hammer.cpp b/host/examples/transport_hammer.cpp
index ff35ceb21..a44e81a82 100644
--- a/host/examples/transport_hammer.cpp
+++ b/host/examples/transport_hammer.cpp
@@ -41,15 +41,9 @@ unsigned long long num_seq_errors = 0;
/***********************************************************************
* RX Hammer
**********************************************************************/
-void rx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, const std::string &rx_otw){
+void rx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, uhd::rx_streamer::sptr rx_stream){
uhd::set_thread_priority_safe();
- //create a receive streamer
- uhd::stream_args_t stream_args(rx_cpu, rx_otw);
- for (size_t ch = 0; ch < usrp->get_num_mboards(); ch++) //linear channel mapping
- stream_args.channels.push_back(ch);
- uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
-
//print pre-test summary
std::cout << boost::format(
"Testing receive rate %f Msps"
@@ -60,7 +54,7 @@ void rx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, cons
const size_t max_samps_per_packet = rx_stream->get_max_num_samps();
std::vector<char> buff(max_samps_per_packet*uhd::convert::get_bytes_per_item(rx_cpu));
std::vector<void *> buffs;
- for (size_t ch = 0; ch < stream_args.channels.size(); ch++)
+ for (size_t ch = 0; ch < rx_stream->get_num_channels(); ch++)
buffs.push_back(&buff.front()); //same buffer for each channel
bool had_an_overflow = false;
uhd::time_spec_t last_time;
@@ -74,7 +68,7 @@ void rx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, cons
while (not boost::this_thread::interruption_requested()){
cmd.num_samps = rand() % 100000;
- usrp->issue_stream_cmd(cmd);
+ rx_stream->issue_stream_cmd(cmd);
num_rx_samps += rx_stream->recv(buffs, max_samps_per_packet, md, timeout, true);
//handle the error codes
@@ -103,16 +97,15 @@ void rx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &rx_cpu, cons
/***********************************************************************
* TX Hammer
**********************************************************************/
-void tx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_cpu, const std::string &tx_otw){
+void tx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_cpu, uhd::tx_streamer::sptr tx_stream){
uhd::set_thread_priority_safe();
- //create a transmit streamer
- uhd::stream_args_t stream_args(tx_cpu, tx_otw);
- for (size_t ch = 0; ch < usrp->get_num_mboards(); ch++) //linear channel mapping
- stream_args.channels.push_back(ch);
- uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
uhd::tx_metadata_t md;
- std::vector<std::complex<float> > buff(10000);
+ const size_t max_samps_per_packet = tx_stream->get_max_num_samps();
+ std::vector<char> buff(max_samps_per_packet*uhd::convert::get_bytes_per_item(tx_cpu));
+ std::vector<void *> buffs;
+ for (size_t ch = 0; ch < tx_stream->get_num_channels(); ch++)
+ buffs.push_back(&buff.front()); //same buffer for each channel
//print pre-test summary
std::cout << boost::format(
@@ -130,7 +123,7 @@ void tx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_cpu, cons
while(num_acc_samps < total_num_samps){
//send a single packet
- num_tx_samps += tx_stream->send(&buff, tx_stream->get_max_num_samps(), md, timeout);
+ num_tx_samps += tx_stream->send(buffs, max_samps_per_packet, md, timeout);
num_acc_samps += std::min(total_num_samps-num_acc_samps, tx_stream->get_max_num_samps());
}
@@ -140,13 +133,13 @@ void tx_hammer(uhd::usrp::multi_usrp::sptr usrp, const std::string &tx_cpu, cons
}
}
-void tx_hammer_async_helper(uhd::usrp::multi_usrp::sptr usrp){
+void tx_hammer_async_helper(uhd::tx_streamer::sptr tx_stream){
//setup variables and allocate buffer
uhd::async_metadata_t async_md;
while (not boost::this_thread::interruption_requested()){
- if (not usrp->get_device()->recv_async_msg(async_md)) continue;
+ if (not tx_stream->recv_async_msg(async_md)) continue;
//handle the error codes
switch(async_md.event_code){
@@ -239,14 +232,24 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//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_cpu, rx_otw));
+ //create a receive streamer
+ uhd::stream_args_t stream_args(rx_cpu, rx_otw);
+ for (size_t ch = 0; ch < usrp->get_num_mboards(); ch++) //linear channel mapping
+ stream_args.channels.push_back(ch);
+ uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
+ thread_group.create_thread(boost::bind(&rx_hammer, usrp, rx_cpu, rx_stream));
}
//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_cpu, tx_otw));
- thread_group.create_thread(boost::bind(&tx_hammer_async_helper, usrp));
+ //create a transmit streamer
+ uhd::stream_args_t stream_args(tx_cpu, tx_otw);
+ for (size_t ch = 0; ch < usrp->get_num_mboards(); ch++) //linear channel mapping
+ stream_args.channels.push_back(ch);
+ uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
+ thread_group.create_thread(boost::bind(&tx_hammer, usrp, tx_cpu, tx_stream));
+ thread_group.create_thread(boost::bind(&tx_hammer_async_helper, tx_stream));
}
//sleep for the required duration
diff --git a/host/examples/tx_bursts.cpp b/host/examples/tx_bursts.cpp
index 8dd4a002c..c58d3e178 100644
--- a/host/examples/tx_bursts.cpp
+++ b/host/examples/tx_bursts.cpp
@@ -147,7 +147,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
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, seconds_in_future)){
+ while (not got_async_burst_ack and tx_stream->recv_async_msg(async_md, seconds_in_future)){
got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK);
}
std::cout << (got_async_burst_ack? "success" : "fail") << std::endl;
diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp
index 4cc31a7c0..2eef80389 100644
--- a/host/examples/tx_timed_samples.cpp
+++ b/host/examples/tx_timed_samples.cpp
@@ -116,7 +116,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
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)){
+ while (not got_async_burst_ack and tx_stream->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" : "fail") << std::endl;
diff --git a/host/examples/txrx_loopback_to_file.cpp b/host/examples/txrx_loopback_to_file.cpp
index 9dc348da8..ef119b689 100644
--- a/host/examples/txrx_loopback_to_file.cpp
+++ b/host/examples/txrx_loopback_to_file.cpp
@@ -151,7 +151,7 @@ template<typename samp_type> void recv_to_file(
stream_cmd.num_samps = num_requested_samples;
stream_cmd.stream_now = false;
stream_cmd.time_spec = uhd::time_spec_t(settling_time);
- usrp->issue_stream_cmd(stream_cmd);
+ rx_stream->issue_stream_cmd(stream_cmd);
while(not stop_signal_called and (num_requested_samples != num_total_samps or num_requested_samples == 0)){
size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md, timeout);