aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/rx_timed_samples.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-27 23:09:09 +0000
committerJosh Blum <josh@joshknows.com>2010-05-27 23:09:09 +0000
commite940d0225944a210584c386d270d09b132b5514b (patch)
tree59188c0b162c29c02ed09a59b32ab84010ecf269 /host/examples/rx_timed_samples.cpp
parentf113ae17863729f05b6ada815b9817cd16001211 (diff)
parent4eff47a4b66eff61feffe6498b9ecebef94dc6b9 (diff)
downloaduhd-e940d0225944a210584c386d270d09b132b5514b.tar.gz
uhd-e940d0225944a210584c386d270d09b132b5514b.tar.bz2
uhd-e940d0225944a210584c386d270d09b132b5514b.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp_e
Conflicts: host/utils/CMakeLists.txt
Diffstat (limited to 'host/examples/rx_timed_samples.cpp')
-rw-r--r--host/examples/rx_timed_samples.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index 4b8774036..64da260d5 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -29,7 +29,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::string args;
int seconds_in_future;
size_t total_num_samps;
- double rx_rate;
+ double rx_rate, freq;
//setup the program options
po::options_description desc("Allowed options");
@@ -39,10 +39,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("secs", po::value<int>(&seconds_in_future)->default_value(3), "number of seconds in the future to receive")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive")
("rxrate", po::value<double>(&rx_rate)->default_value(100e6/16), "rate of incoming samples")
+ ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
+ po::notify(vm);
//print the help message
if (vm.count("help")){
@@ -62,6 +63,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
sdev->set_rx_rate(rx_rate);
std::cout << boost::format("Actual RX Rate: %f Msps...") % (sdev->get_rx_rate()/1e6) << std::endl;
std::cout << boost::format("Setting device timestamp to 0...") << std::endl;
+ sdev->set_rx_freq(freq);
sdev->set_time_now(uhd::time_spec_t(0));
//setup streaming
@@ -78,11 +80,16 @@ 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){
uhd::rx_metadata_t md;
- std::complex<float> buff[1000];
+ std::vector<std::complex<float> > buff(dev->get_max_recv_samps_per_packet());
size_t num_rx_samps = dev->recv(
- boost::asio::buffer(buff, sizeof(buff)),
- md, uhd::io_type_t::COMPLEX_FLOAT32
+ boost::asio::buffer(buff),
+ md, uhd::io_type_t::COMPLEX_FLOAT32,
+ uhd::device::RECV_MODE_ONE_PACKET
);
+ if (num_rx_samps == 0 and num_acc_samps > 0){
+ std::cout << "Got timeout before all samples received, possible packet loss, exiting loop..." << std::endl;
+ break;
+ }
if (num_rx_samps == 0) continue; //wait for packets with contents
std::cout << boost::format("Got packet: %u samples, %u secs, %u nsecs")