def test_raw_signal(self): analog_out = self.ctx.getAnalogOut() nb_samples = 16 tb = self.tb expected_result1 = [1.0] * nb_samples expected_result2 = [3.0] * nb_samples dst1 = m2k.analog_out_sink('ip:192.168.2.1', 1024, [750000, 750000], [1, 1], [4, 4], [0, 0], False, False) src1 = analog.sig_source_s(750000, analog.GR_CONST_WAVE, 1000, analog_out.convertVoltsToRaw(0, 1), 0, 0) src2 = analog.sig_source_s(750000, analog.GR_CONST_WAVE, 1000, analog_out.convertVoltsToRaw(1, 3), 0, 0) tb.connect((src1, 0), (dst1, 0)) tb.connect((src2, 0), (dst1, 1)) tb.start() samples = self.analog_in.getSamples(nb_samples) map(lambda x, y: self.assertAlmostEqual(x, y, 0.1), expected_result1, samples[0]) map(lambda x, y: self.assertAlmostEqual(x, y, 0.1), expected_result2, samples[1])
def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "video_sdl_test") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 7680000 ################################################## # Blocks ################################################## self.video_sdl_sink_0 = video_sdl.sink_s(0, 640, 480, 0, 640, 480) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_short * 1, samp_rate, True) self.blocks_add_xx_0 = blocks.add_vss(1) self.analog_sig_source_x_2 = analog.sig_source_s( samp_rate, analog.GR_TRI_WAVE, 1234.5, 255, 0, 0) self.analog_sig_source_x_1 = analog.sig_source_s( samp_rate, analog.GR_COS_WAVE, 10000, 255, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_throttle_1, 0), (self.video_sdl_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.trigger = trigger = -1 self.samp_rate = samp_rate = 20000000 ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=1.4e9, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=8192, fft_rate=25, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(288e6, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(24, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(4000000, 0) self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_gr_complex*1, samp_rate) self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_gr_complex) self.blocks_burst_tagger_0.set_true_tag("burst",True) self.blocks_burst_tagger_0.set_false_tag("burst",False) self.analog_const_source_x_0 = analog.sig_source_s(0, analog.GR_CONST_WAVE, 0, 0, trigger) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_burst_tagger_0, 1)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_tagged_file_sink_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_burst_tagger_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
def run_sig_source_s(self): fs = 1 ntype = analog.GR_SIN_WAVE freq = 10 ampl = 1 self.tb = gr.top_block() self.op = analog.sig_source_s(fs, ntype, freq, ampl) self.head = blocks.head(gr.sizeof_short, self.N) self.snk = blocks.null_sink(gr.sizeof_short) self.tb.connect(self.op, self.head, self.snk) self.tb.run()
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.limesdr_source_0 = limesdr.source( '0009070105C62E09', 2, '/home/aaron/Documents/satcom/limeSuite/testFiles/lms7suite_wfm/loraRadioDualChannel' ) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/aaron/Documents/satcom/ieeeTracker/packetTracker/testData/rawIQData2', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/home/aaron/Documents/satcom/ieeeTracker/packetTracker/testData/rawIQData', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_burst_tagger_0_0 = blocks.burst_tagger( gr.sizeof_gr_complex) self.blocks_burst_tagger_0_0.set_true_tag('burst', True) self.blocks_burst_tagger_0_0.set_false_tag('burst', False) self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_gr_complex) self.blocks_burst_tagger_0.set_true_tag('burst', True) self.blocks_burst_tagger_0.set_false_tag('burst', False) self.analog_const_source_x_0 = analog.sig_source_s( 0, analog.GR_CONST_WAVE, 0, 0, -1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_burst_tagger_0, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_burst_tagger_0_0, 1)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_burst_tagger_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.limesdr_source_0, 1), (self.blocks_burst_tagger_0, 0)) self.connect((self.limesdr_source_0, 0), (self.blocks_burst_tagger_0_0, 0))
def make_file(self, filename, type, amplitude): filename = os.path.join(self.test_dir, filename) tb = gr.top_block() if type == "rf32": head = blocks.head(gr.sizeof_float * 1, self.samp_rate) source = analog.sig_source_f(self.samp_rate, analog.GR_COS_WAVE, 1000, amplitude, 0) tb.connect(source, head) elif type == "ri32": head = blocks.head(gr.sizeof_int * 1, self.samp_rate) source = analog.sig_source_i(self.samp_rate, analog.GR_COS_WAVE, 1000, amplitude, 0) tb.connect(source, head) elif type == "ri16": head = blocks.head(gr.sizeof_short * 1, self.samp_rate) source = analog.sig_source_s(self.samp_rate, analog.GR_COS_WAVE, 1000, amplitude, 0) tb.connect(source, head) elif type == "ri8": head = blocks.head(gr.sizeof_char * 1, self.samp_rate) source = analog.sig_source_f(self.samp_rate, analog.GR_COS_WAVE, 1000, amplitude, 0) convert = blocks.float_to_char(1, 1) tb.connect(source, convert) tb.connect(convert, head) else: head = blocks.head(gr.sizeof_gr_complex * 1, self.samp_rate) source = analog.sig_source_c(self.samp_rate, analog.GR_COS_WAVE, 1000, amplitude, 0) tb.connect(source, head) sigmf_sink = sigmf.sink(type, filename) tb.connect(head, sigmf_sink) tb.run() tb.wait() return filename
def __init__(self, frame, panel, vbox, argv): MAX_CHANNELS = 7 stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) parser = OptionParser (option_class=eng_option) parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-e","--enable-fft", action="store_true", default=False, help="enable spectrum plot (and use more CPU)") parser.add_option("-f", "--freq", type="eng_float", default=None, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("-i","--file-input", action="store_true", default=False, help="input from baseband-0.dat, baseband-1.dat ...") parser.add_option("-g", "--audio-gain", type="eng_float", default=1.0, help="input audio gain multiplier") parser.add_option("-n", "--nchannels", type="int", default=1, help="number of Tx channels [1,4]") parser.add_option("-a", "--udp-addr", type="string", default="127.0.0.1", help="UDP host IP address") parser.add_option("--args", type="string", default="", help="device args") parser.add_option("--gains", type="string", default="", help="gains") parser.add_option("-p", "--udp-port", type="int", default=0, help="UDP port number") parser.add_option("-r","--repeat", action="store_true", default=False, help="continuously replay input file") parser.add_option("-S", "--stretch", type="int", default=0, help="elastic buffer trigger value") parser.add_option("-v","--verbose", action="store_true", default=False, help="print out stats") parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() sys.exit(1) if options.nchannels < 1 or options.nchannels > MAX_CHANNELS: sys.stderr.write ("op25_tx: nchannels out of range. Must be in [1,%d]\n" % MAX_CHANNELS) sys.exit(1) if options.freq is None: sys.stderr.write("op25_tx: must specify frequency with -f FREQ\n") parser.print_help() sys.exit(1) # ---------------------------------------------------------------- # Set up constants and parameters self.u = osmosdr.sink (options.args) # the USRP sink (consumes samples) gain_names = self.u.get_gain_names() for name in gain_names: gain_range = self.u.get_gain_range(name) print("gain: name: %s range: start %d stop %d step %d" % (name, gain_range[0].start(), gain_range[0].stop(), gain_range[0].step())) if options.gains: for tuple in options.gains.split(","): name, gain = tuple.split(":") gain = int(gain) print("setting gain %s to %d" % (name, gain)) self.u.set_gain(gain, name) self.usrp_rate = 320000 print('setting sample rate') self.u.set_sample_rate(self.usrp_rate) self.u.set_center_freq(int(options.freq)) #self.u.set_bandwidth(self.usrp_rate) #self.u = blocks.file_sink(gr.sizeof_gr_complex, 'usrp-samp.dat') #self.dac_rate = self.u.dac_rate() # 128 MS/s #self.usrp_interp = 400 #self.u.set_interp_rate(self.usrp_interp) #self.usrp_rate = self.dac_rate / self.usrp_interp # 320 kS/s #self.sw_interp = 10 #self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s self.audio_rate = 32000 # if not self.set_freq(options.freq): # freq_range = self.subdev.freq_range() # print "Failed to set frequency to %s. Daughterboard supports %s to %s" % ( # eng_notation.num_to_str(options.freq), # eng_notation.num_to_str(freq_range[0]), # eng_notation.num_to_str(freq_range[1])) # raise SystemExit # self.subdev.set_enable(True) # enable transmitter # instantiate vocoders self.vocoders = [] if options.file_input: i = 0 t = blocks.file_source(gr.sizeof_char, "baseband-%d.dat" % i, options.repeat) self.vocoders.append(t) elif options.udp_port > 0: self.udp_sources = [] for i in range (options.nchannels): t = gr.udp_source(1, options.udp_addr, options.udp_port + i, 216) self.udp_sources.append(t) arity = 2 t = gr.packed_to_unpacked_bb(arity, gr.GR_MSB_FIRST) self.vocoders.append(t) self.connect(self.udp_sources[i], self.vocoders[i]) if 1: # else: input_audio_rate = 8000 #self.audio_input = audio.source(input_audio_rate, options.audio_input) af = 1333 audio_input = analog.sig_source_s( input_audio_rate, analog.GR_SIN_WAVE, af, 15000) t = op25_repeater.vocoder(True, # 0=Decode,True=Encode options.verbose, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors self.connect(audio_input, t) self.vocoders.append(t) sum = blocks.add_cc () # Instantiate N NBFM channels step = 100e3 offset = (0 * step, -1 * step, +1 * step, 2 * step, -2 * step, 3 * step, -3 * step) for i in range (options.nchannels): t = pipeline(self.vocoders[i], offset[i], self.audio_rate, self.usrp_rate) self.connect(t, (sum, i)) t = file_pipeline(offset[2], self.usrp_rate, '2013-320k-filt.dat') self.connect(t, (sum, options.nchannels)) gain = blocks.multiply_const_cc (0.75 / (options.nchannels+1)) # connect it all self.connect (sum, gain) self.connect (gain, self.u) # plot an FFT to verify we are sending what we want if options.enable_fft: post_mod = fftsink2.fft_sink_c(panel, title="Post Modulation", fft_size=512, sample_rate=self.usrp_rate, y_per_div=20, ref_level=40) self.connect (sum, post_mod) vbox.Add (post_mod.win, 1, wx.EXPAND)
def __init__(self): gr.top_block.__init__(self, "Recepteur ADSB -Mode-S") Qt.QWidget.__init__(self) self.setWindowTitle("Recepteur ADSB -Mode-S") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "adsb_receiver") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.seuil = seuil = 0.003 self.samp_rate = samp_rate = 2000000 self.freq = freq = 1090000000 ################################################## # Blocks ################################################## self._seuil_range = Range(0.0001, 0.3, 0.0001, 0.003, 200) self._seuil_win = RangeWidget(self._seuil_range, self.set_seuil, 'Seuil', "counter_slider", float) self.top_grid_layout.addWidget(self._seuil_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freq_range = Range(950000000, 1093000000, 10000, 1090000000, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.figures = Qt.QTabWidget() self.figures_widget_0 = Qt.QWidget() self.figures_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_0) self.figures_grid_layout_0 = Qt.QGridLayout() self.figures_layout_0.addLayout(self.figures_grid_layout_0) self.figures.addTab(self.figures_widget_0, 'Waterfall (recu)') self.figures_widget_1 = Qt.QWidget() self.figures_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_1) self.figures_grid_layout_1 = Qt.QGridLayout() self.figures_layout_1.addLayout(self.figures_grid_layout_1) self.figures.addTab(self.figures_widget_1, 'Spectre (recu)') self.figures_widget_2 = Qt.QWidget() self.figures_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.figures_widget_2) self.figures_grid_layout_2 = Qt.QGridLayout() self.figures_layout_2.addLayout(self.figures_grid_layout_2) self.figures.addTab(self.figures_widget_2, 'Rx: temporel / bits') self.top_grid_layout.addWidget(self.figures, 1, 0, 3, 2) for r in range(1, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.rtlsdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.rtlsdr_source_0_0.set_sample_rate(samp_rate) self.rtlsdr_source_0_0.set_center_freq(freq, 0) self.rtlsdr_source_0_0.set_freq_corr(0, 0) self.rtlsdr_source_0_0.set_gain(14, 0) self.rtlsdr_source_0_0.set_if_gain(24, 0) self.rtlsdr_source_0_0.set_bb_gain(20, 0) self.rtlsdr_source_0_0.set_antenna('', 0) self.rtlsdr_source_0_0.set_bandwidth(samp_rate, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Spectre", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.figures_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f( 250, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-0.1, 1.1) self.qtgui_time_sink_x_0_2.set_y_label('Manchester bits', "") self.qtgui_time_sink_x_0_2.enable_tags(True) self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0.000008, 0, "burst") self.qtgui_time_sink_x_0_2.enable_autoscale(False) self.qtgui_time_sink_x_0_2.enable_grid(False) self.qtgui_time_sink_x_0_2.enable_axis_labels(True) self.qtgui_time_sink_x_0_2.enable_control_panel(True) self.qtgui_time_sink_x_0_2.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [8, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_2_win = sip.wrapinstance(self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_2_win, 0, 1, 1, 1) for r in range(0, 1): self.figures_grid_layout_2.setRowStretch(r, 1) for c in range(1, 2): self.figures_grid_layout_2.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Rx mag2', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.figures_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 1, 1) for r in range(0, 1): self.figures_grid_layout_2.setRowStretch(r, 1) for c in range(0, 1): self.figures_grid_layout_2.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.figures_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb('010100001010000001001010110', 0, 'burst') self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_threshold_ff_0 = blocks.threshold_ff(seuil, seuil, 0) self.blocks_tagged_file_sink_0 = blocks.tagged_file_sink(gr.sizeof_char*1, samp_rate) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_burst_tagger_0 = blocks.burst_tagger(gr.sizeof_char) self.blocks_burst_tagger_0.set_true_tag('',True) self.blocks_burst_tagger_0.set_false_tag('burst',False) self.analog_sig_source_x_1 = analog.sig_source_s(samp_rate, analog.GR_COS_WAVE, 80, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_burst_tagger_0, 1)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_burst_tagger_0, 0), (self.blocks_tagged_file_sink_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_correlate_access_code_tag_xx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_2, 0)) self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_burst_tagger_0, 0)) self.connect((self.digital_correlate_access_code_tag_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, frame, panel, vbox, argv): MAX_CHANNELS = 7 stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) parser = OptionParser (option_class=eng_option) parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, help="select USRP Tx side A or B") parser.add_option("-e","--enable-fft", action="store_true", default=False, help="enable spectrum plot (and use more CPU)") parser.add_option("-f", "--freq", type="eng_float", default=None, help="set Tx frequency to FREQ [required]", metavar="FREQ") parser.add_option("-i","--file-input", action="store_true", default=False, help="input from baseband-0.dat, baseband-1.dat ...") parser.add_option("-g", "--audio-gain", type="eng_float", default=1.0, help="input audio gain multiplier") parser.add_option("-n", "--nchannels", type="int", default=1, help="number of Tx channels [1,4]") parser.add_option("-a", "--udp-addr", type="string", default="127.0.0.1", help="UDP host IP address") parser.add_option("--args", type="string", default="", help="device args") parser.add_option("--gains", type="string", default="", help="gains") parser.add_option("-p", "--udp-port", type="int", default=0, help="UDP port number") parser.add_option("-r","--repeat", action="store_true", default=False, help="continuously replay input file") parser.add_option("-S", "--stretch", type="int", default=0, help="elastic buffer trigger value") parser.add_option("-v","--verbose", action="store_true", default=False, help="print out stats") parser.add_option("-I", "--audio-input", type="string", default="", help="pcm input device name. E.g., hw:0,0 or /dev/dsp") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() sys.exit(1) if options.nchannels < 1 or options.nchannels > MAX_CHANNELS: sys.stderr.write ("op25_tx: nchannels out of range. Must be in [1,%d]\n" % MAX_CHANNELS) sys.exit(1) if options.freq is None: sys.stderr.write("op25_tx: must specify frequency with -f FREQ\n") parser.print_help() sys.exit(1) # ---------------------------------------------------------------- # Set up constants and parameters self.u = osmosdr.sink (options.args) # the USRP sink (consumes samples) gain_names = self.u.get_gain_names() for name in gain_names: gain_range = self.u.get_gain_range(name) print "gain: name: %s range: start %d stop %d step %d" % (name, gain_range[0].start(), gain_range[0].stop(), gain_range[0].step()) if options.gains: for tuple in options.gains.split(","): name, gain = tuple.split(":") gain = int(gain) print "setting gain %s to %d" % (name, gain) self.u.set_gain(gain, name) self.usrp_rate = 320000 print 'setting sample rate' self.u.set_sample_rate(self.usrp_rate) self.u.set_center_freq(int(options.freq)) #self.u.set_bandwidth(self.usrp_rate) #self.u = blocks.file_sink(gr.sizeof_gr_complex, 'usrp-samp.dat') #self.dac_rate = self.u.dac_rate() # 128 MS/s #self.usrp_interp = 400 #self.u.set_interp_rate(self.usrp_interp) #self.usrp_rate = self.dac_rate / self.usrp_interp # 320 kS/s #self.sw_interp = 10 #self.audio_rate = self.usrp_rate / self.sw_interp # 32 kS/s self.audio_rate = 32000 # if not self.set_freq(options.freq): # freq_range = self.subdev.freq_range() # print "Failed to set frequency to %s. Daughterboard supports %s to %s" % ( # eng_notation.num_to_str(options.freq), # eng_notation.num_to_str(freq_range[0]), # eng_notation.num_to_str(freq_range[1])) # raise SystemExit # self.subdev.set_enable(True) # enable transmitter # instantiate vocoders self.vocoders = [] if options.file_input: i = 0 t = blocks.file_source(gr.sizeof_char, "baseband-%d.dat" % i, options.repeat) self.vocoders.append(t) elif options.udp_port > 0: self.udp_sources = [] for i in range (options.nchannels): t = gr.udp_source(1, options.udp_addr, options.udp_port + i, 216) self.udp_sources.append(t) arity = 2 t = gr.packed_to_unpacked_bb(arity, gr.GR_MSB_FIRST) self.vocoders.append(t) self.connect(self.udp_sources[i], self.vocoders[i]) if 1: # else: input_audio_rate = 8000 #self.audio_input = audio.source(input_audio_rate, options.audio_input) af = 1333 audio_input = analog.sig_source_s( input_audio_rate, analog.GR_SIN_WAVE, af, 15000) t = op25_repeater.vocoder(True, # 0=Decode,True=Encode options.verbose, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors self.connect(audio_input, t) self.vocoders.append(t) sum = blocks.add_cc () # Instantiate N NBFM channels step = 100e3 offset = (0 * step, -1 * step, +1 * step, 2 * step, -2 * step, 3 * step, -3 * step) for i in range (options.nchannels): t = pipeline(self.vocoders[i], offset[i], self.audio_rate, self.usrp_rate) self.connect(t, (sum, i)) t = file_pipeline(offset[2], self.usrp_rate, '2013-320k-filt.dat') self.connect(t, (sum, options.nchannels)) gain = blocks.multiply_const_cc (0.75 / (options.nchannels+1)) # connect it all self.connect (sum, gain) self.connect (gain, self.u) # plot an FFT to verify we are sending what we want if options.enable_fft: post_mod = fftsink2.fft_sink_c(panel, title="Post Modulation", fft_size=512, sample_rate=self.usrp_rate, y_per_div=20, ref_level=40) self.connect (sum, post_mod) vbox.Add (post_mod.win, 1, wx.EXPAND)