# Noutput\_items

**URL:** <https://www.ruby-forum.com/t/noutput-items/229981>\
**Category:** GNU Radio\
**Created:** [May 25, 2014, 9:55am UTC](https://www.ruby-forum.com/t/noutput-items/229981 "2014-05-25T09:55:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [May 25, 2014, 9:55am UTC](https://www.ruby-forum.com/t/noutput-items/229981/1 "2014-05-25T09:55:14Z")

</div>

Hi,  
I’m confused about what is the return value of the work function if I  
have  
multiple output ports?  
I use _produce()_ method to determine how many items produced on each  
port,  
so what does it mean to return again a number from work if I produced  
different number of items for each output port??

best,  
Mostafa

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [May 25, 2014, 10:22am UTC](https://www.ruby-forum.com/t/noutput-items/229981/2 "2014-05-25T10:22:22Z")

</div>

Hi Mostafa,

a few things:

1. work() only is meaningful for sync and interpolator/decimator blocks;  
then, you always have a fixed relation between consumed and produced  
items, and you can’t have a different number of output items on  
different ports.
2. noutput\_items is the parameter of the work function that tells you  
how many items you can produce _maximally_. It’s not the number you  
produced; in the (performance-wise) best case, you return noutput\_items  
to tell that your block consumed and produced everything GNU Radio asked  
it to. If you produced less, you return exactly that amount.
3. When using produce(), you should return the special value  
WORK\_CALLED\_PRODUCE.
4. If you’re having different output item numbers on different ports,  
you’re bound to use a general block with general\_work. Then you’ll have  
to consume() at each input the amount of items that you’ve used and  
produce them at each output. Also, you should implement a forecast()  
method just to give GNU Radio an idea how many items you need on which  
input port if you have to produce a certain number of output items on  
different ports.
5. Most of the time, blocks described by 4. are complicated. I used to  
write blocks like that, but nowadays I rarely do, because the message  
port API of GNU Radio fits my designs’ needs better, most of the time.  
When dealing with things that are basically packets of digitally  
modulated data, take a look at the Tagged Stream / PDU infrastructure as  
described in the GNU Radio doxygen.
6. I’ve seen some screenshots of defunctional flowgraphs where the  
developer tried to implement correction loops (e.g. phase correction  
loop) by outputting an error/correction estimate on one output port and  
the corrected samples on the other, feeding back the correction to a  
multiplier upstream. Don’t fall into that trap! In GNU Radio, you can’t  
have sample loops, since this violates causality requirements (a block  
can’t produce output without input, but within a loop there is no input  
without output). Just mentioning this because it can lead to a lot of  
frustration 😉

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [May 25, 2014, 10:55am UTC](https://www.ruby-forum.com/t/noutput-items/229981/3 "2014-05-25T10:55:08Z")

</div>

Thank you so much for your complete explanation. Just the term  
_maximally_  
and WORK\_CALLED\_PRODUCE works for me 🙂

best,
