discuss-gnuradio
[Top][All Lists]
Advanced

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

GNU Radio 3.9.3.0 Python basic block - issues with forecast and produce


From: Patric Müller
Subject: GNU Radio 3.9.3.0 Python basic block - issues with forecast and produce
Date: Fri, 21 Jan 2022 15:14:29 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

Hello everyone,

I am currently trying to create a basic block similar to this issue:
https://stackoverflow.com/questions/68289222/gnu-radio-buffer-size

Some software and hardware info:
GNU Radio version: 3.9.3.0
Python version: 3.9.7
OS: Ubuntu 20.04

I always want to work on the same number of items, say 1024. Now I would like to use up all of the items, but I want to produce something between say 500 - 1500 items. For now, I would like to create a simple block with one input and one output, which consumes a set number of items and outputs only a fraction of those incoming items in order to understand it better.

Therefore I started with a general block and wanted to change ninput_items_required[0]. However, ninput_items_required is an integer. Trying to directly change this integer values results in:

Unable to cast Python instance to C++ type (compile in debug mode for details)


My second question is about the produce() function. If it is used, general_work() should return
WORK_CALLED_PRODUCE
but how exactly? After calling produce() and telling the scheduler how many items are produced, can I then change output_items[0]?

My attempt at the forecast() function and general_work() is provided below. General suggestions/hints or a basic example would be helpful and immensely appreciated. If additional background is required, let me know and I will gladly provide more information.


    def forecast(self, noutput_items, ninput_items_required):
        # Estimate, that we will always need self.buffer_len items on input port [0]
        ninput_items_required[0] = self.buffer_len


    def general_work(self, input_items, output_items):
        # Firstly check, if input_items has a sufficient amount of items
        if len(input_items[0]) >= self.buffer_len:
            # Then consume exactly self.buffer_len items on input_port[0]
            self.consume(0, self.buffer_len)
            # Now I would like to only output a fraction of the input items
            # say the first self.out_items, on output port[0]
            self.produce(0, self.out_items)
            # Do I set my output_items[0] here?
        # Now I only need to return WORK_CALLED_PRODUCE, but how exactly?
        return 0


Kind regards,
Patric Müller





reply via email to

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