3

I am writing my own GNU Radio block in Python, and I want to set a minimum buffer size for both (or either) the input and output buffers of that block.

Is there a function or piece of code that can do this?

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Doe
  • 185
  • 3
  • 13

1 Answers1

4

You can only set the minimum output buffer size (that's not a problem; every input buffer is the output buffer of another block), using the gr.block.set_min_output_buffer(port, size) call, for example by doing:

  • by adding the call def __init__(self): gr.sync_block.__init__(self, name="block_with_buffer", in_sig=[numpy.float32], out_sig=[numpy.float32]) self.set_min_output_buffer(2**20) in your constructor, or
  • by calling
    your_block_handle.set_min_output_buffer(2**20)
    in whatever python script you're using to set up your flow graph, or
  • by using GNU Radio Companion's "advanced" tab (in your block's property dialog) to set the minimum output buffer size.

However, GNU Radio forgot to wrap that call in its python block class. Hence, you currently can't use that with python blocks, sorry, only with C++ blocks. I'm currently writing a patch for that; if all goes well, you'll see this on the master branch soon :)

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • 1. just to make sure I understand it correctly: according to the last paragraph in your comment, you say that if my block is written in python, adding the line: `self.set_min_output_buffer(2**20)` will not work, is that correct?? (which means I have to write my block only in C++) 2. If this is not what you mean then I'm still unclear on this because I wrote my block in python and when I added the call inside the __init__(self): exactly as you did in the first suggestion, and ran my code, I go the following error: AttributeError: object has no attribute 'set_min_output_buffer' – Doe Jun 17 '16 at 21:42