def __init__(self, options): gr.top_block.__init__(self) if options.freq is not None: u = usrp2.source(options) elif options.infile is not None: u = gr.file_source(gr.sizeof_gr_complex, options.infile) else: import sys sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.scope = None if options.outfile is not None: rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: rx = qam_rxtx.RX(options) framebytes = rx.framebytes if options.rxdata is not None: if options.rxdata == '-': self.connect( rx, gr.file_descriptor_sink(gr.sizeof_char * framebytes, 1)) else: self.connect( rx, gr.file_sink(gr.sizeof_char * framebytes, options.rxdata)) if options.berdata is not None: # select one of the ber modes ber = qam_rxtx.BER(framebytes, 100, mode=options.bermode) data = qam_rxtx.make_data(framebytes) self.connect(rx, (ber, 0)) self.connect(data, (ber, 1)) if options.berdata == '-': # print it out msgq = gr.msg_queue(16) self.connect(ber, gr.message_sink(gr.sizeof_float, msgq, True)) self.watcher = ofdm_rxtx.queue_watcher(msgq) elif options.berdata == '.': import scope # scope it out self.scope = scope.scope(self, ber, 'Frame BER') else: self.connect( ber, gr.file_sink(gr.sizeof_float, options.berdata)) else: pass #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this? self.connect(u, rx)
def __init__(self, options): gr.top_block.__init__(self) if options.freq is not None: u = usrp2.source(options) elif options.infile is not None: u = gr.file_source(gr.sizeof_gr_complex, options.infile) else: import sys sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.scope = None if options.outfile is not None: rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: rx = qam_rxtx.RX(options) framebytes = rx.framebytes if options.rxdata is not None: if options.rxdata == '-': self.connect(rx, gr.file_descriptor_sink(gr.sizeof_char * framebytes, 1)) else: self.connect(rx, gr.file_sink(gr.sizeof_char * framebytes, options.rxdata)) if options.berdata is not None: # select one of the ber modes ber = qam_rxtx.BER(framebytes, 100, mode=options.bermode) data = qam_rxtx.make_data(framebytes) self.connect(rx, (ber,0)) self.connect(data, (ber,1)) if options.berdata == '-': # print it out msgq = gr.msg_queue(16) self.connect(ber, gr.message_sink(gr.sizeof_float, msgq, True)) self.watcher = ofdm_rxtx.queue_watcher(msgq) elif options.berdata == '.': import scope # scope it out self.scope = scope.scope(self, ber, 'Frame BER') else: self.connect(ber, gr.file_sink(gr.sizeof_float, options.berdata)) else: pass #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this? self.connect(u, rx)
def __init__(self, options): gr.top_block.__init__(self) if options.rx_freq is not None: u = uhd_receiver(options.args, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose) elif options.infile is not None: u = gr.file_source(gr.sizeof_gr_complex, options.infile) else: import sys sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.scope = None if options.outfile is not None: rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: rx = ofdm_rxtx.RX(options) data_tones = rx.params.data_tones if options.rxdata is not None: if options.rxdata == '.': import scope # scope it out rxs = gr.vector_to_stream(gr.sizeof_gr_complex, data_tones) self.connect(rx, rxs) self.scope = scope.scope(self, rxs, 'Frame SNR', isComplex=True) else: if options.char > 0: # rail and scale self.connect( rx, gr.vector_to_stream(gr.sizeof_float, data_tones * 2), gr.multiply_const_ff(128.0 * (2**0.5) / options.char), gr.rail_ff(-128.0, 127.0), gr.float_to_char(), gr.file_sink(gr.sizeof_char, options.rxdata)) else: self.connect( rx, gr.file_sink(data_tones * gr.sizeof_gr_complex, options.rxdata)) if options.snrdata is not None: # select one of the snr modes snr = ofdm_rxtx.SNR(rx.params.data_tones, options.size, mode=options.snrmode) if options.char > 0: # NOTE: we use repeat, assuming the file is long enough or properly aligned data = gr.stream_to_vector(gr.sizeof_float, data_tones * 2) self.connect( gr.file_source(gr.sizeof_char, options.txdata, repeat=True), gr.char_to_float(), gr.multiply_const_ff(options.char * (2**-0.5) / 128.0), data) else: data = ofdm_rxtx.make_data(rx.params.data_tones, options.size, options.txdata) self.connect(rx, (snr, 0)) self.connect(data, (snr, 1)) if options.snrdata == '-': # print it out msgq = gr.msg_queue(16) self.connect(snr, gr.message_sink(gr.sizeof_float, msgq, True)) self.watcher = ofdm_rxtx.queue_watcher(msgq) elif options.snrdata == '.': import scope # scope it out self.scope = scope.scope(self, snr, 'Frame SNR') else: self.connect( snr, gr.file_sink(gr.sizeof_float, options.snrdata)) else: pass #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this? self.connect(u, rx)
def __init__(self, options): gr.top_block.__init__(self) if options.rx_freq is not None: u = uhd_receiver(options.args, options.bandwidth, options.rx_freq, options.rx_gain, options.spec, options.antenna, options.verbose) elif options.infile is not None: u = gr.file_source(gr.sizeof_gr_complex, options.infile) else: import sys sys.stderr.write("--freq or --infile must be specified\n") raise SystemExit self.scope = None if options.outfile is not None: rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile) else: rx = ofdm_rxtx.RX(options) data_tones = rx.params.data_tones if options.rxdata is not None: if options.rxdata == '.': import scope # scope it out rxs = gr.vector_to_stream(gr.sizeof_gr_complex, data_tones) self.connect(rx, rxs) self.scope = scope.scope(self, rxs, 'Frame SNR', isComplex=True) else: if options.char > 0: # rail and scale self.connect(rx, gr.vector_to_stream(gr.sizeof_float, data_tones * 2), gr.multiply_const_ff(128.0 * (2**0.5)/ options.char), gr.rail_ff(-128.0, 127.0), gr.float_to_char(), gr.file_sink(gr.sizeof_char, options.rxdata)) else: self.connect(rx, gr.file_sink(data_tones * gr.sizeof_gr_complex, options.rxdata)) if options.snrdata is not None: # select one of the snr modes snr = ofdm_rxtx.SNR(rx.params.data_tones, options.size, mode=options.snrmode) if options.char > 0: # NOTE: we use repeat, assuming the file is long enough or properly aligned data = gr.stream_to_vector(gr.sizeof_float, data_tones * 2) self.connect(gr.file_source(gr.sizeof_char, options.txdata, repeat=True), gr.char_to_float(), gr.multiply_const_ff(options.char * (2**-0.5) / 128.0), data) else: data = ofdm_rxtx.make_data(rx.params.data_tones, options.size, options.txdata) self.connect(rx, (snr,0)) self.connect(data, (snr,1)) if options.snrdata == '-': # print it out msgq = gr.msg_queue(16) self.connect(snr, gr.message_sink(gr.sizeof_float, msgq, True)) self.watcher = ofdm_rxtx.queue_watcher(msgq) elif options.snrdata == '.': import scope # scope it out self.scope = scope.scope(self, snr, 'Frame SNR') else: self.connect(snr, gr.file_sink(gr.sizeof_float, options.snrdata)) else: pass #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this? self.connect(u, rx)