summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarm te Hennepe <d.h.tehennepe@student.utwente.nl>2015-03-04 17:38:36 +0100
committerHarm te Hennepe <d.h.tehennepe@student.utwente.nl>2015-03-04 17:39:30 +0100
commit41f1ba4171b74354ab25cf066451d8ba940d9ec4 (patch)
tree619c26109b8ded870defb073d349c1fca549482d
parent4a1d5aafbbee9a5ff181251830d20b34894b6095 (diff)
Warn when the throttlers sleep time variable overflows
-rw-r--r--gr-blocks/lib/throttle_impl.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/gr-blocks/lib/throttle_impl.cc b/gr-blocks/lib/throttle_impl.cc
index 7c24f80ae1..d818ce192b 100644
--- a/gr-blocks/lib/throttle_impl.cc
+++ b/gr-blocks/lib/throttle_impl.cc
@@ -28,6 +28,7 @@
#include <gnuradio/io_signature.h>
#include <cstring>
#include <boost/thread/thread.hpp>
+#include <limits>
pmt::pmt_t throttle_rx_rate_pmt(pmt::intern("rx_rate"));
@@ -107,8 +108,13 @@ namespace gr {
//if the expected samples was less, we need to throttle back
if(d_total_samples > expected_samps) {
+ double sleep_time = (d_total_samples - expected_samps)/d_samps_per_us;
+ if (std::numeric_limits<long>::max() < sleep_time) {
+ GR_LOG_ALERT(d_logger, "WARNING: Throttle sleep time overflow! You "
+ "are probably using a very low sample rate.");
+ }
boost::this_thread::sleep(boost::posix_time::microseconds
- (long((d_total_samples - expected_samps)/d_samps_per_us)));
+ (long(sleep_time)));
}
//copy all samples output[i] <= input[i]