# Scheduling a block even with no input items RE: Flow graph blocking when doing 2x1 transmission

**URL:** <https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175>\
**Category:** GNU Radio\
**Created:** [June 3, 2014, 3:32pm UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175 "2014-06-03T15:32:24Z")\
**Posts on this page:** 8\
**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:** [June 3, 2014, 3:32pm UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/1 "2014-06-03T15:32:24Z")

</div>

Dear All,

Had anyone tried to implementing a gnuradio block that will output zeros  
if there are no items at the input, and will simply copy the input to  
output otherwise?

I find that if there are no items at the input, the block never gets  
scheduled.

I want this block to feed zeros to my USRP until actual data is ready to  
be passed to it.

Regards,

David

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 3, 2014, 3:54pm UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/2 "2014-06-03T15:54:49Z")

</div>

On 06/03/2014 03:30 PM, David Halls wrote:

> be passed to it.  
> Hey David,

any reason you can’t use eob/sob?

Also, did you set forecast accordingly?

Note that this can go wrong easily: If this blocks produces a bajillion  
zeros very quickly, nothing will happen until the USRP has consumed them  
all.

M

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 3, 2014, 4:00pm UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/3 "2014-06-03T16:00:43Z")

</div>

Hey Martin,

Good to hear from you as always. Gnuradio scheduling baffles me more  
than anything else on this planet. The day I get my head around it will  
be a happy day indeed. :0

The problem with using ‘sob’, ‘eob’ is because I have two inputs to the  
USRP UHD sink. One is constantly transmitting and has items coming in  
from time=0, but the other has no input items from time=0, they only  
arrive later on. As a result the sink seems to block waiting for items  
on _both_ inputs before it will transmit anything. I don’t want the USRP  
to have to wait for the second stream to be populated before it  
transmits anything…

I thought ‘forecast’ may help me out, but wasn’t sure what to put in the  
function to make it schedule even when there are no input items?

David

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 3, 2014, 4:26pm UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/4 "2014-06-03T16:26:42Z")

</div>

On 06/03/2014 03:59 PM, David Halls wrote:

> Hey Martin,
> 
> Good to hear from you as always. Gnuradio scheduling baffles me more  
> than anything else on this planet. The day I get my head around it will  
> be a happy day indeed. :0

Some things aren’t meant for us mere mortals 🙂

> The problem with using ‘sob’, ‘eob’ is because I have two inputs to the  
> USRP UHD sink. One is constantly transmitting and has items coming in  
> from time=0, but the other has no input items from time=0, they only  
> arrive later on. As a result the sink seems to block waiting for items  
> on _both_ inputs before it will transmit anything. I don’t want the USRP  
> to have to wait for the second stream to be populated before it  
> transmits anything…

Hm, this is an interesting use case I think we might want to address at  
some point. But this doesn’t help you right now.

> I thought ‘forecast’ may help me out, but wasn’t sure what to put in the  
> function to make it schedule even when there are no input items?

Haven’t tried this, but maybe you can just tell it that  
ninput\_items\_required = 0 for some values of noutput\_items.

Again, this might produce too many zeros. Maybe you need something more  
sophisticated.

Cheers,  
Martin

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 4, 2014, 2:44am UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/5 "2014-06-04T02:44:26Z")

</div>

On Tue, Jun 3, 2014 at 9:59 PM, David Halls  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The problem with using ‘sob’, ‘eob’ is because I have two inputs to the  
> USRP UHD sink. One is constantly transmitting and has items coming in from  
> time=0, but the other has no input items from time=0, they only arrive  
> later on. As a result the sink seems to block waiting for items on _both_  
> inputs before it will transmit anything. I don’t want the USRP to have to  
> wait for the second stream to be populated before it transmits anything…

David,

Just one consideration:  
Says, “in0” is the port getting constant input, whereas “in1” is getting  
the non-consistent input.  
Will this happen where “in1” is getting more input than “in0” ?  
When this happen do you want to fill “in0” instead with zeros?

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 3, 2014, 5:09pm UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/6 "2014-06-03T17:09:44Z")

</div>

On Tue, Jun 3, 2014 at 9:59 PM, David Halls  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The problem with using ‘sob’, ‘eob’ is because I have two inputs to the  
> USRP UHD sink. One is constantly transmitting and has items coming in from  
> time=0, but the other has no input items from time=0, they only arrive  
> later on. As a result the sink seems to block waiting for items on _both_  
> inputs before it will transmit anything. I don’t want the USRP to have to  
> wait for the second stream to be populated before it transmits anything…

Create a general block with two inputs and two outputs.  
The two outputs connect to the USRP UHD sink. The first input connects  
to  
the constantly transmitting source while the second input connects to  
the  
non-consistent source.

In your forecast function:

ninput\_items\_required[0] = noutput\_items;  
ninput\_items\_required[1] = 0;

Then in your general\_work function:

const gr\_complex _in0 = (const gr\_complex_) input\_items[0];  
const gr\_complex _in1 = (const gr\_complex_) input\_items[1];  
gr\_complex _out0 = (gr\_complex_) output\_items[0];  
gr\_complex _out1 = (gr\_complex_) output\_items[1];

for (int i=0; i \< noutput\_items; i++)  
out0[i] = in0[i];

for (int i=0; i \< ninput\_items[1]; i++)  
out1[i] = in1[i]

for (int i=ninput\_items[1]; i \< noutput\_items; i++)  
out1[i] = 0.0; // here you fill in the zeros, but won’t  
over-filled.

consume( 0, noutput\_items);  
consume( 1, ninput\_items[1]);

return noutput\_items;

Hope this helps !

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 9, 2014, 10:51am UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/7 "2014-06-09T10:51:35Z")

</div>

On Tue, Jun 3, 2014 at 11:08 PM, Activecat [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> return noutput\_items;

I’ve tested out above idea, it works.  
Its implementation source file is at

> <https://github.com/activecat/gr-test2/blob/master/lib/streamer1_impl.cc>

To test it out, just run the flowgraph of

> <https://github.com/activecat/gr-test2/blob/master/examples/flowgraph_09.grc>

> **[GitHub - activecat/gr-test2: GNU Radio: more examples](https://github.com/activecat/gr-test2)**
>
> GNU Radio: more examples

---

<div class="post-metadata">

**Author:** ![divotdave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bbe5ce/32.png) [@divotdave](https://www.ruby-forum.com/u/divotdave)\
**Post date:** [June 6, 2014, 4:48am UTC](https://www.ruby-forum.com/t/scheduling-a-block-even-with-no-input-items-re-flow-graph-blocking-when-doing-2x1-transmission/230175/8 "2014-06-06T04:48:19Z")

</div>

From: xianda [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: 05 June 2014 09:50  
To: David Halls  
Subject: Re:Re: [Discuss-gnuradio] Scheduling a block even with no input  
items RE: Flow graph blocking when doing 2x1 transmission

Hi David:  
Thank you in advance.  
I want to ask a question about “Payload TD Tx 1 is  
derived from input codewords that are generated in MATLAB and stored in  
a file, then loaded into the flow graph.” as you said.I want to ask how  
to gnerated a dat document which is in MATLAB.What command you use in  
MATLAB?  
Thanks very much.  
Best regards,  
xianda

Hi Xianda,  
Please find the zip file attached with files to read and write (to/from  
MATLAB) both complex, and byte types.  
Syntax is  
input = read\_complex\_binary(‘filename.dat’)  
input = read\_char\_binary(‘filename.dat’)  
write\_complex\_binary(data,‘filename.dat’)  
write\_char\_binary(data,‘filename.dat’)  
Regards,  
David

At 2014-06-04 08:53:31, “David Halls”  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:

Hi Activecat,

I have disconnected the rest of the flow graph because it is extremely  
complex.

In the system I have a Source, a Relay (1 rx USRP, 1 tx USRP), a  
Destination. S —\> R\_rx/R\_tx → D

The two transmitters that you see on that flow graph snippet I sent you  
are the the Source Tx and the Relay Tx.

Payload TD Tx 1 is derived from input codewords that are generated in  
MATLAB and stored in a file, then loaded into the flow graph. The  
payload is created in a similar fashion to Martin’s original OFDM\_tx.  
This is then transmitted from Source Tx.

Until this point, no packets are received by Relay Rx but once the  
source transmits, these packets are then received by Relay Rx, and then  
there is a decode-and-forward chain of blocks, and this then creates  
Payload TD Tx 2.

The full flow graph is attached, but may be missing many blocks for  
you…

David

* * *

From: Activecat [removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: 04 June 2014 13:45  
To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Cc: David Halls  
Subject: Re: [Discuss-gnuradio] Scheduling a block even with no input  
items RE: Flow graph blocking when doing 2x1 transmission

On Wed, Jun 4, 2014 at 7:10 PM, David Halls  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\<[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>\>  
wrote:  
Activecat,

In fact my horrible hack doesn’t work properly. Once items start  
arriving at Payload TD Tx 2, they still don’t arrive as ‘consistently’  
(for want of a better word), as those from the Noise Source block, and  
thus zeros are inserted when they are not required!

David

David,

Could you please explain in details, what is this Payload TD Tx 2?  
How does it generate data, is it getting data from a hardware or  
console, why it sometime idle but sometime transmitting?

This is a virtual source. Where is it associated virtual sink?

* * *

NOTE: The information in this email and any attachments may be  
confidential and/or legally privileged. This message may be read, copied  
and used only by the intended recipient. If you are not the intended  
recipient, please destroy this message, delete any copies held on your  
system and notify the sender immediately.

Toshiba Research Europe Limited, registered in England and Wales  
(2519556). Registered Office 208 Cambridge Science Park, Milton Road,  
Cambridge CB4 0GZ, England. Web:  
www.toshiba.eu/research/trl[http://www.toshiba.eu/research/trl](http://www.toshiba.eu/research/trl)

* * *

This email has been scanned for email related threats and delivered  
safely by Mimecast.  
For more information please visit [http://www.mimecast.com](http://www.mimecast.com)

* * *

* * *

NOTE: The information in this email and any attachments may be  
confidential and/or legally privileged. This message may be read, copied  
and used only by the intended recipient. If you are not the intended  
recipient, please destroy this message, delete any copies held on your  
system and notify the sender immediately.

Toshiba Research Europe Limited, registered in England and Wales  
(2519556). Registered Office 208 Cambridge Science Park, Milton Road,  
Cambridge CB4 0GZ, England. Web: www.toshiba.eu/research/trl
