discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] How to use forecast()?


From: Mir M. Ali
Subject: Re: [Discuss-gnuradio] How to use forecast()?
Date: Mon, 31 May 2010 01:27:36 -0500

if you still wanna use forecast and general_work then this is how you do it ...

void your_block::forecast(int noutput_items,gr_vector_int &ninput_items_required){

ninput_items_required[0]=100 * noutput_items;
ninput_items_required[1]=100 * noutput_items;

}

the scheduler will choose the number for noutput_items and it will make sure that you have the required items on your input streams by calling forecast. 
Suppose your output items are a multiple of a specific item e.g. if you always want 100 items produced each time your general_work() is called then you have to tell the scheduler that the noutput_items must be a multiple of 100. Call set_output_miltiple() to let the scheduler know this. This is how it's done,


dsss_spreading_b::dsss_spreading_b(unsigned int length_PN):gr_block("spreading_b",
gr_make_io_signature(2,2,sizeof(unsigned char)),
gr_make_io_signature(1,1,sizeof(unsigned char))),
d_length_PN(length_PN)
{
set_output_multiple(d_length_PN);
}


for example the above constructor shows a block that has 2 input streams and one output stream and it calls set_output_multilple which has an integer parameter d_length_PN passed. The scheduler will make sure that the noutput_items that it selects will be a multiple of d_length_PN....

if d_length_PN=100 ...then scheduler will choose n*100 output_items ... where n in an integer.

Look into the examples or the blocks in the gnuradio. Read the comments in gr_block.h file. This will give you all the information.

Good luck.


On Sun, May 30, 2010 at 9:16 PM, Eric Blossom <address@hidden> wrote:
On Sun, May 30, 2010 at 01:33:17PM -0700, Zohair wrote:
>
> Hello everybody,
>
> I'm working on building a block that accepts many inputs (say n) and has one
> output. For a single output item to be generated, 100 samples from each
> input port should be taken. How can I use forecast() and general_work() to
> serve my purpose? I read somewhere that we never call or modify the
> parameters explicitly, the scheduler does this instead. But how does the
> scheduler know that I need 100 samples exactly.
>
> Any help is highly appreciated.

No need to use general_work or forecast.

Derive from gr_sync_decimator.  There are many examples in
gnuradio-core/src/lib/general.

Eric

_______________________________________________
Discuss-gnuradio mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio


reply via email to

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