Hello, dear GNU-Radio community,
Some last weeks I am coping with how to run and reconfigure gr.top_block on the fly, didn't manage, so I thought, maybe someone out there could give me some hint.

I am writing an application which is expected to send different test signal through USRP2 - to test some other embedded receivers. So I need to reconfigure top_block an different parameters on the fly. I can do the nonGUI case, its OK. I just use wait() to identify when vector with test data is empty, to generate a new one and restart the flowgraph. But I can't wrap around how to involve the wxPython GUI - after starting MainLoop() I've no control any more on the top_block.
What is needed:
1) during software run, change gr.vector_source data (get some notification, when its empty, then fill with new test-case-data, start again)
2) on each test-case, be able to adjust frequency, and gain of USRP2
3) give some graphical output of signal, for example, FFT.

Q1)Is there some callback, when vector is empty (I didn't find one) or flowgraph is stopped due finished-data-stream? Or at least parameter? (the gr_vector_source.detail().done() just rises an error)
Q2)Is there some callback from MainLoop() which "usually" is used?
Q3)does it in general make sense to reconfigure and readjust flowgraph "fluently" or it is recommended some sleep time inbetween. Like, maybe, the gain of USRP2 just impossible to switch from 0 to 35 within 1ms. Or notification done() can be issued between data samples are really sent out by USRP, thus changing frequency at that time would be wrong.

I also tried to start the grc_wxgui.top_block_gui in new thread and after run() tried to adjust parameters, without efforts. Also MainLoop() in different thread, no luck.

Here down some very basic sample - if somebody can give hint to attach Scope to it, I would appreciate it a lot.

Best regards from Bremen,
diehortusxana

==================
#!/usr/bin/env python

from gnuradio import audio
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from optparse import OptionParser
import time
import math

class my_basic_tb(gr.top_block):
  def __init__(self):
    gr.top_block.__init__(self)
    self.samp_rate = samp_rate = 32000
    self.audio_sink_0 = audio.sink(48000, "", True)
self.gr_vector_source_x_0 = gr.vector_source_f(gen_freq(41,1), False, 1)
    self.connect((self.gr_vector_source_x_0, 0), (self.audio_sink_0, 0))

def gen_freq(freq,len_s):
    nv = []
    for i in range(1,48000*len_s):
      if math.fmod(i,freq) == 0:
        nv.append(1)
      else:
        nv.append(0)
    return nv


if __name__ == '__main__':
  parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
  (options, args) = parser.parse_args()

  tb = my_basic_tb()
  tb.start()
  tb.wait()
  print("done_part_1")
  tb.lock()
  tb.disconnect(tb.gr_vector_source_x_0)
  tb.gr_vector_source_x_0 = gr.vector_source_f(gen_freq(11,1), False, 1)
  tb.connect((tb.gr_vector_source_x_0, 0), (tb.audio_sink_0, 0))
  tb.unlock()
  tb.start()
  print("reconfigured")
  tb.wait()

  print("Done")
===================

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to