From a629bbe7e3c39a10bdc3a981f6badb85a436b443 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Oct 2011 11:59:27 -0700 Subject: uhd: updated examples to use new streamer interface --- host/examples/benchmark_rate.cpp | 31 +++++++------- host/examples/latency_test.cpp | 17 ++++---- host/examples/rx_ascii_art_dft.cpp | 10 +++-- host/examples/rx_multi_samples.cpp | 15 ++++--- host/examples/rx_samples_to_file.cpp | 17 ++++---- host/examples/rx_samples_to_udp.cpp | 12 +++--- host/examples/rx_timed_samples.cpp | 12 +++--- host/examples/test_messages.cpp | 75 ++++++++++++++-------------------- host/examples/tx_bursts.cpp | 14 ++++--- host/examples/tx_samples_from_file.cpp | 17 ++++---- host/examples/tx_timed_samples.cpp | 17 ++++---- host/examples/tx_waveforms.cpp | 18 ++++---- 12 files changed, 128 insertions(+), 127 deletions(-) (limited to 'host/examples') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 774b240d4..7862bd44b 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -43,6 +43,10 @@ unsigned long long num_seq_errors = 0; void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ uhd::set_thread_priority_safe(); + //create a receive streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + //print pre-test summary std::cout << boost::format( "Testing receive rate %f Msps" @@ -50,7 +54,7 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ //setup variables and allocate buffer uhd::rx_metadata_t md; - const size_t max_samps_per_packet = usrp->get_device()->get_max_recv_samps_per_packet(); + const size_t max_samps_per_packet = rx_stream->get_max_num_samps(); std::vector > buff(max_samps_per_packet); bool had_an_overflow = false; uhd::time_spec_t last_time; @@ -58,10 +62,8 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ usrp->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); while (not boost::this_thread::interruption_requested()){ - num_rx_samps += usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET + num_rx_samps += rx_stream->recv( + &buff.front(), buff.size(), md ); //handle the error codes @@ -95,6 +97,10 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp){ uhd::set_thread_priority_safe(); + //create a transmit streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + //print pre-test summary std::cout << boost::format( "Testing transmit rate %f Msps" @@ -103,23 +109,16 @@ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp){ //setup variables and allocate buffer uhd::tx_metadata_t md; md.has_time_spec = false; - const size_t max_samps_per_packet = usrp->get_device()->get_max_send_samps_per_packet(); + const size_t max_samps_per_packet = tx_stream->get_max_num_samps(); std::vector > buff(max_samps_per_packet); while (not boost::this_thread::interruption_requested()){ - num_tx_samps += usrp->get_device()->send( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_ONE_PACKET - ); + num_tx_samps += tx_stream->send(&buff.front(), buff.size(), md); } //send a mini EOB packet - md.end_of_burst = true; - usrp->get_device()->send("", 0, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF - ); + md.end_of_burst = true; + tx_stream->send("", 0, md); } void benchmark_tx_rate_async_helper(uhd::usrp::multi_usrp::sptr usrp){ diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp index 85ac73567..b995b0433 100644 --- a/host/examples/latency_test.cpp +++ b/host/examples/latency_test.cpp @@ -83,6 +83,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //allocate a buffer to use std::vector > buffer(nsamps); + //create RX and TX streamers + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + //initialize result counts int time_error = 0; int ack = 0; @@ -104,10 +109,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ * Receive the requested packet **************************************************************/ uhd::rx_metadata_t rx_md; - size_t num_rx_samps = usrp->get_device()->recv( - &buffer.front(), buffer.size(), rx_md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_FULL_BUFF + size_t num_rx_samps = rx_stream->recv( + &buffer.front(), buffer.size(), rx_md ); if(verbose) std::cout << boost::format("Got packet: %u samples, %u full secs, %f frac secs") @@ -121,10 +124,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ tx_md.end_of_burst = true; tx_md.has_time_spec = true; tx_md.time_spec = rx_md.time_spec + uhd::time_spec_t(rtt); - size_t num_tx_samps = usrp->get_device()->send( - &buffer.front(), buffer.size(), tx_md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF + size_t num_tx_samps = tx_stream->send( + &buffer.front(), buffer.size(), tx_md ); if(verbose) std::cout << boost::format("Sent %d samples") % num_tx_samps << std::endl; diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp index 11a0ccc24..14b83fb65 100644 --- a/host/examples/rx_ascii_art_dft.cpp +++ b/host/examples/rx_ascii_art_dft.cpp @@ -147,6 +147,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ UHD_ASSERT_THROW(ref_locked.to_bool()); } + //create a receive streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + //allocate recv buffer and metatdata uhd::rx_metadata_t md; std::vector > buff(num_bins); @@ -162,10 +166,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //------------------------------------------------------------------ while (true){ //read a buffer's worth of samples every iteration - size_t num_rx_samps = usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_FULL_BUFF + size_t num_rx_samps = rx_stream->recv( + &buff.front(), buff.size(), md ); if (num_rx_samps != buff.size()) continue; diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index 8f6d7c939..56aed60af 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -111,6 +111,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ boost::this_thread::sleep(boost::posix_time::milliseconds(100)); } + //create a receive streamer + //linearly map channels (index0 = channel0, index1 = channel1, ...) + uhd::streamer_args stream_args("fc32"); //complex floats + for (size_t chan = 0; chan < usrp->get_rx_num_channels(); chan++) + stream_args.channels.push_back(chan); //linear mapping + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + //setup streaming std::cout << std::endl; std::cout << boost::format( @@ -126,7 +133,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::rx_metadata_t md; //allocate buffers to receive with samples (one buffer per channel) - size_t samps_per_buff = usrp->get_device()->get_max_recv_samps_per_packet(); + const size_t samps_per_buff = rx_stream->get_max_num_samps(); std::vector > > buffs( usrp->get_rx_num_channels(), std::vector >(samps_per_buff) ); @@ -141,10 +148,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ 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 = usrp->get_device()->recv( - buff_ptrs, samps_per_buff, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, timeout + size_t num_rx_samps = rx_stream->recv( + buff_ptrs, samps_per_buff, md, timeout ); //use a small timeout for subsequent packets diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 1e213c83a..58bd158a5 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -34,20 +34,21 @@ void sig_int_handler(int){stop_signal_called = true;} template void recv_to_file( uhd::usrp::multi_usrp::sptr usrp, - const uhd::io_type_t &io_type, + const std::string &cpu_format, const std::string &file, size_t samps_per_buff ){ + //create a receive streamer + uhd::streamer_args stream_args(cpu_format); + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::rx_metadata_t md; std::vector buff(samps_per_buff); std::ofstream outfile(file.c_str(), std::ofstream::binary); bool overflow_message = true; while(not stop_signal_called){ - size_t num_rx_samps = usrp->get_device()->recv( - &buff.front(), buff.size(), md, io_type, - uhd::device::RECV_MODE_FULL_BUFF - ); + size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md); if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW){ @@ -205,9 +206,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } //recv to file - if (type == "double") recv_to_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT64, file, spb); - else if (type == "float") recv_to_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT32, file, spb); - else if (type == "short") recv_to_file >(usrp, uhd::io_type_t::COMPLEX_INT16, file, spb); + if (type == "double") recv_to_file >(usrp, "fc64", file, spb); + else if (type == "float") recv_to_file >(usrp, "fc32", file, spb); + else if (type == "short") recv_to_file >(usrp, "sc16", file, spb); else throw std::runtime_error("Unknown type " + type); //finished diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index d06f1bc6e..3db436ad5 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -130,6 +130,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ UHD_ASSERT_THROW(ref_locked.to_bool()); } + //create a receive streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + //setup streaming uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); stream_cmd.num_samps = total_num_samps; @@ -139,14 +143,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //loop until total number of samples reached size_t num_acc_samps = 0; //number of accumulated samples uhd::rx_metadata_t md; - std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); + std::vector > buff(rx_stream->get_max_num_samps()); uhd::transport::udp_simple::sptr udp_xport = uhd::transport::udp_simple::make_connected(addr, port); while(num_acc_samps < total_num_samps){ - size_t num_rx_samps = usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET + size_t num_rx_samps = rx_stream->recv( + &buff.front(), buff.size(), md ); //handle the error codes diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 05cc0717b..6389375d9 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -70,6 +70,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Setting device timestamp to 0...") << std::endl; usrp->set_time_now(uhd::time_spec_t(0.0)); + //create a receive streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + //setup streaming std::cout << std::endl; std::cout << boost::format( @@ -85,7 +89,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::rx_metadata_t md; //allocate buffer to receive with samples - std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); + std::vector > buff(rx_stream->get_max_num_samps()); //the first call to recv() will block this many seconds before receiving double timeout = seconds_in_future + 0.1; //timeout (delay before receive + padding) @@ -93,10 +97,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ 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 = usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, timeout + size_t num_rx_samps = rx_stream->recv( + &buff.front(), buff.size(), md, timeout ); //use a small timeout for subsequent packets diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index 60d108184..668f25ef3 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -36,24 +36,22 @@ namespace po = boost::program_options; * Issue a stream command with a time that is in the past. * We expect to get an inline late command message. */ -bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp){ +bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ std::cout << "Test late command message... " << std::flush; usrp->set_time_now(uhd::time_spec_t(200.0)); //set time uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); - stream_cmd.num_samps = usrp->get_device()->get_max_recv_samps_per_packet(); + 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); - std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); + std::vector > buff(rx_stream->get_max_num_samps()); uhd::rx_metadata_t md; - const size_t nsamps = usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_FULL_BUFF + const size_t nsamps = rx_stream->recv( + &buff.front(), buff.size(), md ); switch(md.error_code){ @@ -85,27 +83,23 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp){ * Issue a stream command with num samps and more. * We expect to get an inline broken chain message. */ -bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp){ +bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ std::cout << "Test broken chain message... " << std::flush; 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 = usrp->get_device()->get_max_recv_samps_per_packet(); + stream_cmd.num_samps = rx_stream->get_max_num_samps(); usrp->issue_stream_cmd(stream_cmd); - std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); + std::vector > buff(rx_stream->get_max_num_samps()); uhd::rx_metadata_t md; - usrp->get_device()->recv( //once for the requested samples - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_FULL_BUFF + rx_stream->recv( //once for the requested samples + &buff.front(), buff.size(), md ); - usrp->get_device()->recv( //again for the inline message - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_FULL_BUFF + rx_stream->recv( //again for the inline message + &buff.front(), buff.size(), md ); switch(md.error_code){ @@ -137,7 +131,7 @@ bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp){ * 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){ +bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){ std::cout << "Test burst ack message... " << std::flush; uhd::tx_metadata_t md; @@ -146,12 +140,10 @@ bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr usrp){ md.has_time_spec = false; //3 times max-sps guarantees a SOB, no burst, and EOB packet - std::vector > buff(usrp->get_device()->get_max_send_samps_per_packet()*3); + std::vector > buff(tx_stream->get_max_num_samps()*3); - usrp->get_device()->send( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF + tx_stream->send( + &buff.front(), buff.size(), md ); uhd::async_metadata_t async_md; @@ -185,7 +177,7 @@ bool test_burst_ack_message(uhd::usrp::multi_usrp::sptr usrp){ * 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){ +bool test_underflow_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){ std::cout << "Test underflow message... " << std::flush; uhd::tx_metadata_t md; @@ -193,10 +185,7 @@ bool test_underflow_message(uhd::usrp::multi_usrp::sptr usrp){ md.end_of_burst = false; md.has_time_spec = false; - usrp->get_device()->send("", 0, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF - ); + tx_stream->send("", 0, md); uhd::async_metadata_t async_md; if (not usrp->get_device()->recv_async_msg(async_md, 1)){ @@ -229,7 +218,7 @@ bool test_underflow_message(uhd::usrp::multi_usrp::sptr usrp){ * Send a burst packet that occurs at a time in the past. * We expect to get a time error async message. */ -bool test_time_error_message(uhd::usrp::multi_usrp::sptr usrp){ +bool test_time_error_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr, uhd::tx_streamer::sptr tx_stream){ std::cout << "Test time error message... " << std::flush; uhd::tx_metadata_t md; @@ -240,10 +229,7 @@ bool test_time_error_message(uhd::usrp::multi_usrp::sptr usrp){ usrp->set_time_now(uhd::time_spec_t(200.0)); //time at 200s - usrp->get_device()->send("", 0, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF - ); + tx_stream->send("", 0, md); uhd::async_metadata_t async_md; if (not usrp->get_device()->recv_async_msg(async_md)){ @@ -276,16 +262,12 @@ void flush_async(uhd::usrp::multi_usrp::sptr usrp){ while (usrp->get_device()->recv_async_msg(async_md)){} } -void flush_recv(uhd::usrp::multi_usrp::sptr usrp){ - std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); +void flush_recv(uhd::rx_streamer::sptr rx_stream){ + std::vector > buff(rx_stream->get_max_num_samps()); uhd::rx_metadata_t md; do{ - usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_FULL_BUFF - ); + rx_stream->recv(&buff.front(), buff.size(), md); } while (md.error_code != uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -319,10 +301,15 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ 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; + //create RX and TX streamers + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + //------------------------------------------------------------------ // begin messages test //------------------------------------------------------------------ - static const uhd::dict > + static const uhd::dict > tests = boost::assign::map_list_of ("Test Burst ACK ", &test_burst_ack_message) ("Test Underflow ", &test_underflow_message) @@ -342,9 +329,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::srand(uhd::time_spec_t::get_system_time().get_full_secs()); for (size_t n = 0; n < ntests; n++){ std::string key = tests.keys()[std::rand() % tests.size()]; - bool pass = tests[key](usrp); + bool pass = tests[key](usrp, rx_stream, tx_stream); flush_async(usrp); - flush_recv(usrp); + flush_recv(rx_stream); //store result if (pass) successes[key]++; diff --git a/host/examples/tx_bursts.cpp b/host/examples/tx_bursts.cpp index a66fb85b6..98853ce20 100644 --- a/host/examples/tx_bursts.cpp +++ b/host/examples/tx_bursts.cpp @@ -93,15 +93,19 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Setting device timestamp to 0...") << std::endl; usrp->set_time_now(uhd::time_spec_t(0.0)); + //create a transmit streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + //allocate buffer with data to send - size_t spb = usrp->get_device()->get_max_send_samps_per_packet(); + const size_t spb = tx_stream->get_max_num_samps(); std::vector *> buffs; for(size_t i=0; i < usrp->get_num_mboards(); i++) { buffs.push_back(new std::complex[spb]); for(size_t n=0; n < spb; n++) buffs.back()[n] = std::complex(ampl, ampl); - } + }; std::signal(SIGINT, &sig_int_handler); if(repeat) std::cout << "Press Ctrl + C to quit..." << std::endl; @@ -127,10 +131,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ md.end_of_burst = samps_to_send < spb; //send a single packet - size_t num_tx_samps = usrp->get_device()->send( - buffs, samps_to_send, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_ONE_PACKET, timeout + size_t num_tx_samps = tx_stream->send( + buffs, samps_to_send, md, timeout ); //do not use time spec for subsequent packets diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index 03fc4c8d4..09939183b 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -29,10 +29,14 @@ namespace po = boost::program_options; template void send_from_file( uhd::usrp::multi_usrp::sptr usrp, - const uhd::io_type_t &io_type, + const std::string &cpu_format, const std::string &file, size_t samps_per_buff ){ + //create a transmit streamer + uhd::streamer_args stream_args(cpu_format); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + uhd::tx_metadata_t md; md.start_of_burst = false; md.end_of_burst = false; @@ -47,10 +51,7 @@ template void send_from_file( md.end_of_burst = infile.eof(); - usrp->get_device()->send( - &buff.front(), num_tx_samps, md, io_type, - uhd::device::SEND_MODE_FULL_BUFF - ); + tx_stream->send(&buff.front(), num_tx_samps, md); } infile.close(); @@ -172,9 +173,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } //send from file - if (type == "double") send_from_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT64, file, spb); - else if (type == "float") send_from_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT32, file, spb); - else if (type == "short") send_from_file >(usrp, uhd::io_type_t::COMPLEX_INT16, file, spb); + if (type == "double") send_from_file >(usrp, "fc64", file, spb); + else if (type == "float") send_from_file >(usrp, "fc32", file, spb); + else if (type == "short") send_from_file >(usrp, "sc16", file, spb); else throw std::runtime_error("Unknown type " + type); //finished diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 1c222d414..3daf1974a 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -73,8 +73,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Setting device timestamp to 0...") << std::endl; usrp->set_time_now(uhd::time_spec_t(0.0)); + //create a transmit streamer + uhd::streamer_args stream_args("fc32"); //complex floats + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + //allocate buffer with data to send - std::vector > buff(usrp->get_device()->get_max_send_samps_per_packet(), std::complex(ampl, ampl)); + std::vector > buff(tx_stream->get_max_num_samps(), std::complex(ampl, ampl)); //setup metadata for the first packet uhd::tx_metadata_t md; @@ -91,10 +95,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size()); //send a single packet - size_t num_tx_samps = usrp->get_device()->send( - &buff.front(), samps_to_send, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_ONE_PACKET, timeout + size_t num_tx_samps = tx_stream->send( + &buff.front(), samps_to_send, md, timeout ); //do not use time spec for subsequent packets @@ -108,10 +110,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //send a mini EOB packet md.end_of_burst = true; - usrp->get_device()->send("", 0, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF - ); + tx_stream->send("", 0, md); std::cout << std::endl << "Waiting for async burst ACK... " << std::flush; uhd::async_metadata_t async_md; diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 6e5c53642..9aa3ec71f 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -202,6 +202,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ const double cps = wave_freq/usrp->get_tx_rate(); double theta = 0; + //create a transmit streamer + //linearly map channels (index0 = channel0, index1 = channel1, ...) + uhd::streamer_args stream_args("fc32"); + for (size_t chan = 0; chan < usrp->get_tx_num_channels(); chan++) + stream_args.channels.push_back(chan); //linear mapping + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + //allocate a buffer which we re-use for each channel std::vector > buff(spb); std::vector *> buffs(usrp->get_tx_num_channels(), &buff.front()); @@ -250,11 +257,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ theta = std::fmod(theta, 1); //send the entire contents of the buffer - usrp->get_device()->send( - buffs, buff.size(), md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF - ); + tx_stream->send(buffs, buff.size(), md); md.start_of_burst = false; md.has_time_spec = false; @@ -262,10 +265,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //send a mini EOB packet md.end_of_burst = true; - usrp->get_device()->send("", 0, md, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF - ); + tx_stream->send("", 0, md); //finished std::cout << std::endl << "Done!" << std::endl << std::endl; -- cgit v1.2.3 From fac15db5d77c5196badb4a06f2f5fec34eb57337 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 6 Oct 2011 09:25:54 -0700 Subject: uhd: renamed some of the stream types and functions --- host/examples/benchmark_rate.cpp | 8 +- host/examples/latency_test.cpp | 6 +- host/examples/rx_ascii_art_dft.cpp | 4 +- host/examples/rx_multi_samples.cpp | 4 +- host/examples/rx_samples_to_file.cpp | 4 +- host/examples/rx_samples_to_udp.cpp | 4 +- host/examples/rx_timed_samples.cpp | 4 +- host/examples/test_messages.cpp | 6 +- host/examples/tx_bursts.cpp | 4 +- host/examples/tx_samples_from_file.cpp | 4 +- host/examples/tx_timed_samples.cpp | 4 +- host/examples/tx_waveforms.cpp | 4 +- host/include/uhd/CMakeLists.txt | 2 +- host/include/uhd/device.hpp | 6 +- host/include/uhd/device_deprecated.ipp | 16 +- host/include/uhd/stream.hpp | 189 +++++++++++++++++++++++ host/include/uhd/streamer.hpp | 189 ----------------------- host/include/uhd/usrp/multi_usrp.hpp | 8 +- host/lib/transport/super_recv_packet_handler.hpp | 2 +- host/lib/transport/super_send_packet_handler.hpp | 2 +- host/lib/usrp/usrp1/io_impl.cpp | 4 +- host/lib/usrp/usrp1/usrp1_impl.hpp | 4 +- host/lib/usrp/usrp2/io_impl.cpp | 4 +- host/lib/usrp/usrp2/usrp2_impl.hpp | 4 +- 24 files changed, 243 insertions(+), 243 deletions(-) create mode 100644 host/include/uhd/stream.hpp delete mode 100644 host/include/uhd/streamer.hpp (limited to 'host/examples') diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 7862bd44b..fce184514 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -44,8 +44,8 @@ void benchmark_rx_rate(uhd::usrp::multi_usrp::sptr usrp){ uhd::set_thread_priority_safe(); //create a receive streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::stream_args_t stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); //print pre-test summary std::cout << boost::format( @@ -98,8 +98,8 @@ void benchmark_tx_rate(uhd::usrp::multi_usrp::sptr usrp){ uhd::set_thread_priority_safe(); //create a transmit streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + uhd::stream_args_t stream_args("fc32"); //complex floats + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); //print pre-test summary std::cout << boost::format( diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp index b995b0433..518d2383a 100644 --- a/host/examples/latency_test.cpp +++ b/host/examples/latency_test.cpp @@ -84,9 +84,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::vector > buffer(nsamps); //create RX and TX streamers - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + uhd::stream_args_t stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); //initialize result counts int time_error = 0; diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp index 14b83fb65..2e5bbba9d 100644 --- a/host/examples/rx_ascii_art_dft.cpp +++ b/host/examples/rx_ascii_art_dft.cpp @@ -148,8 +148,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } //create a receive streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::stream_args_t stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); //allocate recv buffer and metatdata uhd::rx_metadata_t md; diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index 56aed60af..7561f1285 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -113,10 +113,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //create a receive streamer //linearly map channels (index0 = channel0, index1 = channel1, ...) - uhd::streamer_args stream_args("fc32"); //complex floats + uhd::stream_args_t stream_args("fc32"); //complex floats for (size_t chan = 0; chan < usrp->get_rx_num_channels(); chan++) stream_args.channels.push_back(chan); //linear mapping - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); //setup streaming std::cout << std::endl; diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 58bd158a5..605439748 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -39,8 +39,8 @@ template void recv_to_file( size_t samps_per_buff ){ //create a receive streamer - uhd::streamer_args stream_args(cpu_format); - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::stream_args_t stream_args(cpu_format); + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); uhd::rx_metadata_t md; std::vector buff(samps_per_buff); diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index 3db436ad5..cf7fd493a 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -131,8 +131,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } //create a receive streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + uhd::stream_args_t stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); //setup streaming uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 6389375d9..0851593cd 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -71,8 +71,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_time_now(uhd::time_spec_t(0.0)); //create a receive streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); + 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; diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index 668f25ef3..f24a172d1 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -302,9 +302,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; //create RX and TX streamers - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args); - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + uhd::stream_args_t stream_args("fc32"); //complex floats + uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); //------------------------------------------------------------------ // begin messages test diff --git a/host/examples/tx_bursts.cpp b/host/examples/tx_bursts.cpp index 98853ce20..f5ae18a9f 100644 --- a/host/examples/tx_bursts.cpp +++ b/host/examples/tx_bursts.cpp @@ -94,8 +94,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_time_now(uhd::time_spec_t(0.0)); //create a transmit streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + 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 const size_t spb = tx_stream->get_max_num_samps(); diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index 09939183b..964c6cea8 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -34,8 +34,8 @@ template void send_from_file( size_t samps_per_buff ){ //create a transmit streamer - uhd::streamer_args stream_args(cpu_format); - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + uhd::stream_args_t stream_args(cpu_format); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); uhd::tx_metadata_t md; md.start_of_burst = false; diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 3daf1974a..3b8cc75d4 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -74,8 +74,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_time_now(uhd::time_spec_t(0.0)); //create a transmit streamer - uhd::streamer_args stream_args("fc32"); //complex floats - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + 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 > buff(tx_stream->get_max_num_samps(), std::complex(ampl, ampl)); diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 9aa3ec71f..1eb6c2f1e 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -204,10 +204,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //create a transmit streamer //linearly map channels (index0 = channel0, index1 = channel1, ...) - uhd::streamer_args stream_args("fc32"); + uhd::stream_args_t stream_args("fc32"); for (size_t chan = 0; chan < usrp->get_tx_num_channels(); chan++) stream_args.channels.push_back(chan); //linear mapping - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_streamer(stream_args); + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); //allocate a buffer which we re-use for each channel std::vector > buff(spb); diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index 6b277654d..2b0c6ec14 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -30,7 +30,7 @@ INSTALL(FILES exception.hpp property_tree.ipp property_tree.hpp - streamer.hpp + stream.hpp version.hpp wax.hpp DESTINATION ${INCLUDE_DIR}/uhd diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index c96139858..89c6332da 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -19,7 +19,7 @@ #define INCLUDED_UHD_DEVICE_HPP #include -#include +#include #include #include #include @@ -77,10 +77,10 @@ public: static sptr make(const device_addr_t &hint, size_t which = 0); //! Make a new receive streamer from the streamer arguments - virtual rx_streamer::sptr get_rx_streamer(const streamer_args &args) = 0; + virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0; //! Make a new transmit streamer from the streamer arguments - virtual tx_streamer::sptr get_tx_streamer(const streamer_args &args) = 0; + virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0; /*! * Receive and asynchronous message from the device. diff --git a/host/include/uhd/device_deprecated.ipp b/host/include/uhd/device_deprecated.ipp index 7afaaca2d..8e61c389f 100644 --- a/host/include/uhd/device_deprecated.ipp +++ b/host/include/uhd/device_deprecated.ipp @@ -80,12 +80,12 @@ size_t send( if (_tx_streamer.get() == NULL or _tx_streamer->get_num_channels() != buffs.size() or _send_tid != io_type.tid){ _send_tid = io_type.tid; _tx_streamer.reset(); //cleanup possible old one - streamer_args args; + stream_args_t args; args.cpu_format = (_send_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16"; args.otw_format = "sc16"; for (size_t ch = 0; ch < buffs.size(); ch++) args.channels.push_back(ch); //linear mapping - _tx_streamer = get_tx_streamer(args); + _tx_streamer = get_tx_stream(args); } const size_t nsamps = (send_mode == SEND_MODE_ONE_PACKET)? std::min(nsamps_per_buff, get_max_send_samps_per_packet()) : @@ -135,12 +135,12 @@ size_t recv( if (_rx_streamer.get() == NULL or _rx_streamer->get_num_channels() != buffs.size() or _recv_tid != io_type.tid){ _recv_tid = io_type.tid; _rx_streamer.reset(); //cleanup possible old one - streamer_args args; + stream_args_t args; args.cpu_format = (_recv_tid == io_type_t::COMPLEX_FLOAT32)? "fc32" : "sc16"; args.otw_format = "sc16"; for (size_t ch = 0; ch < buffs.size(); ch++) args.channels.push_back(ch); //linear mapping - _rx_streamer = get_rx_streamer(args); + _rx_streamer = get_rx_stream(args); } const size_t nsamps = (recv_mode == RECV_MODE_ONE_PACKET)? std::min(nsamps_per_buff, get_max_recv_samps_per_packet()) : @@ -154,10 +154,10 @@ size_t recv( */ size_t get_max_send_samps_per_packet(void){ if (_tx_streamer.get() == NULL){ - streamer_args args; + stream_args_t args; args.cpu_format = "fc32"; args.otw_format = "sc16"; - _tx_streamer = get_tx_streamer(args); + _tx_streamer = get_tx_stream(args); _send_tid = io_type_t::COMPLEX_FLOAT32; } return _tx_streamer->get_max_num_samps(); @@ -169,10 +169,10 @@ size_t get_max_send_samps_per_packet(void){ */ size_t get_max_recv_samps_per_packet(void){ if (_rx_streamer.get() == NULL){ - streamer_args args; + stream_args_t args; args.cpu_format = "fc32"; args.otw_format = "sc16"; - _rx_streamer = get_rx_streamer(args); + _rx_streamer = get_rx_stream(args); _recv_tid = io_type_t::COMPLEX_FLOAT32; } return _rx_streamer->get_max_num_samps(); diff --git a/host/include/uhd/stream.hpp b/host/include/uhd/stream.hpp new file mode 100644 index 000000000..583dfd1e4 --- /dev/null +++ b/host/include/uhd/stream.hpp @@ -0,0 +1,189 @@ +// +// Copyright 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_STREAM_HPP +#define INCLUDED_UHD_STREAM_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace uhd{ + +/*! + * A struct of parameters to construct a streamer. + * + * Note: + * Not all combinations of CPU and OTW format have conversion support. + * You may however write and register your own conversion routines. + */ +struct UHD_API stream_args_t{ + + //! Convenience constructor for streamer args + stream_args_t( + const std::string &cpu = "fc32", + const std::string &otw = "sc16" + ){ + cpu_format = cpu; + otw_format = otw; + } + + /*! + * The CPU format is a string that describes the format of host memory. + * Common CPU formats are: + * - fc32 - complex + * - fc64 - complex + * - sc16 - complex + * - sc8 - complex + * - f32 - float + * - f64 - double + * - s16 - int16_t + * - s8 - int8_t + */ + std::string cpu_format; + + /*! + * The OTW format is a string that describes the format over-the-wire. + * Common OTW format are: + * - sc16 - Q16 I16 + * - sc8 - Q8_1 I8_1 Q8_0 I8_0 + * - s16 - R16_1 R16_0 + * - s8 - R8_3 R8_2 R8_1 R8_0 + */ + std::string otw_format; + + /*! + * The args parameter is currently unused. Leave it blank. + * The intention is that a user with a custom DSP design + * may want to pass args and do something special with it. + */ + std::string args; + + /*! + * The channels is a list of channel numbers. + * Leave this blank to default to channel 0. + * Set channels for a multi-channel application. + * Channel mapping depends on the front-end selection. + */ + std::vector channels; +}; + +/*! + * The RX streamer is the host interface to receiving samples. + * It represents the layer between the samples on the host + * and samples inside the device's receive DSP processing. + */ +class UHD_API rx_streamer : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + + //! Get the number of channels associated with this streamer + virtual size_t get_num_channels(void) const = 0; + + //! Get the max number of samples per buffer per packet + virtual size_t get_max_num_samps(void) const = 0; + + //! Typedef for a pointer to a single, or a collection of recv buffers + typedef ref_vector buffs_type; + + /*! + * Receive buffers containing samples described by the metadata. + * + * Receive handles fragmentation as follows: + * If the buffer has insufficient space to hold all samples + * that were received in a single packet over-the-wire, + * then the buffer will be completely filled and the implementation + * will hold a pointer into the remaining portion of the packet. + * Subsequent calls will load from the remainder of the packet, + * and will flag the metadata to show that this is a fragment. + * The next call to receive, after the remainder becomes exahausted, + * will perform an over-the-wire receive as usual. + * See the rx metadata fragment flags and offset fields for details. + * + * This is a blocking call and will not return until the number + * of samples returned have been written into each buffer. + * Under a timeout condition, the number of samples returned + * may be less than the number of samples specified. + * + * \param buffs a vector of writable memory to fill with samples + * \param nsamps_per_buff the size of each buffer in number of samples + * \param metadata data to fill describing the buffer + * \param timeout the timeout in seconds to wait for a packet + * \return the number of samples received or 0 on error + */ + virtual size_t recv( + const buffs_type &buffs, + const size_t nsamps_per_buff, + rx_metadata_t &metadata, + double timeout = 0.1 + ) = 0; +}; + +/*! + * The TX streamer is the host interface to transmitting samples. + * It represents the layer between the samples on the host + * and samples inside the device's transmit DSP processing. + */ +class UHD_API tx_streamer : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + + //! Get the number of channels associated with this streamer + virtual size_t get_num_channels(void) const = 0; + + //! Get the max number of samples per buffer per packet + virtual size_t get_max_num_samps(void) const = 0; + + //! Typedef for a pointer to a single, or a collection of send buffers + typedef ref_vector buffs_type; + + /*! + * Send buffers containing samples described by the metadata. + * + * Send handles fragmentation as follows: + * If the buffer has more items than the maximum per packet, + * the send method will fragment the samples across several packets. + * Send will respect the burst flags when fragmenting to ensure + * that start of burst can only be set on the first fragment and + * that end of burst can only be set on the final fragment. + * + * This is a blocking call and will not return until the number + * of samples returned have been read out of each buffer. + * Under a timeout condition, the number of samples returned + * may be less than the number of samples specified. + * + * \param buffs a vector of read-only memory containing samples + * \param nsamps_per_buff the number of samples to send, per buffer + * \param metadata data describing the buffer's contents + * \param timeout the timeout in seconds to wait on a packet + * \return the number of samples sent + */ + virtual size_t send( + const buffs_type &buffs, + const size_t nsamps_per_buff, + const tx_metadata_t &metadata, + double timeout = 0.1 + ) = 0; +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_STREAM_HPP */ diff --git a/host/include/uhd/streamer.hpp b/host/include/uhd/streamer.hpp deleted file mode 100644 index c9c6fef89..000000000 --- a/host/include/uhd/streamer.hpp +++ /dev/null @@ -1,189 +0,0 @@ -// -// Copyright 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_UHD_STREAMER_HPP -#define INCLUDED_UHD_STREAMER_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace uhd{ - -/*! - * A struct of parameters to construct a streamer. - * - * Note: - * Not all combinations of CPU and OTW format have conversion support. - * You may however write and register your own conversion routines. - */ -struct UHD_API streamer_args{ - - //! Convenience constructor for streamer args - streamer_args( - const std::string &cpu = "fc32", - const std::string &otw = "sc16" - ){ - cpu_format = cpu; - otw_format = otw; - } - - /*! - * The CPU format is a string that describes the format of host memory. - * Common CPU formats are: - * - fc32 - complex - * - fc64 - complex - * - sc16 - complex - * - sc8 - complex - * - f32 - float - * - f64 - double - * - s16 - int16_t - * - s8 - int8_t - */ - std::string cpu_format; - - /*! - * The OTW format is a string that describes the format over-the-wire. - * Common OTW format are: - * - sc16 - Q16 I16 - * - sc8 - Q8_1 I8_1 Q8_0 I8_0 - * - s16 - R16_1 R16_0 - * - s8 - R8_3 R8_2 R8_1 R8_0 - */ - std::string otw_format; - - /*! - * The args parameter is currently unused. Leave it blank. - * The intention is that a user with a custom DSP design - * may want to pass args and do something special with it. - */ - std::string args; - - /*! - * The channels is a list of channel numbers. - * Leave this blank to default to channel 0. - * Set channels for a multi-channel application. - * Channel mapping depends on the front-end selection. - */ - std::vector channels; -}; - -/*! - * The RX streamer is the host interface to receiving samples. - * It represents the layer between the samples on the host - * and samples inside the device's receive DSP processing. - */ -class UHD_API rx_streamer : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - - //! Get the number of channels associated with this streamer - virtual size_t get_num_channels(void) const = 0; - - //! Get the max number of samples per buffer per packet - virtual size_t get_max_num_samps(void) const = 0; - - //! Typedef for a pointer to a single, or a collection of recv buffers - typedef ref_vector buffs_type; - - /*! - * Receive buffers containing samples described by the metadata. - * - * Receive handles fragmentation as follows: - * If the buffer has insufficient space to hold all samples - * that were received in a single packet over-the-wire, - * then the buffer will be completely filled and the implementation - * will hold a pointer into the remaining portion of the packet. - * Subsequent calls will load from the remainder of the packet, - * and will flag the metadata to show that this is a fragment. - * The next call to receive, after the remainder becomes exahausted, - * will perform an over-the-wire receive as usual. - * See the rx metadata fragment flags and offset fields for details. - * - * This is a blocking call and will not return until the number - * of samples returned have been written into each buffer. - * Under a timeout condition, the number of samples returned - * may be less than the number of samples specified. - * - * \param buffs a vector of writable memory to fill with samples - * \param nsamps_per_buff the size of each buffer in number of samples - * \param metadata data to fill describing the buffer - * \param timeout the timeout in seconds to wait for a packet - * \return the number of samples received or 0 on error - */ - virtual size_t recv( - const buffs_type &buffs, - const size_t nsamps_per_buff, - rx_metadata_t &metadata, - double timeout = 0.1 - ) = 0; -}; - -/*! - * The TX streamer is the host interface to transmitting samples. - * It represents the layer between the samples on the host - * and samples inside the device's transmit DSP processing. - */ -class UHD_API tx_streamer : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - - //! Get the number of channels associated with this streamer - virtual size_t get_num_channels(void) const = 0; - - //! Get the max number of samples per buffer per packet - virtual size_t get_max_num_samps(void) const = 0; - - //! Typedef for a pointer to a single, or a collection of send buffers - typedef ref_vector buffs_type; - - /*! - * Send buffers containing samples described by the metadata. - * - * Send handles fragmentation as follows: - * If the buffer has more items than the maximum per packet, - * the send method will fragment the samples across several packets. - * Send will respect the burst flags when fragmenting to ensure - * that start of burst can only be set on the first fragment and - * that end of burst can only be set on the final fragment. - * - * This is a blocking call and will not return until the number - * of samples returned have been read out of each buffer. - * Under a timeout condition, the number of samples returned - * may be less than the number of samples specified. - * - * \param buffs a vector of read-only memory containing samples - * \param nsamps_per_buff the number of samples to send, per buffer - * \param metadata data describing the buffer's contents - * \param timeout the timeout in seconds to wait on a packet - * \return the number of samples sent - */ - virtual size_t send( - const buffs_type &buffs, - const size_t nsamps_per_buff, - const tx_metadata_t &metadata, - double timeout = 0.1 - ) = 0; -}; - -} //namespace uhd - -#endif /* INCLUDED_UHD_STREAMER_HPP */ diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 303af7ef9..72386204f 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -109,13 +109,13 @@ public: virtual device::sptr get_device(void) = 0; //! Convenience method to get a RX streamer - rx_streamer::sptr get_rx_streamer(const streamer_args &args){ - return this->get_device()->get_rx_streamer(args); + rx_streamer::sptr get_rx_stream(const stream_args_t &args){ + return this->get_device()->get_rx_stream(args); } //! Convenience method to get a TX streamer - tx_streamer::sptr get_tx_streamer(const streamer_args &args){ - return this->get_device()->get_tx_streamer(args); + tx_streamer::sptr get_tx_stream(const stream_args_t &args){ + return this->get_device()->get_tx_stream(args); } /******************************************************************* diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp index f4dbc5531..de7b4b34c 100644 --- a/host/lib/transport/super_recv_packet_handler.hpp +++ b/host/lib/transport/super_recv_packet_handler.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp index 079fea11e..42bac5e21 100644 --- a/host/lib/transport/super_send_packet_handler.hpp +++ b/host/lib/transport/super_send_packet_handler.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 7d4fe2ec7..22c2db6ae 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -527,7 +527,7 @@ bool usrp1_impl::recv_async_msg( /*********************************************************************** * Receive streamer **********************************************************************/ -rx_streamer::sptr usrp1_impl::get_rx_streamer(const uhd::streamer_args &args){ +rx_streamer::sptr usrp1_impl::get_rx_stream(const uhd::stream_args_t &args){ //map an empty channel set to chan0 const std::vector channels = args.channels.empty()? std::vector(1, 0) : args.channels; @@ -567,7 +567,7 @@ rx_streamer::sptr usrp1_impl::get_rx_streamer(const uhd::streamer_args &args){ /*********************************************************************** * Transmit streamer **********************************************************************/ -tx_streamer::sptr usrp1_impl::get_tx_streamer(const uhd::streamer_args &args){ +tx_streamer::sptr usrp1_impl::get_tx_stream(const uhd::stream_args_t &args){ //map an empty channel set to chan0 const std::vector channels = args.channels.empty()? std::vector(1, 0) : args.channels; diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp index 7776ea8d6..c777307ee 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.hpp +++ b/host/lib/usrp/usrp1/usrp1_impl.hpp @@ -55,8 +55,8 @@ public: ~usrp1_impl(void); //the io interface - uhd::rx_streamer::sptr get_rx_streamer(const uhd::streamer_args &args); - uhd::tx_streamer::sptr get_tx_streamer(const uhd::streamer_args &args); + uhd::rx_streamer::sptr get_rx_stream(const uhd::stream_args_t &args); + uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args); bool recv_async_msg(uhd::async_metadata_t &, double); private: diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index f271d480a..d37be403b 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -366,7 +366,7 @@ bool usrp2_impl::recv_async_msg( /*********************************************************************** * Receive streamer **********************************************************************/ -rx_streamer::sptr usrp2_impl::get_rx_streamer(const uhd::streamer_args &args){ +rx_streamer::sptr usrp2_impl::get_rx_stream(const uhd::stream_args_t &args){ //map an empty channel set to chan0 const std::vector channels = args.channels.empty()? std::vector(1, 0) : args.channels; @@ -426,7 +426,7 @@ rx_streamer::sptr usrp2_impl::get_rx_streamer(const uhd::streamer_args &args){ /*********************************************************************** * Transmit streamer **********************************************************************/ -tx_streamer::sptr usrp2_impl::get_tx_streamer(const uhd::streamer_args &args){ +tx_streamer::sptr usrp2_impl::get_tx_stream(const uhd::stream_args_t &args){ //map an empty channel set to chan0 const std::vector channels = args.channels.empty()? std::vector(1, 0) : args.channels; diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index a67c704c8..31a390af7 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -72,8 +72,8 @@ public: ~usrp2_impl(void); //the io interface - uhd::rx_streamer::sptr get_rx_streamer(const uhd::streamer_args &args); - uhd::tx_streamer::sptr get_tx_streamer(const uhd::streamer_args &args); + uhd::rx_streamer::sptr get_rx_stream(const uhd::stream_args_t &args); + uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args); bool recv_async_msg(uhd::async_metadata_t &, double); private: -- cgit v1.2.3 From 522bc87d9f61668f3d22e067c39a98e5f33fc6c5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 12 Oct 2011 20:05:57 -0700 Subject: uhd: fixed 8sc item32 converter on head/tail cases --- host/examples/rx_timed_samples.cpp | 2 +- host/lib/convert/gen_convert_general.py | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'host/examples') diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 0851593cd..143bceb03 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -98,7 +98,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ 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 + &buff.front(), buff.size(), md, timeout, true ); //use a small timeout for subsequent packets diff --git a/host/lib/convert/gen_convert_general.py b/host/lib/convert/gen_convert_general.py index 43e1f9967..9a1135b0b 100644 --- a/host/lib/convert/gen_convert_general.py +++ b/host/lib/convert/gen_convert_general.py @@ -51,27 +51,23 @@ DECLARE_CONVERTER(sc8_item32_$(end), 1, $(cpu_type), 1, PRIORITY_GENERAL){ const item32_t *input = reinterpret_cast(size_t(inputs[0]) & ~0x3); $(cpu_type)_t *output = reinterpret_cast<$(cpu_type)_t *>(outputs[0]); $(cpu_type)_t dummy; + size_t num_samps = nsamps; - const bool head_case = ((size_t(inputs[0]) & 0x3) != 0); - const bool tail_case = ((nsamps & 0x1) == 0)? head_case : not head_case; - const size_t num_pairs = (head_case? nsamps-1 : nsamps)/2; - size_t i = 0, j = 0; - - //special head case, probably from a partial recv - if (head_case){ - const item32_t item0 = $(to_host)(input[i++]); - item32_sc8_to_$(cpu_type)(item0, dummy, output[j++], scale_factor); + if ((size_t(inputs[0]) & 0x3) != 0){ + const item32_t item0 = $(to_host)(*input++); + item32_sc8_to_$(cpu_type)(item0, dummy, *output++, scale_factor); + num_samps--; } - for (; i < num_pairs; i++, j+=2){ + const size_t num_pairs = num_samps/2; + for (size_t i = 0, j = 0; i < num_pairs; i++, j+=2){ const item32_t item_i = $(to_host)(input[i]); item32_sc8_to_$(cpu_type)(item_i, output[j], output[j+1], scale_factor); } - //special tail case, finished on an odd number - if (tail_case){ - const item32_t item_i = $(to_host)(input[i]); - item32_sc8_to_$(cpu_type)(item_i, output[j], dummy, scale_factor); + if (num_samps != num_pairs*2){ + const item32_t item_n = $(to_host)(input[num_pairs]); + item32_sc8_to_$(cpu_type)(item_n, output[num_samps-1], dummy, scale_factor); } } """ -- cgit v1.2.3 From f3afd2eb94a65b4e6494c269ff67cd283dcad1de Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Nov 2011 11:44:37 -0700 Subject: uhd: performance speed up for tx waveforms, no iterative libmath per sample --- host/examples/tx_waveforms.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'host/examples') diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 1eb6c2f1e..4abca5dae 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -76,7 +76,7 @@ public: } inline std::complex operator()(const double theta) const{ - return _wave_table[unsigned(boost::math::iround(theta*wave_table_len))%wave_table_len]; + return _wave_table[unsigned(theta*wave_table_len)%wave_table_len]; } private: @@ -100,7 +100,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "single uhd device address args") - ("spb", po::value(&spb)->default_value(10000), "samples per buffer") + ("spb", po::value(&spb)->default_value(0), "samples per buffer, 0 for default") ("rate", po::value(&rate), "rate of outgoing samples") ("freq", po::value(&freq), "RF center frequency in Hz") ("ampl", po::value(&l)->default_value(float(0.3)), "amplitude of the waveform [0 to 0.7]") @@ -210,6 +210,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); //allocate a buffer which we re-use for each channel + if (spb == 0) spb = tx_stream->get_max_num_samps()*10; std::vector > buff(spb); std::vector *> buffs(usrp->get_tx_num_channels(), &buff.front()); -- cgit v1.2.3 From 7c503ad1fab5fd6218847b1d030881b4d048379f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Nov 2011 14:34:40 -0800 Subject: uhd: modify examples to use new time/clock source API --- host/examples/rx_ascii_art_dft.cpp | 15 ++------------- host/examples/rx_multi_samples.cpp | 7 +++---- host/examples/rx_samples_to_file.cpp | 15 ++------------- host/examples/rx_samples_to_udp.cpp | 15 ++------------- host/examples/tx_samples_from_file.cpp | 15 ++------------- host/examples/tx_waveforms.cpp | 15 ++------------- 6 files changed, 13 insertions(+), 69 deletions(-) (limited to 'host/examples') diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp index 2e5bbba9d..cba72472a 100644 --- a/host/examples/rx_ascii_art_dft.cpp +++ b/host/examples/rx_ascii_art_dft.cpp @@ -54,7 +54,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("frame-rate", po::value(&frame_rate)->default_value(5), "frame rate of the display (fps)") ("ref-lvl", po::value(&ref_lvl)->default_value(0), "reference level for the display (dB)") ("dyn-rng", po::value(&dyn_rng)->default_value(60), "dynamic range for the display (dB)") - ("ref", po::value(&ref)->default_value("INTERNAL"), "waveform type (INTERNAL, EXTERNAL, MIMO)") + ("ref", po::value(&ref)->default_value("internal"), "waveform type (internal, external, mimo)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -72,18 +72,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); //Lock mboard clocks - if (ref == "MIMO") { - uhd::clock_config_t clock_config; - clock_config.ref_source = uhd::clock_config_t::REF_MIMO; - clock_config.pps_source = uhd::clock_config_t::PPS_MIMO; - usrp->set_clock_config(clock_config, 0); - } - else if (ref == "EXTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::external(), 0); - } - else if (ref == "INTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::internal(), 0); - } + usrp->set_clock_source(ref); //always select the subdevice first, the channel mapping affects the other settings if (vm.count("subdev")) usrp->set_rx_subdev_spec(subdev); diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index 7561f1285..42ef33d70 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -92,6 +92,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_time_now(uhd::time_spec_t(0.0)); } else if (sync == "pps"){ + usrp->set_time_source("external"); usrp->set_time_unknown_pps(uhd::time_spec_t(0.0)); boost::this_thread::sleep(boost::posix_time::seconds(1)); //wait for pps sync pulse } @@ -99,10 +100,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ UHD_ASSERT_THROW(usrp->get_num_mboards() == 2); //make mboard 1 a slave over the MIMO Cable - uhd::clock_config_t clock_config; - clock_config.ref_source = uhd::clock_config_t::REF_MIMO; - clock_config.pps_source = uhd::clock_config_t::PPS_MIMO; - usrp->set_clock_config(clock_config, 1); + usrp->set_clock_source("mimo", 1); + usrp->set_time_source("mimo", 1); //set time on the master (mboard 0) usrp->set_time_now(uhd::time_spec_t(0.0), 0); diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 605439748..ed242b07a 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -99,7 +99,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("ant", po::value(&ant), "daughterboard antenna selection") ("subdev", po::value(&subdev), "daughterboard subdevice specification") ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") - ("ref", po::value(&ref)->default_value("INTERNAL"), "waveform type (INTERNAL, EXTERNAL, MIMO)") + ("ref", po::value(&ref)->default_value("internal"), "waveform type (internal, external, mimo)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -117,18 +117,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); //Lock mboard clocks - if (ref == "MIMO") { - uhd::clock_config_t clock_config; - clock_config.ref_source = uhd::clock_config_t::REF_MIMO; - clock_config.pps_source = uhd::clock_config_t::PPS_MIMO; - usrp->set_clock_config(clock_config, 0); - } - else if (ref == "EXTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::external(), 0); - } - else if (ref == "INTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::internal(), 0); - } + usrp->set_clock_source(ref); //always select the subdevice first, the channel mapping affects the other settings if (vm.count("subdev")) usrp->set_rx_subdev_spec(subdev); diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index cf7fd493a..c456f05c3 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -51,7 +51,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") ("port", po::value(&port)->default_value("7124"), "server udp port") ("addr", po::value(&addr)->default_value("192.168.1.10"), "resolvable server address") - ("ref", po::value(&ref)->default_value("INTERNAL"), "waveform type (INTERNAL, EXTERNAL, MIMO)") + ("ref", po::value(&ref)->default_value("internal"), "waveform type (internal, external, mimo)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -70,18 +70,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; //Lock mboard clocks - if (ref == "MIMO") { - uhd::clock_config_t clock_config; - clock_config.ref_source = uhd::clock_config_t::REF_MIMO; - clock_config.pps_source = uhd::clock_config_t::PPS_MIMO; - usrp->set_clock_config(clock_config, 0); - } - else if (ref == "EXTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::external(), 0); - } - else if (ref == "INTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::internal(), 0); - } + usrp->set_clock_source(ref); //set the rx sample rate std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl; diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index 964c6cea8..8e3614f6c 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -79,7 +79,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("ant", po::value(&ant), "daughterboard antenna selection") ("subdev", po::value(&subdev), "daughterboard subdevice specification") ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") - ("ref", po::value(&ref)->default_value("INTERNAL"), "waveform type (INTERNAL, EXTERNAL, MIMO)") + ("ref", po::value(&ref)->default_value("internal"), "waveform type (internal, external, mimo)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -97,18 +97,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); //Lock mboard clocks - if (ref == "MIMO") { - uhd::clock_config_t clock_config; - clock_config.ref_source = uhd::clock_config_t::REF_MIMO; - clock_config.pps_source = uhd::clock_config_t::PPS_MIMO; - usrp->set_clock_config(clock_config, 0); - } - else if (ref == "EXTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::external(), 0); - } - else if (ref == "INTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::internal(), 0); - } + usrp->set_clock_source(ref); //always select the subdevice first, the channel mapping affects the other settings if (vm.count("subdev")) usrp->set_tx_subdev_spec(subdev); diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 4abca5dae..5b17e0595 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -110,7 +110,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") ("wave-type", po::value(&wave_type)->default_value("CONST"), "waveform type (CONST, SQUARE, RAMP, SINE)") ("wave-freq", po::value(&wave_freq)->default_value(0), "waveform frequency in Hz") - ("ref", po::value(&ref)->default_value("INTERNAL"), "waveform type (INTERNAL, EXTERNAL, MIMO)") + ("ref", po::value(&ref)->default_value("internal"), "waveform type (internal, external, mimo)") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -128,18 +128,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); //Lock mboard clocks - if (ref == "MIMO") { - uhd::clock_config_t clock_config; - clock_config.ref_source = uhd::clock_config_t::REF_MIMO; - clock_config.pps_source = uhd::clock_config_t::PPS_MIMO; - usrp->set_clock_config(clock_config, 0); - } - else if (ref == "EXTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::external(), 0); - } - else if (ref == "INTERNAL") { - usrp->set_clock_config(uhd::clock_config_t::internal(), 0); - } + usrp->set_clock_source(ref); //always select the subdevice first, the channel mapping affects the other settings if (vm.count("subdev")) usrp->set_tx_subdev_spec(subdev); -- cgit v1.2.3