Forum: GNU Radio gr_top_block adding new block while running

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Engin K. (Guest)
on 2009-03-12 11:42
(Received via mailing list)
hi all,

I want to record for example a fir filter output
to file when I want. I have develop basic application,
given some parts below

.....
.....
def start_record_samples (self):
        self.stop()
        self.utfil = gr.file_sink(gr.sizeof_float,"capture.cfile")
        self.connect(self.chan_filt,self.utfil)
        self.start()

def stop_record_samples (self):
        self.stop()
        self.disconnect(self.chan_filt,self.utfil)
        self.start()

.....
.....

these functions are controlled with two buttons. "start" button calls
start_record_samples and "stop" button calls stop_record_samples.

but they don't work properly.

start_record_samples gives error given below,

Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/gnuradio/wxgui/form.py",
line
33, in <lambda>
    wx.EVT_BUTTON(parent, new_id, lambda evt: callback())
  File "usrp_snby_rcv.py", line 219, in record_samples
    self.start_record_samples()
  File "usrp_snby_rcv.py", line 227, in start_record_samples
    self.start()
  File
"/usr/local/lib/python2.5/site-packages/gnuradio/gr/top_block.py",
line 72, in start
    self._tb.start()
  File "/usr/local/lib/python2.5/site-
packages/gnuradio/gr/gnuradio_swig_py_runtime.py", line 1411, in start
    return _gnuradio_swig_py_runtime.gr_top_block_sptr_start(*args,
**kwargs)
RuntimeError: top_block::start: top block already running or wait() not
called after previous stop()

how can  I add new block temporarily to a running gr_top_block
scheduler?
because after stop it can't start anymore.

regards.
Engin K. (Guest)
on 2009-03-17 18:47
(Received via mailing list)
Engin K. wrote:

>         self.utfil = gr.file_sink(gr.sizeof_float,"capture.cfile")
>
> 33, in <lambda>
>     return _gnuradio_swig_py_runtime.gr_top_block_sptr_start(*args,
> **kwargs)
> RuntimeError: top_block::start: top block already running or wait() not
> called after previous stop()
>
> how can  I add new block temporarily to a running gr_top_block scheduler?
> because after stop it can't start anymore.
>
> regards.

I have found the solution from gr wiki. I just add self.wait() before
self.start and everything is fine now.
This topic is locked and can not be replied to.