Search code examples
pythongnuradio

Creating a Block with Number of Fixed Input Elements GNU RADIO


I was able to create a block that has an input quantity other than output, in case the output will always have 6 more elements. But now I'm having trouble making the block always get length X complex samples. For example my block will always have a fixed input amount and will not be the default of 4096 samples

import numpy
from gnuradio import gr
import math
import numpy as np

class codificador_wavelet(gr.basic_block):
    """
     docstring for block codificador_wavelet
   """
   def __init__(self,taxa):
       gr.basic_block.__init__(self,
          name="codificador_wavelet",
          in_sig=[numpy.complex64],
          out_sig=[numpy.complex64])
       self.taxa=taxa
       self.mg=8
   def forecast(self, noutput_items, ninput_items_required):
       n = noutput_items-6 
       ninput_items_required[0] = 1 if (n<=0) else n

Solution

  • I don't know if this is quite a full answer, but I don't have enough reputation to comment.

    If the block always wants a known constant input size, you might try accepting vector inputs using the stream to vector block like what's shown in the core concepts tutorial. To hide this from the user, you can use a hierarchical block containing the stream to vector block and the block that you're creating.