[Top][All Lists]

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

Re: [Discuss-gnuradio] zero ninput_items_required[0]

From: Martin Braun (CEL)
Subject: Re: [Discuss-gnuradio] zero ninput_items_required[0]
Date: Fri, 18 Oct 2013 14:59:26 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Oct 18, 2013 at 02:32:48PM +0200, Nemanja Savic wrote:
> The body of my forecast function is:
> ninput_items_required[0] = noutput_items * d_sym_rate / d_sampling_freq;
> printf("ninput_items_required %d, noutput_items %d\n", ninput_items_required
> [0], noutput_items);

If d_sym_rate and d_sampling_freq are integers, integer division will
cause ninput_items_required to be zero for small values of

> when i run execution, the output is following:
> ninput_items_required 8, noutput_items 4096
> ninput_items_required 4, noutput_items 2048
> ninput_items_required 2, noutput_items 1024
> ninput_items_required 1, noutput_items 512
> ninput_items_required 0, noutput_items 256
> ninput: 0, produced: 0
> The last line of the output comes from general_work function and prints number
> of input items and number of produced output samples.
> Can somebody explain me why forecast is called 5 times, till number of input
> items reach 0, and after that nothing is possible in work function, cause it
> won't enter the loop since ninput_items = 0;

Depending on the state of the buffers, the scheduler calls forecast()
until it finds a value of ninput_items_required that works (it tries to
process as much as possible). In your case, there is probably some
situation where the input buffer is not full.
The way you've set up forecast(), the scheduler will eventually find out
that it doesn't need any items to produce at least 256 output items. So
it calls work() with no input data, expecting 256 output items.
But since you can't produce anything without input, nothing happens.

It seems like what you want is a sync_decimator, got a gr::block. This
means you set relative_rate in the ctor and don't need to handle all of this
yourself. Make sure you don't set relative_rate to zero, again!
In a sync_decimator, you won't need forecast() at all and your work
function is much simpler. The scheduler will also never try to call a
sycn_decimator w/o input.


Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstraße 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071

KIT -- University of the State of Baden-Württemberg and
National Laboratory of the Helmholtz Association

Attachment: pgpSfdteOuQCF.pgp
Description: PGP signature

reply via email to

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