discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Benchmark_tx GUI Freezing up


From: Yu-Hua Yang
Subject: [Discuss-gnuradio] Benchmark_tx GUI Freezing up
Date: Mon, 8 Jun 2009 17:56:57 +0800

Hello

I am trying to write a GUI to do the transmissions made with the benchmark_tx.py example. For some reason, after sending the 3rd packet, my GUI would freeze and require force quit. I took code segments from GUI examples and benchmark_tx.py and I am not understanding why the GUI is freezing (and what causes it)

After importing the necessary libraries, I have a

#gui class
class benchmark_gui (stdgui2.std_top_block):
       
    def __init__(self,frame,panel,vbox,argv):
        stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv)

        #define some paramters
        self.panel= panel
        self.frame = frame
       
        #build the gui
        self._build_gui(vbox)

#define the gui function
    def _build_gui(self, vbox):     

        self.myform = myform = form.form()
       
   #function to begin the transmission (mostly from benchmark_tx)
   def _form_set(kv):
            freq = kv['freq']
            mb = kv['mb']
            pktsize = kv['pktsize']
               
            mods = modulation_utils.type_1_mods()

                parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
                expert_grp = parser.add_option_group("Expert")

                parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(),
                      default='gmsk',
                      help="Select modulation from: %s [default=%%default]"
                            % (', '.join(mods.keys()),))
                parser.add_option("","--discontinuous", action="" default=False,
                      help="enable discontinous transmission (bursts of 5 packets)")
                parser.add_option("","--from-file", default=None,
                      help="use file for packet contents")
           
                transmit_path.add_options(parser, expert_grp)

                for mod in mods.values():
                    mod.add_options(expert_grp)

                (options, args) = parser.parse_args ()
           
            #use the ones from form
            options.tx_freq = freq
            options.megabytes = mb
            options.size = pktsize
           
            # build the graph
                tb = my_top_block(mods[options.modulation], options)

               r = gr.enable_realtime_scheduling()
                if r != gr.RT_OK:
                print "Warning: failed to enable realtime scheduling"

                tb.start()                       # start flow graph
           
            #send packets
            def send_pkt(payload='', eof=False):
                    return tb.txpath.send_pkt(payload, eof)
       
            #generate and send packets
            nbytes = int(1e6 * options.megabytes)
                n = 0
                pktno = 0
                pkt_size = int(options.size)

                while n < nbytes:
                if options.from_file is None:
                       data = "" - 2) * chr(pktno & 0xff)
                else:
                        data = "" - 2)
                    if data == '':
                        break;

                payload = struct.pack('!H', pktno & 0xffff) + data
                send_pkt(payload)
                n += len(payload)
                self._set_status_msg("Sending %d packet of %d packets"% (pktno,n), 0)
                if options.discontinuous and pktno % 5 == 4:
                        time.sleep(1)
                pktno += 1
       
                    send_pkt(eof=True)

                    tb.wait()                       # wait for it to finish
           
            self._set_status_msg("Done",0)

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add((5,0), 0)
        myform['freq'] = form.float_field(
            parent=self.panel, sizer=hbox, label="Freq", weight=1,
            callback=myform.check_input_and_call(_form_set))
        vbox.Add(hbox, 0, wx.EXPAND)
        #number of packets   
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2.Add((5,0), 0)
        myform['mb'] = form.float_field(
            parent=self.panel, sizer=hbox, label="MB to transmit", weight=1,
            callback=myform.check_input_and_call(_form_set))
        vbox.Add(hbox2, 0, wx.EXPAND)       
        #packet size
        hbox3 = wx.BoxSizer(wx.HORIZONTAL)
        hbox3.Add((5,0), 0)
        myform['pktsize'] = form.float_field(
            parent=self.panel, sizer=hbox, label="Packet Size", weight=1,
            callback=myform.check_input_and_call(_form_set))
        vbox.Add(hbox3, 0, wx.EXPAND)       
       
        st1 = wx.StaticText(self.panel, -1, "Input settings and hit enter", style=wx.ALIGN_CENTRE)
        vbox.Add(st1, 1, wx.EXPAND |  wx.TOP | wx.BOTTOM, 15)
       
    #status reporting function
    def _set_status_msg(self, msg, which=0):
        self.frame.GetStatusBar().SetStatusText(msg, which)

and I simply copied the class from benchmark_tx.py like so:

#class for transmission
class my_top_block(gr.top_block):
    def __init__(self, modulator, options):
        gr.top_block.__init__(self)
        self.txpath = transmit_path(modulator, options)
        self.connect(self.txpath)

Basically, the code flows (from what I am understanding) as: the benchmark_gui is called, and then the user then input the settings, and upon hitting Enter, the code goes into _form_set function which takes the settings and then prepare the USRP to transmit at those settings, creates a my_top_block object, and then generate and send packets. I thought that by copying the settings i didnt touch from benchmark_tx, I should be able to run my GUI. But after the 3rd packet, the GUI freezes.

Please help.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]