summaryrefslogtreecommitdiff
path: root/gr-digital/lib/header_payload_demux_impl.cc
diff options
context:
space:
mode:
authorRichard C. Bell <richard.bell1@navy.mil>2015-06-01 18:35:52 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2015-06-14 07:37:19 -0700
commitcba91e3a25d27e39379fe41381beaf55a52ab43f (patch)
tree8f7d5cceb65ed0c3bfac9fed12d5c6c8b0dc8d29 /gr-digital/lib/header_payload_demux_impl.cc
parent6057a6c3225618ab9f455c58785041a0ea9074dc (diff)
Fix an error in which the wrong header is allowed through
Added break statements to every case. This fixed issues we were having with this block in which the wrong header would be allowed through, sometimes seconds after start, sometimes hours after start, depending on the HPD settings used. With the break statements, general_work must be called each time a new state begins, which removes any sample offset issues that could be happening in the original fall through method. I suspect the original methods issue is caused by the check_items_available function, though I have not confirmed this. I've tested this fix against the current built-in block implementation in my own custom flowgraph, and in the rx_ofdm.grc example. The fix works in both cases.
Diffstat (limited to 'gr-digital/lib/header_payload_demux_impl.cc')
-rw-r--r--gr-digital/lib/header_payload_demux_impl.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/gr-digital/lib/header_payload_demux_impl.cc b/gr-digital/lib/header_payload_demux_impl.cc
index 160f54036d..89428fa86e 100644
--- a/gr-digital/lib/header_payload_demux_impl.cc
+++ b/gr-digital/lib/header_payload_demux_impl.cc
@@ -221,7 +221,13 @@ namespace gr {
in += d_itemsize;
nread++;
d_state = STATE_FIND_TRIGGER;
- // Fall through
+ // The following break was added to this state as well as STATE_FIND_TRIGGER
+ // and STATE_HEADER. There appears to be a bug somewhere in this code without
+ // the breaks that can lead to failure of this block. With the breaks in the code
+ // testing has shown more stable performance with various block paramters.
+ // If an offset calculation bug is found and fixed, it should be possible to
+ // remove these breaks for some performance increase.
+ break;
case STATE_FIND_TRIGGER:
trigger_offset = find_trigger_signal(nread, noutput_items, input_items);
@@ -234,7 +240,7 @@ namespace gr {
consume_each (trigger_offset);
in += trigger_offset * d_itemsize;
d_state = STATE_HEADER;
- // Fall through
+ break;
case STATE_HEADER:
if (check_items_available(d_header_len, ninput_items, noutput_items, nread)) {
@@ -262,7 +268,7 @@ namespace gr {
consume_each (nread);
in += nread * d_itemsize;
d_state = STATE_PAYLOAD;
- // Fall through
+ break;
case STATE_PAYLOAD:
if (check_items_available(d_curr_payload_len, ninput_items, noutput_items, nread)) {
@@ -274,7 +280,7 @@ namespace gr {
set_min_noutput_items(d_output_symbols ? 1 : (d_items_per_symbol + d_gi));
d_state = STATE_FIND_TRIGGER;
}
- break;
+ break;
default:
throw std::runtime_error("invalid state");