# Flush samples of blocks when changing centrer frequency

**URL:** <https://www.ruby-forum.com/t/flush-samples-of-blocks-when-changing-centrer-frequency/234095>\
**Category:** GNU Radio\
**Created:** [February 5, 2015, 11:31am UTC](https://www.ruby-forum.com/t/flush-samples-of-blocks-when-changing-centrer-frequency/234095 "2015-02-05T11:31:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [February 5, 2015, 11:31am UTC](https://www.ruby-forum.com/t/flush-samples-of-blocks-when-changing-centrer-frequency/234095/1 "2015-02-05T11:31:10Z")

</div>

Hi,

I have a python flowgraph with several blocks.

One of them is a “filter.single\_pole\_iir\_filter\_ff” which does a moving  
average. The last block is a Sink to file block.

I scan several bands, 10MHz each, in order to get the power of the  
signals  
in those bands. I use moving average to get an average of 5 readings in  
each band.

In order to change the center frequency, I stop the flow-grahp,  
reconfigure  
the USRP center freq and then start the flow-graph again.

I guess samples from the previous scans remain in internal block buffers  
since I get power in samples of BAND2 (BAND1+10MHz) which are only  
present  
in BAND1. That is, the moving average is effective between bands and I  
only  
want to be effective in the same band.

I thought that stop() and start() signals would reset the entire graph  
but  
I am afraid it doesn’t.

Is there a way to flush those samples so that everytime I run the  
frequency  
changed flow-graph I don’t get the samples from the previous band?

Many thanks in advance.  
Jorge

---

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [February 5, 2015, 11:59am UTC](https://www.ruby-forum.com/t/flush-samples-of-blocks-when-changing-centrer-frequency/234095/2 "2015-02-05T11:59:20Z")

</div>

On Thu, Feb 5, 2015 at 11:30 AM, Jorge G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In order to change the center frequency, I stop the flow-grahp,  
> reconfigure the USRP center freq and then start the flow-graph again.

You can use the message port[1] in uhd source/sink or stream tags [2] to  
change the center frequency

> frequency changed flow-graph I don’t get the samples from the previous band?

UHD source will give rx\_time, rx\_rate and rx\_freq tags whenever there is  
a  
tune request to a new frequency. You can use these tags to get rid of  
unwanted samples.

> Many thanks in advance.  
> Jorge

[1] [GNU Radio Manual and C++ API Reference: UHD Interface](http://gnuradio.org/doc/doxygen/page_uhd.html)  
[2]  
[gnuradio/gr-uhd/examples/python/freq\_hopping.py at master · gnuradio/gnuradio · GitHub](https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/freq_hopping.py)

---

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [February 5, 2015, 12:14pm UTC](https://www.ruby-forum.com/t/flush-samples-of-blocks-when-changing-centrer-frequency/234095/3 "2015-02-05T12:14:34Z")

</div>

Hi

I am not familiar with those solutions. Could you please give a little  
more  
detail?

How can I use msg ports/ stream tags? Are they available in python  
flow-graph or do I have to look into C++ block programming?

Where can I see rx\_time, rx\_rate and rx\_freq tags ?

Regards,  
Jorge
