Gr_top_block adding new block while running


#1

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
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.


#2

Engin K. wrote:

    self.utfil = gr.file_sink(gr.sizeof_float,"capture.cfile")

33, in
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.