Hi Zach, sorry it took me so long to react: so, let's dissect a few things:
First, the general purposes of these functions: * forecast() is called by the *scheduler* to ask your block "hey, if I'd need you to produce N items, how much would you need on your 0. (and 1., and 2.,… if existing) input for that?". The scheduler usually repeatedly calls that with a decreasing N until the number of samples your block requires can be fulfilled by the number of input items that the scheduler has ready. If that never happens, usually, something is broken. * consume() is something that *you* call from within a (general_)work() to signal the scheduler how many items you've consumed from the input(s). * produce() is something that *you* call from within a (general_)work() to signal the scheduler how many items you've put into the output buffer. *If* you use produce, you should return the magic WORK_CALLED_PRODUCE values. You usually don't call produce() – you just return the number of consumed samples instead. * noutput_items is **not** a variable that you set – it's the info how many items you are asked to produce (parameter to forecast()) or how many items you're **allowed at most** to produce (when it's the parameter to a (general_)work()) Again, the better parts of your mail have been broken by Nabble. Abandon Nabble. Subscribe directly: https://lists.gnu.org/mailman/listinfo/discuss-gnuradio Hope that helps, Marcus On 05/26/2017 07:49 PM, Zach Morris wrote: > That worked to create a general block, but I'm still having some trouble with > implementing the forecast(), consume() and produce() functions. > > The goal of the block is to discard elements in an input vector that are > below a certain threshold, and eventually update some statistics based on > the remaining elements. For a vector of 256 elements, there could be > anywhere between 0 and 256 outputs (the arbitrary ratio you mentioned). > > The default forecast function has a 1:1 ratio: > > Should I replace "noutput_items" with my "vector_length" parameter, ensuring > that we always get (for example) 256 inputs? > > In the general_work function, I think we want to consume the entire input > vector once we figure out which elements are above the threshold: > > I'm not sure about the produce function; do I need to tell the system how > many items I produce, or is that covered at the end of general_work: > > > Thank you kindly, > > Zach > > > > > -- > View this message in context: > http://gnuradio.4.n7.nabble.com/Python-block-help-tp51706p64062.html > Sent from the GnuRadio mailing list archive at Nabble.com. > > _______________________________________________ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio