def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] samples_file" parser = OptionParser(option_class=eng_option, usage=usage) (options, args) = parser.parse_args () if len(args)<1: # print "using gaussian noise as source" # self.sigsrc = gr.noise_source_c(gr.GR_GAUSSIAN,10e6) print "using repeating random vector as source" self.sigsrc = blocks.vector_source_c([10e6*(random.random() + 1j*random.random()) for i in range(0,100000)],True) self.src = blocks.throttle( gr.sizeof_gr_complex,2048000) self.connect(self.sigsrc, self.src) else: filename = args[0] print "using samples from file " + filename self.src = blocks.file_source(gr.sizeof_gr_complex, filename, False) dp = parameters.dab_parameters(1) rp = parameters.receiver_parameters(1) self.sync_dab = ofdm_sync_dab(dp, rp, False) self.nop0 = blocks.nop(gr.sizeof_gr_complex) self.nop1 = blocks.nop(gr.sizeof_char) self.connect(self.src, self.sync_dab, self.nop0) self.connect((self.sync_dab,1), self.nop1)
def test_007_connect_invalid_dst_port_neg(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect(nop1, (nop2, -1)))
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] samples_file" parser = OptionParser(option_class=eng_option, usage=usage) (options, args) = parser.parse_args() if len(args) < 1: # print "using gaussian noise as source" # self.sigsrc = gr.noise_source_c(gr.GR_GAUSSIAN,10e6) print "using repeating random vector as source" self.sigsrc = blocks.vector_source_c([ 10e6 * (random.random() + 1j * random.random()) for i in range(0, 100000) ], True) self.src = blocks.throttle(gr.sizeof_gr_complex, 2048000) self.connect(self.sigsrc, self.src) else: filename = args[0] print "using samples from file " + filename self.src = blocks.file_source(gr.sizeof_gr_complex, filename, False) dp = parameters.dab_parameters(1) rp = parameters.receiver_parameters(1) self.sync_dab = ofdm_sync_dab(dp, rp, False) self.nop0 = blocks.nop(gr.sizeof_gr_complex) self.nop1 = blocks.nop(gr.sizeof_char) self.connect(self.src, self.sync_dab, self.nop0) self.connect((self.sync_dab, 1), self.nop1)
def test_013_disconnect_input_not_connected(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect(hblock, nop2))
def test_007_connect_invalid_dst_port_neg(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) self.assertRaises(RuntimeError, lambda: hblock.connect(nop1, (nop2, -1)))
def test_017_disconnect_output_not_connected(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(TypeError, lambda: hblock.disconnect(nop2, hblock))
def test_005_connect_output_in_use(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(ValueError, lambda: hblock.connect(nop2, hblock))
def test_017_disconnect_output_not_connected(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(ValueError, lambda: hblock.disconnect(nop2, hblock))
def test_013_disconnect_input_not_connected(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(RuntimeError, lambda: hblock.disconnect(hblock, nop2))
def test_005_connect_output_in_use(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) nop2 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(RuntimeError, lambda: hblock.connect(nop2, hblock))
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] samples_file" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-m", "--dab-mode", type="int", default=1, help="DAB mode [default=%default]") parser.add_option("-F", "--filter-input", action="store_true", default=False, help="Enable FFT filter at input") parser.add_option("-s", "--resample-fixed", type="float", default=1, help="resample by a fixed factor (fractional interpolation)") parser.add_option("-S", "--autocorrect-sample-rate", action="store_true", default=False, help="Estimate sample rate offset and resample (dynamic fractional interpolation)") parser.add_option('-r', '--sample-rate', type="int", default=2048000, help="Use non-standard sample rate (default=%default)") parser.add_option('-e', '--equalize-magnitude', action="store_true", default=False, help="Enable individual carrier magnitude equalizer") parser.add_option('-d', '--debug', action="store_true", default=False, help="Write output to files") parser.add_option('-v', '--verbose', action="store_true", default=False, help="Print status messages") (options, args) = parser.parse_args () dp = parameters.dab_parameters(options.dab_mode, verbose=options.verbose, sample_rate=options.sample_rate) rp = parameters.receiver_parameters(options.dab_mode, input_fft_filter=options.filter_input, autocorrect_sample_rate=options.autocorrect_sample_rate, sample_rate_correction_factor=options.resample_fixed, equalize_magnitude=options.equalize_magnitude, verbose=options.verbose) if len(args)<1: if options.verbose: print "-> using repeating random vector as source" self.sigsrc = blocks.vector_source_c([10e6*(random.random() + 1j*random.random()) for i in range(0,100000)],True) self.ns_simulate = blocks.vector_source_c([0.01]*dp.ns_length+[1]*dp.symbols_per_frame*dp.symbol_length,1) self.mult = blocks.multiply_cc() # simulate null symbols ... self.src = blocks.throttle( gr.sizeof_gr_complex,2048000) self.connect(self.sigsrc, (self.mult, 0)) self.connect(self.ns_simulate, (self.mult, 1)) self.connect(self.mult, self.src) else: filename = args[0] if options.verbose: print "-> using samples from file " + filename self.src = blocks.file_source(gr.sizeof_gr_complex, filename, False) self.dab_demod = ofdm.ofdm_demod(dp, rp, debug=options.debug, verbose=options.verbose) self.connect(self.src, self.dab_demod) # sink output to nowhere self.nop0 = blocks.nop(gr.sizeof_char*dp.num_carriers/4) self.nop1 = blocks.nop(gr.sizeof_char) self.connect((self.dab_demod,0),self.nop0) self.connect((self.dab_demod,1),self.nop1)
def test_016_disconnect_output(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) hblock.disconnect(nop1, hblock)
def test_006_connect_invalid_src_port_neg(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect((hblock, -1), nop1))
def test_016_disconnect_output(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) hblock.disconnect(nop1, hblock)
def test_012_disconnect_input(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) hblock.disconnect(hblock, nop1)
def test_005_connect_invalid_src_port_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) self.assertRaises(RuntimeError, lambda: hblock.connect((hblock, 1), nop1))
def test_012_disconnect_input(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) hblock.disconnect(hblock, nop1)
def test_005_connect_invalid_src_port_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) self.assertRaises(ValueError, lambda: hblock.connect( (hblock, 1), nop1))
def test_015_disconnect_input_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect((hblock, 1), nop1))
def test_018_disconnect_output_neg(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(ValueError, lambda: hblock.disconnect(nop1, (hblock, -1)))
def test_019_disconnect_output_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(ValueError, lambda: hblock.disconnect(nop1, (hblock, 1)))
def test_018_disconnect_output_neg(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(TypeError, lambda: hblock.disconnect(nop1, (hblock, -1)))
def test_015_disconnect_input_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(hblock, nop1) self.assertRaises(TypeError, lambda: hblock.disconnect( (hblock, 1), nop1))
def test_019_disconnect_output_exceeds(self): hblock = gr.hier_block2("test_block", gr.io_signature(1,1,gr.sizeof_int), gr.io_signature(1,1,gr.sizeof_int)) nop1 = blocks.nop(gr.sizeof_int) hblock.connect(nop1, hblock) self.assertRaises(RuntimeError, lambda: hblock.disconnect(nop1, (hblock, 1)))
def test_002(self): data = list(range(1, 10)) self.src = blocks.vector_source_c(data, True) self.p = blocks.nop(gr.sizeof_gr_complex) self.p.set_ctrlport_test(0) probe_info = self.p.alias() self.tb.connect(self.src, self.p) # Get available endpoint ep = gr.rpcmanager_get().endpoints()[0] hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1) portnum = re.search(r"-p (\d+)", ep).group(1) # Initialize a simple ControlPort client from endpoint from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient radiosys = GNURadioControlPortClient(hostname, portnum, rpcmethod='thrift') radio = radiosys.client self.tb.start() # Make sure we have time for flowgraph to run time.sleep(0.1) # Get all exported knobs key_name_test = probe_info + "::test" ret = radio.getKnobs([ key_name_test, ]) ret[key_name_test].value = 10 radio.setKnobs({key_name_test: ret[key_name_test]}) ret = radio.getKnobs([]) result_test = ret[key_name_test].value self.assertEqual(result_test, 10) self.tb.stop() self.tb.wait()
def test_002(self): data = range(1, 10) self.src = blocks.vector_source_c(data, True) self.p = blocks.nop(gr.sizeof_gr_complex) self.p.set_ctrlport_test(0); probe_info = self.p.alias() self.tb.connect(self.src, self.p) # Get available endpoint ep = gr.rpcmanager_get().endpoints()[0] hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1) portnum = re.search("-p (\d+)", ep).group(1) argv = [None, hostname, portnum] # Initialize a simple ControlPort client from endpoint from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift') radio = radiosys.client self.tb.start() # Make sure we have time for flowgraph to run time.sleep(0.1) # Get all exported knobs key_name_test = probe_info+"::test" ret = radio.getKnobs([key_name_test,]) ret[key_name_test].value = 10 radio.setKnobs({key_name_test: ret[key_name_test]}) ret = radio.getKnobs([]) result_test = ret[key_name_test].value self.assertEqual(result_test, 10) self.tb.stop() self.tb.wait()
def test_002(self): data = range(1, 10) self.src = blocks.vector_source_c(data, True) self.p = blocks.nop(gr.sizeof_gr_complex) self.p.set_ctrlport_test(0) probe_info = self.p.alias() self.tb.connect(self.src, self.p) # Get available endpoint ep = gr.rpcmanager_get().endpoints()[0] # Initialize a simple Ice client from endpoint ic = Ice.initialize(sys.argv) base = ic.stringToProxy(ep) radio = GNURadio.ControlPortPrx.checkedCast(base) self.tb.start() # Make sure we have time for flowgraph to run time.sleep(0.1) # Get all exported knobs key_name_test = probe_info + "::test" ret = radio.get([ key_name_test, ]) ret[key_name_test].value = 10 radio.set({key_name_test: ret[key_name_test]}) ret = radio.get([]) result_test = ret[key_name_test].value self.assertEqual(result_test, 10) self.tb.stop() self.tb.wait()
def test_002(self): data = range(1, 10) self.src = blocks.vector_source_c(data, True) self.p = blocks.nop(gr.sizeof_gr_complex) self.p.set_ctrlport_test(0); probe_info = self.p.alias() self.tb.connect(self.src, self.p) # Get available endpoint ep = gr.rpcmanager_get().endpoints()[0] # Initialize a simple Ice client from endpoint ic = Ice.initialize(sys.argv) base = ic.stringToProxy(ep) radio = GNURadio.ControlPortPrx.checkedCast(base) self.tb.start() # Make sure we have time for flowgraph to run time.sleep(0.1) # Get all exported knobs key_name_test = probe_info+"::test" ret = radio.get([key_name_test,]) ret[key_name_test].value = 10 radio.set({key_name_test: ret[key_name_test]}) ret = radio.get([]) result_test = ret[key_name_test].value self.assertEqual(result_test, 10) self.tb.stop() self.tb.wait()
def __init__(self): gr.top_block.__init__(self) usage = "%prog: [options] samples_file" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-m", "--dab-mode", type="int", default=1, help="DAB mode [default=%default]") parser.add_option("-F", "--filter-input", action="store_true", default=False, help="Enable FFT filter at input") parser.add_option( "-s", "--resample-fixed", type="float", default=1, help="resample by a fixed factor (fractional interpolation)") parser.add_option( "-S", "--autocorrect-sample-rate", action="store_true", default=False, help= "Estimate sample rate offset and resample (dynamic fractional interpolation)" ) parser.add_option( '-r', '--sample-rate', type="int", default=2048000, help="Use non-standard sample rate (default=%default)") parser.add_option('-e', '--equalize-magnitude', action="store_true", default=False, help="Enable individual carrier magnitude equalizer") parser.add_option('-d', '--debug', action="store_true", default=False, help="Write output to files") parser.add_option('-v', '--verbose', action="store_true", default=False, help="Print status messages") (options, args) = parser.parse_args() dp = parameters.dab_parameters(options.dab_mode, verbose=options.verbose, sample_rate=options.sample_rate) rp = parameters.receiver_parameters( options.dab_mode, input_fft_filter=options.filter_input, autocorrect_sample_rate=options.autocorrect_sample_rate, sample_rate_correction_factor=options.resample_fixed, equalize_magnitude=options.equalize_magnitude, verbose=options.verbose) if len(args) < 1: if options.verbose: print "-> using repeating random vector as source" self.sigsrc = blocks.vector_source_c([ 10e6 * (random.random() + 1j * random.random()) for i in range(0, 100000) ], True) self.ns_simulate = blocks.vector_source_c( [0.01] * dp.ns_length + [1] * dp.symbols_per_frame * dp.symbol_length, 1) self.mult = blocks.multiply_cc() # simulate null symbols ... self.src = blocks.throttle(gr.sizeof_gr_complex, 2048000) self.connect(self.sigsrc, (self.mult, 0)) self.connect(self.ns_simulate, (self.mult, 1)) self.connect(self.mult, self.src) else: filename = args[0] if options.verbose: print "-> using samples from file " + filename self.src = blocks.file_source(gr.sizeof_gr_complex, filename, False) self.dab_demod = ofdm.ofdm_demod(dp, rp, debug=options.debug, verbose=options.verbose) self.connect(self.src, self.dab_demod) # sink output to nowhere self.nop0 = blocks.nop(gr.sizeof_char * dp.num_carriers / 4) self.nop1 = blocks.nop(gr.sizeof_char) self.connect((self.dab_demod, 0), self.nop0) self.connect((self.dab_demod, 1), self.nop1)