Sure, either way will work, but if you don't need any special
behavior, call set_history() and let the default forecast() in
block.cc:

 void
  block::forecast(int noutput_items, gr_vector_int &ninput_items_required)
  {
    unsigned ninputs = ninput_items_required.size ();
    for(unsigned i = 0; i < ninputs; i++)
      ninput_items_required[i] = noutput_items + history() - 1;
  }

do the work for you. This is what history() is there for.


On Wed, Jan 17, 2018 at 5:20 PM, Sakthivel Velumani <[email protected]>
wrote:

> Hi Markus,
>
> A better way is to specify the amount of data you need for the processing
> in the forecast function. By doing so, the GNU Radio scheduler will
> guarantee the sufficient amount of input data and hence you can remove the
> return 0 from the work function.
>
> Best,
> Sakthivel
>
> On Wed, Jan 17, 2018 at 3:20 PM, Markus Wirsing <[email protected]
> > wrote:
>
>> Hello,
>>
>> I have the following problem:
>>
>> I wrote a block that does some processing and needs to look ahead in the
>> data for a certain amount.
>> Therefore the work function of the sync_block will return 0 if the
>> current amount of data is insufficient.
>>
>> This works fine if the program is running infinitely.
>> However, when using a head block and running to completion,
>> it can occur that there is no more data available, which leads to the
>> scheduler infinitely trying again to call the work function, which then
>> returns 0.
>> Can this be detected by the block, so that the block can empty the input
>> buffer and the program can complete?
>>
>> Or is there another good way to solve this problem?
>> I feel like this should be a common problem, but I haven't found a good
>> solution.
>>
>> Thank you in advance for any hints on how to solve this.
>>
>> _______________________________________________
>> Discuss-gnuradio mailing list
>> [email protected]
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
_______________________________________________
Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to