aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/rx_multi_samples.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-11-07 18:47:29 -0800
committerJosh Blum <josh@joshknows.com>2011-11-07 18:47:29 -0800
commite219ad10a6e86cd4edc748f2218e01a9890e108c (patch)
tree372f2e426781de9885889bec6aa98697006268ec /host/examples/rx_multi_samples.cpp
parent8ff8f206d317e8d9c026fef9228a80edc241f9d4 (diff)
parent11f1390bbde65c60f45962acb128cac1ce21e474 (diff)
downloaduhd-e219ad10a6e86cd4edc748f2218e01a9890e108c.tar.gz
uhd-e219ad10a6e86cd4edc748f2218e01a9890e108c.tar.bz2
uhd-e219ad10a6e86cd4edc748f2218e01a9890e108c.zip
Merge branch 'uhd_next'
Diffstat (limited to 'host/examples/rx_multi_samples.cpp')
-rw-r--r--host/examples/rx_multi_samples.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp
index 8f6d7c939..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);
@@ -111,6 +110,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::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_stream(stream_args);
+
//setup streaming
std::cout << std::endl;
std::cout << boost::format(
@@ -126,7 +132,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<std::vector<std::complex<float> > > buffs(
usrp->get_rx_num_channels(), std::vector<std::complex<float> >(samps_per_buff)
);
@@ -141,10 +147,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