# Header/Payload Demux Bug Fix

**URL:** <https://www.ruby-forum.com/t/header-payload-demux-bug-fix/242163>\
**Category:** GNU Radio\
**Created:** [June 1, 2015, 6:26pm UTC](https://www.ruby-forum.com/t/header-payload-demux-bug-fix/242163 "2015-06-01T18:26:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 1, 2015, 6:26pm UTC](https://www.ruby-forum.com/t/header-payload-demux-bug-fix/242163/1 "2015-06-01T18:26:05Z")

</div>

Martin et. al.,

The fix that makes this block work for us in any scenario, is to add a  
break statement at the end of every case statement (don’t allow the fall  
through’s to happen).

This leads me to believe the source of the issues comes from the way  
offsets are calculated between states within one general\_work call.  
Letting  
general\_work return after every state resolves any of these issues. I  
think  
this points to check\_items\_available as the problem child, but I  
couldn’t  
confirm that.

The testbench I use to confirm this has the built-in HPD block and my  
custom HPD block, which has break statements at the end of each state.  
The  
built-in HPD block will start producing errors seconds after I start the  
flowgraph. With the built-in disabled and my custom block in the same  
flowgraph, it will run indefinitely (tested for 20 hours).

The settings of both blocks were:

_Header Length: 8_

_Items per Symbol: 8_

_Length tag key: “packet\_length”_

_Output Format: Items_  
_IO Type: Complex_  
_Trigger Tag Key: blank_

The input to HPD is unpacked and the header is 64 bits long when packed.  
I  
did the bulk of testing using a custom tag\_trigger block that outputs a  
1  
when it sees a certain tag and 0 otherwise to feed the detect port of  
HPD.  
I just tried it using the Trigger Tag Key of the HPD block itself and it  
also seems to be fine. So either way seems to work.

I looked at the bug submission instructions, I think forking from github  
is  
the easiest way of doing it, but I need a little clarification. In this  
case, am I correct to fork the repo, add the break statements to the HPD  
source, and request a pull along with this explanation? I won’t be  
adding  
QA tests or anything else.

v/r,  
Rich

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [June 1, 2015, 8:14pm UTC](https://www.ruby-forum.com/t/header-payload-demux-bug-fix/242163/2 "2015-06-01T20:14:45Z")

</div>

Hey Richard,

good work! Did you also test this patch with the OFDM tx/rx example, or  
some other settings to make sure this didn’t just fix your setup?

I’m a bit annoyed with myself for not getting the offset calculations  
right. Maybe there’s another fix that won’t add breaks, but frankly,  
let’s get this block right before we get it fast.

So, in order to get your changes in, you fork GNU Radio on github, push  
your patch there, then submit a pull request. Read also this:  
[http://gnuradio.org/redmine/projects/gnuradio/wiki/Development](http://gnuradio.org/redmine/projects/gnuradio/wiki/Development)

If this is a bigger patch, we’ll need a copyright assignment. But we’ll  
tell you if that’s the case.

Thanks!

Martin

---

<div class="post-metadata">

**Author:** ![reback](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@reback](https://www.ruby-forum.com/u/reback)\
**Post date:** [June 1, 2015, 9:04pm UTC](https://www.ruby-forum.com/t/header-payload-demux-bug-fix/242163/3 "2015-06-01T21:04:24Z")

</div>

I tested it with the rx\_ofdm example and it works as it did before  
(didn’t  
test over several hours however).

Making the pull request now.

Rich

On Mon, Jun 1, 2015 at 11:13 AM, Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
