diff options
-rw-r--r-- | host/examples/rx_samples_to_file.cpp | 9 | ||||
-rw-r--r-- | host/examples/tx_samples_from_file.cpp | 28 |
2 files changed, 24 insertions, 13 deletions
diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 941e5eb65..444fd155c 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -37,6 +37,7 @@ template<typename samp_type> void recv_to_file( uhd::usrp::multi_usrp::sptr usrp, const std::string &cpu_format, const std::string &wire_format, + const std::string &channel, const std::string &file, size_t samps_per_buff, unsigned long long num_requested_samples, @@ -50,6 +51,9 @@ template<typename samp_type> void recv_to_file( unsigned long long num_total_samps = 0; //create a receive streamer uhd::stream_args_t stream_args(cpu_format,wire_format); + std::vector<size_t> channel_nums; + channel_nums.push_back(boost::lexical_cast<size_t>(channel)); + stream_args.channels = channel_nums; uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); uhd::rx_metadata_t md; @@ -209,7 +213,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po - std::string args, file, type, ant, subdev, ref, wirefmt; + std::string args, file, type, ant, subdev, ref, wirefmt, channel; size_t total_num_samps, spb; double rate, freq, gain, bw, total_time, setup_time; @@ -229,6 +233,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("gain", po::value<double>(&gain), "gain for the RF chain") ("ant", po::value<std::string>(&ant), "antenna selection") ("subdev", po::value<std::string>(&subdev), "subdevice specification") + ("channel", po::value<std::string>(&channel)->default_value("0"), "which channel to use") ("bw", po::value<double>(&bw), "analog frontend filter bandwidth in Hz") ("ref", po::value<std::string>(&ref)->default_value("internal"), "reference source (internal, external, mimo)") ("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8, sc16 or s16)") @@ -329,7 +334,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } #define recv_to_file_args(format) \ - (usrp, format, wirefmt, file, spb, total_num_samps, total_time, bw_summary, stats, null, enable_size_map, continue_on_bad_packet) + (usrp, format, wirefmt, channel, file, spb, total_num_samps, total_time, bw_summary, stats, null, enable_size_map, continue_on_bad_packet) //recv to file if (wirefmt == "s16") { if (type == "double") recv_to_file<double>recv_to_file_args("f64"); diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index cc7e963d5..b09efe454 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -33,17 +33,11 @@ static bool stop_signal_called = false; void sig_int_handler(int){stop_signal_called = true;} template<typename samp_type> void send_from_file( - uhd::usrp::multi_usrp::sptr usrp, - const std::string &cpu_format, - const std::string &wire_format, + uhd::tx_streamer::sptr tx_stream, const std::string &file, size_t samps_per_buff ){ - //create a transmit streamer - uhd::stream_args_t stream_args(cpu_format, wire_format); - uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); - uhd::tx_metadata_t md; md.start_of_burst = false; md.end_of_burst = false; @@ -69,7 +63,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po - std::string args, file, type, ant, subdev, ref, wirefmt; + std::string args, file, type, ant, subdev, ref, wirefmt, channel; size_t spb; double rate, freq, gain, bw, delay, lo_off; @@ -91,6 +85,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("ref", po::value<std::string>(&ref)->default_value("internal"), "reference source (internal, external, mimo)") ("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8 or sc16)") ("delay", po::value<double>(&delay)->default_value(0.0), "specify a delay between repeated transmission of file") + ("channel", po::value<std::string>(&channel)->default_value("0"), "which channel to use") ("repeat", "repeatedly transmit file") ("int-n", "tune USRP with integer-n tuning") ; @@ -186,11 +181,22 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "Press Ctrl + C to stop streaming..." << std::endl; } + //create a transmit streamer + std::string cpu_format; + std::vector<size_t> channel_nums; + if (type == "double") cpu_format = "fc64"; + else if (type == "float") cpu_format = "fc32"; + else if (type == "short") cpu_format = "sc16"; + uhd::stream_args_t stream_args(cpu_format, wirefmt); + channel_nums.push_back(boost::lexical_cast<size_t>(channel)); + stream_args.channels = channel_nums; + uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); + //send from file do{ - if (type == "double") send_from_file<std::complex<double> >(usrp, "fc64", wirefmt, file, spb); - else if (type == "float") send_from_file<std::complex<float> >(usrp, "fc32", wirefmt, file, spb); - else if (type == "short") send_from_file<std::complex<short> >(usrp, "sc16", wirefmt, file, spb); + if (type == "double") send_from_file<std::complex<double> >(tx_stream, file, spb); + else if (type == "float") send_from_file<std::complex<float> >(tx_stream, file, spb); + else if (type == "short") send_from_file<std::complex<short> >(tx_stream, file, spb); else throw std::runtime_error("Unknown type " + type); if(repeat and delay != 0.0) boost::this_thread::sleep(boost::posix_time::milliseconds(delay)); |