aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bladerf/bladerf_source_c.cc
diff options
context:
space:
mode:
authorJon Szymaniak <jon.szymaniak@gmail.com>2014-10-26 16:08:42 -0400
committerDimitri Stolnikov <horiz0n@gmx.net>2014-11-03 23:24:04 +0100
commit6e75abf1986ff4c3a3b71d0c32537956adce8118 (patch)
tree296b547ebf69ad0fbe1e29af9e3c7f5092df9bb4 /lib/bladerf/bladerf_source_c.cc
parent7f82d289a6f196a6f7b72bc0cff1807870ee8837 (diff)
bladeRF: Don't fail out until 3 consecutive errors have occurred
This change is intended to make the bladeRF source/sink implementations slightly more resilient to any transient issues in a flow graph. For poor choices of buffers/transfers or under high CPU load, an RX or TX operation might time out. Instead of immediately reporting WORK_DONE and bailing out, an error message is now printed and the device will attempt to continue transmitting/receiving samples. After 3 consecutive errors have occurred on an RX/TX operation, the device will report WORK_DONE; in this situation, something is likely very wrong.
Diffstat (limited to 'lib/bladerf/bladerf_source_c.cc')
-rw-r--r--lib/bladerf/bladerf_source_c.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/bladerf/bladerf_source_c.cc b/lib/bladerf/bladerf_source_c.cc
index 4c698f1..c2fd15d 100644
--- a/lib/bladerf/bladerf_source_c.cc
+++ b/lib/bladerf/bladerf_source_c.cc
@@ -163,7 +163,17 @@ int bladerf_source_c::work( int noutput_items,
if ( ret != 0 ) {
std::cerr << _pfx << "bladerf_sync_rx error: "
<< bladerf_strerror(ret) << std::endl;
- return WORK_DONE;
+
+ _consecutive_failures++;
+
+ if ( _consecutive_failures >= MAX_CONSECUTIVE_FAILURES ) {
+ std::cerr << _pfx
+ << "Consecutive error limit hit. Shutting down."
+ << std::endl;
+ return WORK_DONE;
+ }
+ } else {
+ _consecutive_failures = 0;
}
current = _conv_buf;