GRC Any Blocks

From SpenchWiki

Jump to: navigation, search

Reason

To enable arbitrary Python-wrapped GNU Radio blocks to be created and connected in the flow graph code generated by GNU Radio Companion (GRC). This means that you do not need to write an XML block definition for GRC to pick up a new block you may have created (although of course it's nicer if you do write one).

Use

There are three types of Any blocks:

  • Any: at least one input and at least one output
  • Any Source: at least one output only
  • Any Sink: at least one input only

You can configure the total number of sinks and sources (as constrained by the type). Since the blocks' ports are treated as 'virtual sinks' and 'virtual sources' (except for when actually generating the flow graph code), type inference will be used when connecting an Any block to another concrete block - you will see the port colour change to that of the connected upstream/downstream port (unless it is also an Any or virtual block, but things will still work in this case).

Fill the Maker field with the raw Python to be copied into the generated flow graph code. This will commonly be of the <package>.<block name> maker format, followed by the necessary arguments to create an instance of the block. You can of course use Python variables that you have represented as GRC Variable blocks elsewhere in your flow graph.

The 'Desc' field is simply so you can keep track of what each Any block actually does (the condensed string representation of the Python block instance is not very informative).

The final important thing to note is you MUST use the GRC Import block to import the relevant Python packages used in your Maker expressions, otherwise you will receive errors when Python attempts to execute the generated flow graph code.

Download

  • Code support is now in the latest official GRC release, so you don't have to apply the Python patch (but you will still need the XML block definitions).

Updates:

  • 10/11/2011: Fixed confusion between real virtual sinks/sources and Any ones (i.e. everything should work correctly now)
  • 26/07/2011: Recursive sink resolution from Any source ports)

Place the XML block definitions where GRC will pick them up (e.g. /usr/local/share/gnuradio/grc/blocks). To review the possible locations, see the GRC documentation.

IMPORTANT: The Any blocks will NOT work unless you apply the two patches to the relevant files in <GNU Radio path>/grc/python/

If you get a chance, please let me know how you go with the Any blocks if you choose to use them.

Views
Personal tools
follow me
Latest Content
Blog
Gallery