aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/rx_timed_samples.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-05-18 14:26:43 -0700
committerJosh Blum <josh@joshknows.com>2010-05-18 14:26:43 -0700
commit17c494b79a99d947a150cdbc582ba331aeb57786 (patch)
treeee1f4533f5baeffa1b0af3853b8fdfe19c3a69d8 /host/examples/rx_timed_samples.cpp
parenteaa1508dcf6ff32496838f593ba4eb9eb1aee2ff (diff)
downloaduhd-17c494b79a99d947a150cdbc582ba331aeb57786.tar.gz
uhd-17c494b79a99d947a150cdbc582ba331aeb57786.tar.bz2
uhd-17c494b79a99d947a150cdbc582ba331aeb57786.zip
Added tx timed samples example.
Added called to device to get max samples per packet. Removed device props that gave max samples per packet.
Diffstat (limited to 'host/examples/rx_timed_samples.cpp')
-rw-r--r--host/examples/rx_timed_samples.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index 4b8774036..d2306c7c4 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,10 +80,11 @@ 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) continue; //wait for packets with contents