# Question about stream tag

**URL:** <https://www.ruby-forum.com/t/question-about-stream-tag/220006>\
**Category:** GNU Radio\
**Created:** [May 24, 2012, 4:28pm UTC](https://www.ruby-forum.com/t/question-about-stream-tag/220006 "2012-05-24T16:28:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 24, 2012, 4:28pm UTC](https://www.ruby-forum.com/t/question-about-stream-tag/220006/1 "2012-05-24T16:28:45Z")

</div>

Hello,  
I want to use my USRP2 to implement a TDMA system, and I want to  
send 5 seconds, receive 5 seconds, and do the recycle. I used the stream  
tag demo in gr-uhd/taguhd. The question is:

1. As sean have said in  
[Re: [Discuss-gnuradio] How to implement a TDMA system](http://lists.gnu.org/archive/html/discuss-gnuradio/2012-04/msg00506.html)  
we should use “tx\_time”, “tx\_sob” (start-of-burst), and “tx\_eob”  
(end-of-burst) to tag the data flow, but yend B in  
[How to align Tx/Rx timestamps - GNU Radio - Ruby-Forum](http://www.ruby-forum.com/topic/3832986) said the data not enclosed by  
sob-eob tag pair was dropped. Is this problem really exist? And any  
solution?
2. Is there any way to switch the Tx/Rx? And how to tell the USRP to  
receive for a desired time slot such as 5 seconds then stop? The only  
parameter I can see in gr\_uhd\_usrp\_source is ‘rx\_time’(tells when to  
start receive), I do not know how to stop the streaming after 5 seconds.  
Thank you for your help. Any suggestion is appreciated.

---

<div class="post-metadata">

**Author:** ![PanS\_Luyuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@PanS\_Luyuan](https://www.ruby-forum.com/u/PanS_Luyuan)\
**Post date:** [May 24, 2012, 4:36pm UTC](https://www.ruby-forum.com/t/question-about-stream-tag/220006/2 "2012-05-24T16:36:11Z")

</div>

On Thu, May 24, 2012 at 10:27 AM, Pan, Luyuan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## solution? 2. Is there any way to switch the Tx/Rx? And how to tell the USRP to receive for a desired time slot such as 5 seconds then stop? The only parameter I can see in gr\_uhd\_usrp\_source is ‘rx\_time’(tells when to start receive), I do not know how to stop the streaming after 5 seconds. Thank you for your help. Any suggestion is appreciated.
> 
> Best regards,  
> Pan, Luyuan

It sounds like you need to add a rate control to your MAC layer.  
Obviously, when you aren’t transmitting, you don’t want to be  
generating any samples. You’ll need to buffer them. This is going to  
take some work outside of GNU Radio to create an app that has a thread  
to control the samples and pass them to a message source block in GNU  
Radio.

I’m not sure there’s a good example of this, and we don’t really have  
a ‘best practices’ for this right now.

Tom

---

<div class="post-metadata">

**Author:** ![PanS\_Luyuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@PanS\_Luyuan](https://www.ruby-forum.com/u/PanS_Luyuan)\
**Post date:** [May 24, 2012, 5:04pm UTC](https://www.ruby-forum.com/t/question-about-stream-tag/220006/3 "2012-05-24T17:04:47Z")

</div>

On 2012/5/24 22:34, Tom R. wrote:

> > sob-eob tag pair was dropped. Is this problem really exist? And any  
> > Obviously, when you aren’t transmitting, you don’t want to be  
> > generating any samples. You’ll need to buffer them. This is going to  
> > take some work outside of GNU Radio to create an app that has a thread  
> > to control the samples and pass them to a message source block in GNU  
> > Radio.
> 
> I’m not sure there’s a good example of this, and we don’t really have  
> a ‘best practices’ for this right now.
> 
> Tom  
> In Tx side, This may be the ‘best’ solution at present. But in Rx side,  
> I just want the USRP to sample for 5 seconds, then stop. Is there any  
> way to reach this goal? Should I use the “stream\_cmd” in uhd to set the  
> receive mode in USRP or any better alternative? Can the modes (“Start  
> continuous”, “Stop continuous”,“Num samps and done”…) achieve my goal?  
> Any suggestion is appreciated. Thank you.  
> –  
> Best regards,  
> Pan, Luyuan

---

<div class="post-metadata">

**Author:** ![PanS\_Luyuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@PanS\_Luyuan](https://www.ruby-forum.com/u/PanS_Luyuan)\
**Post date:** [May 24, 2012, 6:56pm UTC](https://www.ruby-forum.com/t/question-about-stream-tag/220006/4 "2012-05-24T18:56:47Z")

</div>

If you know your sample rate, you can calculate how many samples will  
occur over 5 seconds and pass that as “num samps and done” to a stream  
command. (I’ve never used stream command interface myself, but I think  
this will work).

---

<div class="post-metadata">

**Author:** ![PanS\_Luyuan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/46a35a/32.png) [@PanS\_Luyuan](https://www.ruby-forum.com/u/PanS_Luyuan)\
**Post date:** [May 24, 2012, 8:36pm UTC](https://www.ruby-forum.com/t/question-about-stream-tag/220006/5 "2012-05-24T20:36:36Z")

</div>

> In Tx side, This may be the ‘best’ solution at present. But in Rx side,  
> I just want the USRP to sample for 5 seconds, then stop. Is there any  
> way to reach this goal? Should I use the “stream\_cmd” in uhd to set the  
> receive mode in USRP or any better alternative? Can the modes (“Start  
> continuous”, “Stop continuous”,“Num samps and done”…) achieve my goal?  
> Any suggestion is appreciated. Thank you.

So, you have access to start(), stop() and set\_start\_time() on the  
source object; The issue is that you cant really stop the block while  
the flow graph is running or the source block will timeout, return 0,  
and quit. So, here is a potential fix to make the work function block  
when the streaming is stopped:

[http://gnuradio.org/cgit/jblum.git/commit/?h=wip\_uhd\_stopper&id=c78d307ecd5dac4e28190e5aa9b8377538f65ffa](http://gnuradio.org/cgit/jblum.git/commit/?h=wip_uhd_stopper&id=c78d307ecd5dac4e28190e5aa9b8377538f65ffa)

heres my git repo:  
git://gnuradio.org/jblum.git

-josh
