|
From: | Carlo Donato Lecce |
Subject: | [Discuss-gnuradio] lock and unlock with transmi th_path and receive_path |
Date: | Sun, 24 Jan 2010 14:21:12 +0100 |
Hello all, I seem that using transmit_path and receive_path the reconfigure of flow graph is bad. The following code hung after the call of unlock. I think that there are a bugs in the transmit_path because using a gr.null_source insted of transmit_path the program not hangs. Thanks, Carlo. from gnuradio import gr, gru, modulation_utils from gnuradio import eng_notation from gnuradio.eng_option import eng_option from optparse import OptionParser import random, time, struct, sys, math # from current dir from transmit_path import transmit_path from receive_path import receive_path class h_block(gr.hier_block2): def __init__(self): gr.hier_block2.__init__(self, "hello", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) class top_block(gr.top_block): def __init__(self, mod_class, demod_class, rx_callback, options): gr.top_block.__init__(self) self.txpath = transmit_path(mod_class, options) self.rxpath = receive_path(demod_class, rx_callback, options) self.source = gr.null_source(gr.sizeof_gr_complex) self.sink = gr.null_sink(gr.sizeof_gr_complex) self.connect(self.txpath, self.sink) # self.connect(self.source2, self.sink2) def reconfigure(self): self.lock() self.disconnect(self.txpath, self.sink) self.sink2 = gr.null_sink(gr.sizeof_gr_complex) self.connect(self.txpath, self.sink2) self.unlock() def main(): global n_rcvd, n_right n_rcvd = 0 n_right = 0 def rx_callback(ok, payload): global n_rcvd, n_right (pktno,) = struct.unpack('!H', payload[0:2]) n_rcvd += 1 if ok: n_right += 1 print "1 ok = %5s pktno = %4d n_rcvd = %4d n_right = %4d" % ( ok, pktno, n_rcvd, n_right) # print payload[2:len(payload)] def send_pkt(payload='', eof=False): return tb.txpath.send_pkt(payload, eof) mods = modulation_utils.type_1_mods() demods = modulation_utils.type_1_demods() parser = OptionParser(option_class=eng_option, conflict_handler ="resolve") expert_grp = parser.add_option_group("Expert") channel_grp = parser.add_option_group("Channel") parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(), default='dbpsk', help="Select modulation from: %s [default=%%default]" % (', '.join(mods.keys()),)) parser.add_option("-s", "--size", type="eng_float", default=1500, help="set packet size [default=%default]") parser.add_option("-M", "--megabytes", type="eng_float", default=1.0, help="set megabytes to transmit [default=%default]") parser.add_option("","--discontinuous", action="", default=False, help="enable discontinous transmission (bursts of 5 packets)") channel_grp.add_option("", "--sample-rate", type="eng_float", default=1e5, help="set speed of channel/simulation rate to RATE [default=%default]") channel_grp.add_option("", "--snr", type="eng_float", default=30, help="set the SNR of the channel in dB [default=%default]") channel_grp.add_option("", "--frequency-offset", type="eng_float", default=0, help="set frequency offset introduced by channel [default=%default]") channel_grp.add_option("", "--seed", action="", default=False, help="use a random seed for AWGN noise [default=%default]") transmit_path.add_options(parser, expert_grp) receive_path.add_options(parser, expert_grp) for mod in mods.values(): mod.add_options(expert_grp) for demod in demods.values(): demod.add_options(expert_grp) (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() sys.exit(1) app = top_block(mods[options.modulation], demods[options.modulation], rx_callback, options) app.start() print "Reconfiguring h_block" app.reconfigure() print "Post reconfigure" app.wait() if __name__ == '__main__': try: main() except KeyboardInterrupt: pass Tanti account di posta? Riuniscili e leggi tutte le e-mail da Hotmail |
[Prev in Thread] | Current Thread | [Next in Thread] |