Search code examples
c++gnuradio

GNU Radio io_signature


I'm getting into GNU Radio and after I created a new block, in the main class I have a peace of code like this :

square_ff_impl::square_ff_impl()
  : gr::block("square_ff",
              gr::io_signature::make(<+IMIN+>, <+IMAX+>, sizeof (<+ITYPE+>)), // input signature
              gr::io_signature::make(<+OMIN+>, <+OMAX+>, sizeof (<+OTYPE+>))) // output signature
{
    // empty constructor
}

I don't really know exactly what to put in MIN and MAX (even after reading the doc).

Can you give me some examples please ?


Solution

  • IMIN - minimum number of acceptable input ports
    IMAX - maximum number of acceptable input ports
    OMIN - minimum number of acceptable output ports
    OMAX - maximum number of acceptable output ports
    

    The documentation talks about it a bit in the IOSignatures portion of the BlocksCodingGuide:

    • The first two parameters are min and max number of ports, this allows blocks to have a selectable number of ports at runtime.

    A value of -1 means "unlimited".

    As an example of a source block, take a look at the IO signature of the null source block, which takes no input:

    null_source_impl::null_source_impl (size_t sizeof_stream_item)
      : sync_block("null_source",
                      io_signature::make(0, 0, 0),
                      io_signature::make(1, -1, sizeof_stream_item))
    {
    }
    

    For a sink, check out null sink, which has no output:

    null_sink_impl::null_sink_impl(size_t sizeof_stream_item)
      : sync_block("null_sink",
                   io_signature::make(1, -1, sizeof_stream_item),
                   io_signature::make(0, 0, 0))
    {
    }
    

    And a simple processing blocks, add_ff, which takes unlimited input and produces exactly 1 output stream:

    add_ff_impl::add_ff_impl(size_t vlen)
      : sync_block("add_ff",
              io_signature::make (1, -1, sizeof(float)*vlen),
              io_signature::make (1,  1, sizeof(float)*vlen)),
    d_vlen(vlen)
    {
    ...