discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] ninput_items_required=1024


From: G Reina
Subject: Re: [Discuss-gnuradio] ninput_items_required=1024
Date: Tue, 6 Jun 2017 11:30:29 -0700

I may have just answered it. I change the sync_block to a basic_block and it seems to be working.

-Tony


On Tue, Jun 6, 2017 at 11:12 AM, G Reina <address@hidden> wrote:
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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]