From aa908fafa2f8dcf9d869c21e5b8cd14aab8a6147 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 8 Oct 2011 11:48:40 -0700 Subject: uhd: help messages for user on rx samples to file --- host/examples/rx_samples_to_file.cpp | 16 +++++++++++++++- host/examples/tx_samples_from_file.cpp | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 05d9b15b7..1e213c83a 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -41,6 +41,7 @@ template void recv_to_file( 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( @@ -49,6 +50,19 @@ template void recv_to_file( ); if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; + if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW){ + if (overflow_message){ + overflow_message = false; + std::cerr << boost::format( + "Got an overflow indication. Please consider the following:\n" + " Your write medium must sustain a rate of %fMB/s.\n" + " Dropped samples will not be written to the file.\n" + " Please modify this example for your purposes.\n" + " This message will not appear again.\n" + ) % (usrp->get_rx_rate()*sizeof(samp_type)/1e6); + } + continue; + } if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){ throw std::runtime_error(str(boost::format( "Unexpected error code 0x%x" @@ -75,7 +89,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("help", "help message") ("args", po::value(&args)->default_value(""), "multi uhd device address args") ("file", po::value(&file)->default_value("usrp_samples.dat"), "name of the file to write binary samples to") - ("type", po::value(&type)->default_value("float"), "sample type: double, float, or short") + ("type", po::value(&type)->default_value("short"), "sample type: double, float, or short") ("nsamps", po::value(&total_num_samps)->default_value(0), "total number of samples to receive") ("spb", po::value(&spb)->default_value(10000), "samples per buffer") ("rate", po::value(&rate), "rate of incoming samples") diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index d052baa4a..03fc4c8d4 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -70,7 +70,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("help", "help message") ("args", po::value(&args)->default_value(""), "multi uhd device address args") ("file", po::value(&file)->default_value("usrp_samples.dat"), "name of the file to read binary samples from") - ("type", po::value(&type)->default_value("float"), "sample type: double, float, or short") + ("type", po::value(&type)->default_value("short"), "sample type: double, float, or short") ("spb", po::value(&spb)->default_value(10000), "samples per buffer") ("rate", po::value(&rate), "rate of outgoing samples") ("freq", po::value(&freq), "RF center frequency in Hz") -- cgit v1.2.3