aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-08 11:48:40 -0700
committerJosh Blum <josh@joshknows.com>2011-10-08 11:48:40 -0700
commitaa908fafa2f8dcf9d869c21e5b8cd14aab8a6147 (patch)
tree28f499adad5a7f00606a612e420908627e848795
parent26aacf3edc1331691827156903a65125532ea6a8 (diff)
downloaduhd-aa908fafa2f8dcf9d869c21e5b8cd14aab8a6147.tar.gz
uhd-aa908fafa2f8dcf9d869c21e5b8cd14aab8a6147.tar.bz2
uhd-aa908fafa2f8dcf9d869c21e5b8cd14aab8a6147.zip
uhd: help messages for user on rx samples to file
-rw-r--r--host/examples/rx_samples_to_file.cpp16
-rw-r--r--host/examples/tx_samples_from_file.cpp2
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<typename samp_type> void recv_to_file(
uhd::rx_metadata_t md;
std::vector<samp_type> 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<typename samp_type> 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<std::string>(&args)->default_value(""), "multi uhd device address args")
("file", po::value<std::string>(&file)->default_value("usrp_samples.dat"), "name of the file to write binary samples to")
- ("type", po::value<std::string>(&type)->default_value("float"), "sample type: double, float, or short")
+ ("type", po::value<std::string>(&type)->default_value("short"), "sample type: double, float, or short")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(0), "total number of samples to receive")
("spb", po::value<size_t>(&spb)->default_value(10000), "samples per buffer")
("rate", po::value<double>(&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<std::string>(&args)->default_value(""), "multi uhd device address args")
("file", po::value<std::string>(&file)->default_value("usrp_samples.dat"), "name of the file to read binary samples from")
- ("type", po::value<std::string>(&type)->default_value("float"), "sample type: double, float, or short")
+ ("type", po::value<std::string>(&type)->default_value("short"), "sample type: double, float, or short")
("spb", po::value<size_t>(&spb)->default_value(10000), "samples per buffer")
("rate", po::value<double>(&rate), "rate of outgoing samples")
("freq", po::value<double>(&freq), "RF center frequency in Hz")