I'm creating a Python block that calculates a custom FFT. I need to ensure that I get at least 1024 data points for every input to the block.
>From my reading, it looks like I should just be able to do this with the forecast() function in the Python block. So I've done this: class blk(gr.sync_block): # other base classes are basic_block, > decim_block, interp_block > > def __init__(self, bandWidthMHz=100.0): # only default arguments here > """arguments to this function show up as parameters in GRC""" > gr.sync_block.__init__( > self, > name='test', # will show up in GRC > in_sig=[np.complex64], > out_sig=[np.float32] > ) > # if an attribute with the same name as a parameter is found, > # a callback is registered (properties work, too). > self.bandWidthMHz = bandWidthMHz > self.MM = 0 > > def forecast(self, noutput_items, ninput_items_required=1024): > ninput_items_required[0] = 1024 > > def work(self, input_items, output_items): > if (np.shape(input_items[0])[0] < 1024): > print(np.shape(input_items[0])) > output_items[0] = [3.5, -1, 0, 1] > return len(output_items[0]) > According to the docs, if I set ninput_items_required[0] = 1024, then forecast should prevent the work from being done until I have at least 1024 input values. Nevertheless, the print statement I have in the work function is showing that the program gets to the work even when the input_items[0] is much less (e.g. 24, 102, 960) than 1024. Can anyone point me in the right direction? Can I just have the work function skip execution if len(input_items[0]) < 1024? Or, will that drop data? Thanks for your help. -Tony p.s. I'm just doing this in a Python block from the GRC. So this is not a custom OOT module. Does that matter?
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio