# How to stop "usrp\_spectrum\_sense.py"?

**URL:** <https://www.ruby-forum.com/t/how-to-stop-usrp-spectrum-sense-py/240140>\
**Category:** GNU Radio\
**Created:** [March 30, 2014, 10:25am UTC](https://www.ruby-forum.com/t/how-to-stop-usrp-spectrum-sense-py/240140 "2014-03-30T10:25:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [March 30, 2014, 10:25am UTC](https://www.ruby-forum.com/t/how-to-stop-usrp-spectrum-sense-py/240140/1 "2014-03-30T10:25:01Z")

</div>

Hi Everyone,

The “usrp\_spectrum\_sense.py” program is used to sense the defined  
spectrum  
range. Now, I want to stop it for a period of five second time (e.g.  
from  
55 to 59 seconds). For that purpose, I wrote the following lines in  
python.

================================================  
import usrp\_spectrum\_sense\_updated

import time

class main\_class():

# calling the ‘usrp\_spectrum\_sense.py’ program

```
def relay_func(self, tb):

```

while 1:

```
curr_time = time.strftime('%S',time.localtime())

if int(curr_time)>=55:

```

print 'Hello World"

```
else:

```

t = usrp\_spectrum\_sense\_updated.ThreadClass()

```
        t.start()

        tb = usrp_spectrum_sense_updated.my_top_block()

        try:

        tb.start()

        usrp_spectrum_sense_updated.main_loop(tb)

        except KeyboardInterrupt:

        pass

```

if **name** == ‘ **main** ’:

```
tb = main_class()

tb.relay_func(tb)

```

================================================

In the above program, I tried to stop sensing for the duration of 5  
seconds  
(i.e. 55 ---- 59 seconds). The program works fine whenever I execute it  
in  
between of the mentioned time and it shift automatically to the sensing  
mode at time=0 second; but once it start sensing then it never be  
returned  
to the print message ‘hello world’ even when the condition is matched.

Earliest and kind response is highly appreciated. Thanks.

Regards,  
Syed Aqeel R.

---

<div class="post-metadata">

**Author:** ![syed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@syed](https://www.ruby-forum.com/u/syed)\
**Post date:** [April 5, 2014, 2:34am UTC](https://www.ruby-forum.com/t/how-to-stop-usrp-spectrum-sense-py/240140/2 "2014-04-05T02:34:19Z")

</div>

On 04/04/2014 04:33 AM, Syed Aqeel R. wrote:

> For example, in a minute 50 seconds are reserved for relaying mode while  
> the remaining 10 seconds for sensing mode.
> 
> These are the two most important tasks out of many others. Right now, I  
> am able to switch from relay mode to sensing mode but once the program  
> start with the sensing mode then it won’t be returned to relay mode.

You might want to write a block that outputs data on two different  
paths, instead of reconnecting blocks or using message queues.

> Yes, the delete\_head() call block is remain a mystery for me yet. I am  
> trying to resolve the issue but if anyone has any suggestions then let  
> me know. Waiting for positive response.

I recommend not to use it at all (see comment above).

Also, you might get more results for these GNU Radio-specific questions  
on the GNU Radio mailing list.

Cheers,  
Martin

---

<div class="post-metadata">

**Author:** ![syed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a88e57/32.png) [@syed](https://www.ruby-forum.com/u/syed)\
**Post date:** [April 9, 2014, 2:02am UTC](https://www.ruby-forum.com/t/how-to-stop-usrp-spectrum-sense-py/240140/3 "2014-04-09T02:02:13Z")

</div>

On 04/07/2014 04:51 AM, Syed Aqeel R. wrote:

> “RuntimeError: boost::thread\_resource\_error: Resource temporarily  
> unavailable”
> 
> For detailed information about this error message, see the attached  
> file. Waiting for your reply, thanks.

Syed,

at this point, it’s impossible to help you any further without seeing  
the code. Also, you would probably get more responses on the GNU Radio  
mailing list, which I’ve added.

Another note: It’s usually better to post the error message (if short,  
in an email, if long, on a pasting service such as pastebin) than to  
post a screenshot.

Martin
