# Hier signal processing block in Python

**URL:** <https://www.ruby-forum.com/t/hier-signal-processing-block-in-python/225707>\
**Category:** GNU Radio\
**Created:** [January 24, 2013, 5:22pm UTC](https://www.ruby-forum.com/t/hier-signal-processing-block-in-python/225707 "2013-01-24T17:22:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 24, 2013, 5:22pm UTC](https://www.ruby-forum.com/t/hier-signal-processing-block-in-python/225707/1 "2013-01-24T17:22:13Z")

</div>

Hi all,

Can somebody explain me a bit the difference between blocks written in  
python in the way presented on the website and blocks like packet  
decoder,  
packet encoder, gfsk modulator, etc. The latter blocks are written also  
in  
Python, but they are different than the previous. Particularly I don’t  
understand why there are also thread classes stick to the blocks from  
the  
second group.  
And the most important thing is I would like to know how to make such  
block  
out of tree.

Many thanks

---

<div class="post-metadata">

**Author:** ![Nemanja\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nemanja\_S](https://www.ruby-forum.com/u/Nemanja_S)\
**Post date:** [January 24, 2013, 7:26pm UTC](https://www.ruby-forum.com/t/hier-signal-processing-block-in-python/225707/2 "2013-01-24T19:26:46Z")

</div>

On 01/24/2013 10:20 AM, Nemanja S. wrote:

> Hi all,
> 
> Can somebody explain me a bit the difference between blocks written in  
> python in the way presented on the website and blocks like packet decoder,  
> packet encoder, gfsk modulator, etc. The latter blocks are written also in  
> Python, but they are different than the previous. Particularly I don’t  
> understand why there are also thread classes stick to the blocks from the  
> second group.

Those old blocks are just hier blocks with some processing blocks from  
gnuradio, where the python interface part is outside of the scheduler,  
really just a python thread polling a message queue. The interface is a  
python function call or something.

So, there are APIs to create blocks in python that actually use the  
scheduler. For example, here is one that does the pkt framer/correlate  
but presents a message interface. This block has inputs and outputs that  
can be connected in a gnuradio flow graph.

> <https://github.com/guruofquality/grextras/blob/master/python/packet_framer.py>

Then you can do cool things like this:  
[https://github.com/jmalsbury/pre-cog/wiki](https://github.com/jmalsbury/pre-cog/wiki)

> And the most important thing is I would like to know how to make such block  
> out of tree.

Most of the feature above is in gnuradio master branch, but I dont think  
there is a doc, so you will have to interpolate from this:

> **[Blocks Coding Guide](https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide)**
>
> Advanced GNU Radio Blocks. Contribute to guruofquality/grextras development by creating an account on GitHub.

-josh

---

<div class="post-metadata">

**Author:** ![Nemanja\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nemanja\_S](https://www.ruby-forum.com/u/Nemanja_S)\
**Post date:** [January 24, 2013, 11:19pm UTC](https://www.ruby-forum.com/t/hier-signal-processing-block-in-python/225707/3 "2013-01-24T23:19:23Z")

</div>

Thank you Josh, I hope your answer will help.

The problem particularly with packet decoder block which could be found  
in  
packet.py is that I can’t figure out how messages goes from framer sink  
to  
the message source.  
Namely, framer sink sends message to the queue. There is a thread  
responsible for reading message from the queue and for calculating crc.  
After that, callback function is called and if message was OK, it will  
post  
message again to the queue (Isn’t there only one queue between two  
blocks  
and both read from and write to that queue?).

By the way, do you think that message source sounds like block which  
produces messages (that’s what i was thinking at first glance, but maybe  
cause I am not native speaker)?

Cheers
