GNU Radio 4.0 OOT Module Porting Guide: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
 
Line 43: Line 43:


<code>from gnuradio.kernel.filter import firdes</code>
<code>from gnuradio.kernel.filter import firdes</code>
=== Number of Ports ===
With the io_signature concept promoted to port objects, there is no longer the option to have dynamic number of ports at connect time.
The number of ports needs to be specified as a block parameter at instantiation.
This means for blocks like add, subtract, multiply, etc., the first argument is now the number of ports, rather than vlen

Latest revision as of 19:48, 13 October 2022

Porting Guide for 4.0 Out of Tree Modules

Right now this is a placeholder with a series of notes and reminders, and not an actual porting guide

Zero Item Size Blocks

  • Head
  • Copy
  • Null Source
  • Null Sink

The parameter for item size has been moved to the end, and defaults to 0. This means the item size will be deduced from the connection of the previous block.

To make a block with a deduced item size, you need to get the size of items from the buffer object in the work function

work(work_io& wio) { ... auto size = wio.outputs()[0].n_items * wio.outputs()[0].buf().item_size(); ... }

Coding Guidelines

  • Use #pragma once instead of include guards

Kernel Namespaces

In-tree, things that can be separated from the block implementations have been placed (or should be placed) into the kernel library. This includes things such as filter or math routines, that are not blocks, but carry some computational function that could be useful by more than one block, or outside of GNU Radio altogether

The general namespace mapping of these objects is: namespace gr { namespace kernel { namespace [modulename] { } } }

So when including things that used to just be at the module level, now live one level deeper

In python, this can be seen as

from gnuradio.kernel.filter import firdes

Number of Ports

With the io_signature concept promoted to port objects, there is no longer the option to have dynamic number of ports at connect time. The number of ports needs to be specified as a block parameter at instantiation.

This means for blocks like add, subtract, multiply, etc., the first argument is now the number of ports, rather than vlen