def __init__(self): gr.top_block.__init__(self, "shippingUDPTester") Qt.QWidget.__init__(self) self.setWindowTitle("shippingUDPTester") 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", "shippingTester1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10000 self.msg_str = msg_str = 'AAA000000' self.QPSK = QPSK = digital.constellation_calcdist(([1+1j, -1+1j, 1-1j, -1-1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self._msg_str_tool_bar = Qt.QToolBar(self) self._msg_str_tool_bar.addWidget(Qt.QLabel("msg_str"+": ")) self._msg_str_line_edit = Qt.QLineEdit(str(self.msg_str)) self._msg_str_tool_bar.addWidget(self._msg_str_line_edit) self._msg_str_line_edit.returnPressed.connect( lambda: self.set_msg_str(str(str(self._msg_str_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._msg_str_tool_bar) self.gnuShipping_shippingSender_0 = gnuShipping.shippingSender(5) self.gnuShipping_shippingReciever_0 = gnuShipping.shippingReciever(msg_str) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.blocks_socket_pdu_1 = blocks.socket_pdu("UDP_CLIENT", 'localhost', '10000', 10000, False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_1, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.gnuShipping_shippingReciever_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_socket_pdu_1, 'pdus')) self.msg_connect((self.gnuShipping_shippingSender_0, 'out'), (self.digital_crc32_async_bb_1, 'in'))
def __init__(self, callback): gr.hier_block2.__init__(self, "payload_sink_pdu", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(0, 0, 0)) self.callback = callback #blocks self.tagged_stream_to_pdu = blocks.tagged_stream_to_pdu( blocks.byte_t, "packet_len") self.check_crc = digital.crc32_async_bb(True) self.msg_sink = ofdm_cr_tools.message_handler(self.callback) # Connections self.connect(self, self.tagged_stream_to_pdu) self.msg_connect((self.tagged_stream_to_pdu, 'pdus'), (self.check_crc, 'in')) self.msg_connect((self.check_crc, 'out'), (self.msg_sink, 'in'))
def __init__(self, callback): gr.hier_block2.__init__(self, "payload_source_pdu", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_char * 1)) self.callback = callback ################################################## # Blocks self.msg_source = ofdm_cr_tools.message_handler(self.callback) self.generate_crc = digital.crc32_async_bb(False) self.pdu_to_tagged_stream = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") ################################################## # Connections self.msg_connect((self.msg_source, 'out'), (self.generate_crc, 'in')) self.msg_connect((self.generate_crc, 'out'), (self.pdu_to_tagged_stream, 'pdus')) self.connect((self.pdu_to_tagged_stream, 0), (self, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_qpsk( ).base() self.taps = taps = firdes.root_raised_cosine(32, 32, 0.5, 0.35, 50 * 32) self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 400, #size samp_rate, #samp_rate "bits receiver", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(1) self.qtgui_time_sink_x_0_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 320, #size samp_rate, #samp_rate "receiver", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(1) self.qtgui_time_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, 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(False) 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(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 400, #size samp_rate, #samp_rate "bits sender", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(1) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 400, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(1) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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 xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.pluto_source_0 = iio.pluto_source('ip:192.168.3.2', int(900000000), int(2000000), int(500000), 0x8000, True, True, True, "manual", 50, '', True) self.pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', int(900000000), int(2000000), int(1000000), 0x8000, False, 0, '', True) self.epy_block_3 = epy_block_3.blk(startString='10101010', escapeString='01111000', endString='01100110', preambleString='10000111', preambleLength=18) self.epy_block_2 = epy_block_2.blk(threshold=0.3) self.epy_block_1 = epy_block_1.blk() self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( 4, 0.0628, (taps), 32, 16, 1.5, 1) self.digital_crc32_async_bb_0_0 = digital.crc32_async_bb(True) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.055, 4, True) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf( variable_constellation_0) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=variable_constellation_0, differential=False, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc( 30, 1, 0.001, 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_vector_source_x_0 = blocks.vector_source_b( (180, 180, 180, 180, 180, 180, 180, 180, 0), True, 1, []) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("TEST"), 0.001) self.blocks_message_debug_1 = blocks.message_debug() self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.epy_block_1, 'msg_in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.epy_block_3, 'packet_in')) self.msg_connect((self.digital_crc32_async_bb_0_0, 'out'), (self.blocks_message_debug_1, 'print_pdu')) self.msg_connect((self.epy_block_1, 'msg_out'), (self.digital_crc32_async_bb_0, 'in')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.pluto_sink_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.epy_block_2, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.epy_block_2, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.epy_block_2, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.pluto_source_0, 0), (self.blocks_add_xx_0, 0))
def __init__(self, chiprate=2000000, data_seed_rx=2645625, fec_tailbiting=True, max_freq_hypo=1, ovsf_code_index=0, ovsf_spreading_factor=0, preamble_len=32, preamble_seed_rx=54321, psdu_len=16, roll_off=1, sfd_present=False, spread_factor=2**10, sps=4): gr.top_block.__init__(self, "LECIM DSSS rx") Qt.QWidget.__init__(self) self.setWindowTitle("LECIM DSSS rx") 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", "rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.chiprate = chiprate self.data_seed_rx = data_seed_rx self.fec_tailbiting = fec_tailbiting self.max_freq_hypo = max_freq_hypo self.ovsf_code_index = ovsf_code_index self.ovsf_spreading_factor = ovsf_spreading_factor self.preamble_len = preamble_len self.preamble_seed_rx = preamble_seed_rx self.psdu_len = psdu_len self.roll_off = roll_off self.sfd_present = sfd_present self.spread_factor = spread_factor self.sps = sps ################################################## # Variables ################################################## self.taps_num = taps_num = 64 self.samp_rate = samp_rate = 4e6 self.len_tag_var = len_tag_var = "packet_len" self.freq_vec = freq_vec = lpwan.dsss_const.gen_freq_hypo_vec( spread_factor, chiprate, max_freq_hypo) self.fo = fo = 2000 ################################################## # Blocks ################################################## self._fo_range = Range(-15000, 15000, 1, 2000, 200) self._fo_win = RangeWidget(self._fo_range, self.set_fo, "fo", "counter_slider", float) self.top_layout.addWidget(self._fo_win) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, sps, 1, 1, taps_num)) self.qtgui_time_sink_x_3_0 = qtgui.time_sink_f( 5240000, #size 4e6, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_3_0.set_update_time(0.10) self.qtgui_time_sink_x_3_0.set_y_axis(-1, 2e6) self.qtgui_time_sink_x_3_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_3_0.enable_tags(-1, True) self.qtgui_time_sink_x_3_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 3, 40000, 0, "PSDU") self.qtgui_time_sink_x_3_0.enable_autoscale(True) self.qtgui_time_sink_x_3_0.enable_grid(False) self.qtgui_time_sink_x_3_0.enable_axis_labels(True) self.qtgui_time_sink_x_3_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_3_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_3_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_3_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_3_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_3_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_3_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_3_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_3_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_3_0_win = sip.wrapinstance( self.qtgui_time_sink_x_3_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_3_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) 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) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not 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] for i in xrange(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.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( psdu_len * 8, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(True) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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 xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.lpwan_message_counter_0 = lpwan.message_counter(10, 1) self.lpwan_dsss_preamble_search_cc_0_0 = lpwan.dsss_preamble_search_cc( spread_factor, preamble_seed_rx, ovsf_code_index, ovsf_spreading_factor, (freq_vec), preamble_len, sfd_present, sps, 0, chiprate, "oqpsk", (firdes.root_raised_cosine(1, sps, 1, roll_off, taps_num))) self.lpwan_dsss_normalize_ff_0 = lpwan.dsss_normalize_ff(len_tag_var) self.lpwan_dsss_filter_crc_packets_0 = lpwan.dsss_filter_crc_packets() self.lpwan_dsss_diff_decoding_ff_0 = lpwan.dsss_diff_decoding_ff( len_tag_var, True, preamble_len + (8 if sfd_present else 0)) self.lpwan_dsss_despread_cc_0_0 = lpwan.dsss_despread_cc( spread_factor, data_seed_rx, preamble_seed_rx, ovsf_code_index, ovsf_spreading_factor, sps, psdu_len, 1, chiprate, False, False, 1, 0.05, 0.8, 0.25) self.lpwan_dsss_deinterleaver_ff_0 = lpwan.dsss_deinterleaver_ff( len_tag_var) self.dsss_fec_dec_fb_0 = dsss_fec_dec_fb( len_tag_var=len_tag_var, tailbiting=fec_tailbiting, ) self.digital_crc32_async_bb_1_0 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0, )) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/media/maier/73083b7c-6150-4a9b-9a6d-38e866ba5fba/mathesis_iq_files/per_messung dachgeschoss cel/PER_Dachgeschoss1024_reference_txgain80.iq', True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fo, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.lpwan_dsss_filter_crc_packets_0, 'in_soft')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.digital_crc32_async_bb_1_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.lpwan_message_counter_0, 'in')) self.msg_connect( (self.digital_crc32_async_bb_1_0, 'out'), (self.lpwan_dsss_filter_crc_packets_0, 'in_hard_crc_ok')) self.msg_connect((self.dsss_fec_dec_fb_0, 'out'), (self.digital_crc32_async_bb_1, 'in')) self.msg_connect((self.dsss_fec_dec_fb_0, 'out'), (self.lpwan_dsss_filter_crc_packets_0, 'in_hard')) self.msg_connect((self.lpwan_dsss_filter_crc_packets_0, 'out_soft'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_3_0, 0)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.lpwan_dsss_deinterleaver_ff_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_3_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.lpwan_dsss_deinterleaver_ff_0, 0), (self.lpwan_dsss_normalize_ff_0, 0)) self.connect((self.lpwan_dsss_despread_cc_0_0, 0), (self.lpwan_dsss_diff_decoding_ff_0, 0)) self.connect((self.lpwan_dsss_diff_decoding_ff_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.lpwan_dsss_diff_decoding_ff_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.lpwan_dsss_normalize_ff_0, 0), (self.dsss_fec_dec_fb_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 1), (self.blocks_null_sink_1_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 0), (self.lpwan_dsss_despread_cc_0_0, 0)) self.connect((self.lpwan_message_counter_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.lpwan_dsss_preamble_search_cc_0_0, 0))
def __init__(self, chiprate=2000000, data_seed_tx=2645625, fec_tailbiting=True, ovsf_code_index=0, ovsf_spreading_factor=0, preamble_len=32, preamble_seed_tx=54321, psdu_len=16, roll_off=1, sfd_present=False, spread_factor=2**10, sps=4): gr.top_block.__init__(self, "LECIM DSSS tx") Qt.QWidget.__init__(self) self.setWindowTitle("LECIM DSSS tx") 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", "tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.chiprate = chiprate self.data_seed_tx = data_seed_tx self.fec_tailbiting = fec_tailbiting self.ovsf_code_index = ovsf_code_index self.ovsf_spreading_factor = ovsf_spreading_factor self.preamble_len = preamble_len self.preamble_seed_tx = preamble_seed_tx self.psdu_len = psdu_len self.roll_off = roll_off self.sfd_present = sfd_present self.spread_factor = spread_factor self.sps = sps ################################################## # Variables ################################################## self.sfd = sfd = lpwan.dsss_const.sfd32 if preamble_len == 32 else lpwan.dsss_const.sfd16 self.preamble = preamble = lpwan.dsss_const.preamble32 if preamble_len == 32 else lpwan.dsss_const.preamble16 self.taps_num = taps_num = 32 self.shr = shr = np.append(preamble, sfd) if sfd_present else preamble self.len_tag_var = len_tag_var = "packet_len" ################################################## # Blocks ################################################## self.lpwan_dsss_spreading_bb_0_0 = lpwan.dsss_spreading_bb( len_tag_var, spread_factor, preamble_seed_tx, True, ovsf_code_index, ovsf_spreading_factor) self.lpwan_dsss_spreading_bb_0 = lpwan.dsss_spreading_bb( len_tag_var, spread_factor, data_seed_tx, False, ovsf_code_index, ovsf_spreading_factor) self.lpwan_dsss_interleaver_bb_0 = lpwan.dsss_interleaver_bb( len_tag_var) self.lpwan_dsss_diff_coding_bb_0_0 = lpwan.dsss_diff_coding_bb( len_tag_var) self.lpwan_dsss_diff_coding_bb_0 = lpwan.dsss_diff_coding_bb( len_tag_var) self.dsss_oqpsk_mod_0_0 = dsss_oqpsk_mod( burst_tag="burst", num_of_taps=taps_num, packet_length=(psdu_len * 8 * 2 + len(shr)) * spread_factor, roll_off=roll_off, sps=sps, ) self.dsss_fec_enc_b_0_0 = dsss_fec_enc_b( len_tag_var=len_tag_var, tailbiting=fec_tailbiting, ) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.blocks_vector_source_x_0_0 = blocks.vector_source_b( shr.tolist(), True, 1, [ gr.tag_utils.python_to_tag( (0, pmt.intern(len_tag_var), pmt.from_long(len(shr)))) ]) self.blocks_stream_mux_0 = blocks.stream_mux( gr.sizeof_char * 1, (len(shr) * spread_factor, psdu_len * 2 * 8 * spread_factor)) self.blocks_random_pdu_0 = blocks.random_pdu(psdu_len - 4, psdu_len - 4, chr(0xFF), 1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("generate"), 50) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, '/Users/victorguipont/Developpement-informatique/GNU-radio/sf1024', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.dsss_fec_enc_b_0_0, 'in')) self.connect((self.blocks_stream_mux_0, 0), (self.dsss_oqpsk_mod_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.lpwan_dsss_diff_coding_bb_0_0, 0)) self.connect((self.dsss_fec_enc_b_0_0, 0), (self.lpwan_dsss_interleaver_bb_0, 0)) self.connect((self.dsss_oqpsk_mod_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.lpwan_dsss_diff_coding_bb_0, 0), (self.lpwan_dsss_spreading_bb_0, 0)) self.connect((self.lpwan_dsss_diff_coding_bb_0_0, 0), (self.lpwan_dsss_spreading_bb_0_0, 0)) self.connect((self.lpwan_dsss_interleaver_bb_0, 0), (self.lpwan_dsss_diff_coding_bb_0, 0)) self.connect((self.lpwan_dsss_spreading_bb_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.lpwan_dsss_spreading_bb_0_0, 0), (self.blocks_stream_mux_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tx Stage6") Qt.QWidget.__init__(self) self.setWindowTitle("Tx Stage6") 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", "tx_stage6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.psf_taps = psf_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 15*sps*nfilts) self.thresh = thresh = 3 self.taps_per_filt = taps_per_filt = len(psf_taps)/nfilts self.pld_const = pld_const = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.pld_const.gen_soft_dec_lut(8) self.hdr_format = hdr_format = digital.header_format_default(digital.packet_utils.default_access_code, thresh) self.hdr_const = hdr_const = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.hdr_const.gen_soft_dec_lut(8) self.filt_delay = filt_delay = 1+(taps_per_filt-1)/2 self.bps = bps = pld_const.bits_per_symbol() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Time') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Freq') self.top_layout.addWidget(self.tab) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 400*sps, #size sps, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.01) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 15, 0, 'packet_len') self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc sps, #bw "", #name 1 #number of inputs ) 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) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not 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] for i in xrange(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.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(psf_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf=0' ) self.osmosdr_sink_0.set_sample_rate(32) self.osmosdr_sink_0.set_center_freq(144e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(10, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna('ant0', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async(hdr_format) self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_map_bb_1 = digital.map_bb((hdr_const.pre_diff_code())) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((pld_const.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((hdr_const.points()), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, 'packet_len', 0) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '52001', 10, False) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, pld_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, hdr_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.5, )) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.digital_crc32_async_bb_1, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.digital_protocol_formatter_async_0, 'in')) self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_map_bb_1, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Shipping Passing App") Qt.QWidget.__init__(self) self.setWindowTitle("Shipping Passing App") 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", "basicTxRx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.msg_str = msg_str = "CSQ305438" self.QPSK = QPSK = digital.constellation_calcdist( ([1 + 1j, -1 + 1j, 1 - 1j, -1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self._msg_str_tool_bar = Qt.QToolBar(self) self._msg_str_tool_bar.addWidget(Qt.QLabel("msg_str" + ": ")) self._msg_str_line_edit = Qt.QLineEdit(str(self.msg_str)) self._msg_str_tool_bar.addWidget(self._msg_str_line_edit) self._msg_str_line_edit.returnPressed.connect(lambda: self.set_msg_str( str(str(self._msg_str_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._msg_str_tool_bar) self.tutorial_my_qpsk_demod_cb_0 = tutorial.my_qpsk_demod_cb(True) self.gnuShipping_shippingSender_0 = gnuShipping.shippingSender(5) self.gnuShipping_shippingReciever_0 = gnuShipping.shippingReciever( msg_str) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (QPSK.points()), 1) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "tsb_tag") self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 2, 8, "tsb_tag", True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, 2, "tsb_tag", False, gr.GR_LSB_FIRST) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "tsb_tag") ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.gnuShipping_shippingReciever_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.gnuShipping_shippingSender_0, 'out'), (self.digital_crc32_async_bb_1, 'in')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.tutorial_my_qpsk_demod_cb_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_0, 0), (self.blocks_repack_bits_bb_1, 0))
def __init__(self, access_code_threshold=0, hw_sample_rate=1e7, resample_rate=100, sps=8): gr.hier_block2.__init__( self, "BPSK FHSS Modem V3", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.message_port_register_hier_in("tx_freq_in") self.message_port_register_hier_in("rx_freq_in") self.message_port_register_hier_in("msg_in") self.message_port_register_hier_out("msg_out") ################################################## # Parameters ################################################## self.access_code_threshold = access_code_threshold self.hw_sample_rate = hw_sample_rate self.resample_rate = resample_rate self.sps = sps ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 0.35 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 5*sps*nfilts) self.header_specs = header_specs = digital.packet_header_default(5,"packet_len","packet_num",8) self.firdes_tap = firdes_tap = firdes.low_pass(1, samp_rate, 22000, 8000, firdes.WIN_BLACKMAN_HARRIS, 6.76) self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=resample_rate, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=resample_rate, decimation=1, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (1, ), 1e5, samp_rate) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes_tap), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, .063, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_specs) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(header_specs, "pkt_len") self.digital_header_payload_demux_0_0 = digital.header_payload_demux( 5, 1, 0, "packet_len", "packet_len", False, gr.sizeof_char, "rx_time", samp_rate, (), ) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(3.14/100, 2, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, "pkt_len", 0) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "pkt_len") self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "output.bin", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, 1, 0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self, 'msg_out')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0_0, 'header_data')) self.msg_connect((self, 'tx_freq_in'), (self.analog_sig_source_x_0, 'freq')) self.msg_connect((self, 'rx_freq_in'), (self.freq_xlating_fir_filter_xxx_0, 'freq')) self.msg_connect((self, 'msg_in'), (self.digital_crc32_async_bb_1, 'in')) self.connect((self.analog_agc_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_header_payload_demux_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_header_payload_demux_0_0, 1), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_header_payload_demux_0_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_agc_xx_0, 0))
def __init__(self, index=1, pdu_len=28, resampling=2, sps=2): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.index = index self.pdu_len = pdu_len self.resampling = resampling self.sps = sps ################################################## # Variables ################################################## self.samp_rate_3 = samp_rate_3 = 75000 self.samp_rate_2 = samp_rate_2 = 37500 self.samp_rate_1 = samp_rate_1 = 25000 self.samp_rate_0 = samp_rate_0 = 12500 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate_1*sps*resampling) self.uhd_usrp_source_0.set_center_freq(902200000, 0) self.uhd_usrp_source_0.set_gain(30, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), 'burst', ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate_1*sps*resampling) self.uhd_usrp_sink_0.set_center_freq(902200000, 0) self.uhd_usrp_sink_0.set_gain(30, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_c( 1024*16, #size samp_rate_1*sps, #samp_rate "normalized", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.2, 1.2) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_c( 1024*16, #size samp_rate_1*sps, #samp_rate "resampled", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-0.1, 0.1) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_c( 1024*16*resampling, #size samp_rate_1*sps*resampling, #samp_rate "received", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-0.1, 0.1) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.lpwan_lecim_fsk_phy_tx_0 = lpwan_lecim_fsk_phy_tx( band=False, burst_tag="burst", data_whitening=True, fcs=False, index=index, pdu_len=pdu_len + 4, pfsk=False, preamble_len=64, resampling=resampling, spreading=True, spreading_alternating=False, spreading_factor=16, sps=sps, ) self.lpwan_lecim_fsk_phy_rx_0 = lpwan_lecim_fsk_phy_rx( band=False, data_whitening=True, fcs=False, index=index, pdu_len=pdu_len +4, pfsk=True, preamble_len=64, resampling=resampling, spreading=True, spreading_alternating=False, spreading_factor=16, sps=sps, threshold_0=0.8, threshold_1=0.8, ) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(True) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.blocks_random_pdu_0 = blocks.random_pdu(pdu_len, pdu_len, chr(0xFF), 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("generate"), 5000) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.lpwan_lecim_fsk_phy_tx_0, 'in_tx')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lpwan_lecim_fsk_phy_rx_0, 'out_rx'), (self.digital_crc32_async_bb_1, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.lpwan_lecim_fsk_phy_rx_0, 2), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.lpwan_lecim_fsk_phy_rx_0, 3), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.lpwan_lecim_fsk_phy_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.lpwan_lecim_fsk_phy_rx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Evolucao") Qt.QWidget.__init__(self) self.setWindowTitle("Evolucao") 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", "evolucao") self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.pld_const = pld_const = digital.constellation_calcdist((digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).base() self.pld_const.gen_soft_dec_lut(8) self.sps = sps = 2 self.rep = rep = 3 self.preamble_rep = preamble_rep = [0xe3, 0x8f, 0xc0, 0xfc, 0x7f, 0xc7, 0xe3, 0x81, 0xc0, 0xff, 0x80, 0x38, 0xff, 0xf0, 0x38, 0xe0, 0x0f, 0xc0, 0x03, 0x80, 0x00, 0xff, 0xff, 0xc0] self.preamble_dummy = preamble_dummy = [0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc] self.nfilts = nfilts = 32 self.hdr_format = hdr_format = digital.header_format_counter(digital.packet_utils.default_access_code, 3, pld_const.bits_per_symbol()) self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 5*sps*nfilts) self.rate = rate = 2 self.preamble_select = preamble_select = {1: preamble_dummy, 3: preamble_rep} self.hdr_const = hdr_const = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.hdr_const.gen_soft_dec_lut(8) self.dec_hdr = dec_hdr = fec.repetition_decoder.make(hdr_format.header_nbits(), rep, 0.5) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps)/nfilts self.rxmod = rxmod = digital.generic_mod(hdr_const, False, sps, True, eb, False, False) self.preamble = preamble = preamble_select[int(1.0/dec_hdr.rate())] self.polys = polys = [109, 79] self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119] self.k = k = 7 self.time_offset = time_offset = 1.0 self.sps_0 = sps_0 = 2 self.samp_rate = samp_rate = 32000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, eb, 11*sps*nfilts) self.noise = noise = 0.0 self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc(rxmod .to_basic_block(), (preamble), ([1])) self.mark_delay = mark_delay = mark_delays[sps] self.freq_offset = freq_offset = 0 self.filt_delay = filt_delay = 1+(taps_per_filt-1)/2 self.enc_hdr = enc_hdr = fec.repetition_encoder_make(8000, rep) self.enc = enc = fec.cc_encoder_make(8000, k, rate, (polys), 0, fec.CC_TERMINATED, False) self.dec = dec = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False) self.amp = amp = 1.0 ################################################## # Blocks ################################################## self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._time_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._noise_range = Range(0, 5, 0.01, 0.0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_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._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_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._amp_range = Range(0, 2, 0.01, 1.0, 200) self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._amp_win) self.tab1 = Qt.QTabWidget() self.tab1_widget_0 = Qt.QWidget() self.tab1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_0) self.tab1_grid_layout_0 = Qt.QGridLayout() self.tab1_layout_0.addLayout(self.tab1_grid_layout_0) self.tab1.addTab(self.tab1_widget_0, 'Time') self.tab1_widget_1 = Qt.QWidget() self.tab1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_1) self.tab1_grid_layout_1 = Qt.QGridLayout() self.tab1_layout_1.addLayout(self.tab1_grid_layout_1) self.tab1.addTab(self.tab1_widget_1, 'Freq.') self.tab1_widget_2 = Qt.QWidget() self.tab1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_2) self.tab1_grid_layout_2 = Qt.QGridLayout() self.tab1_layout_2.addLayout(self.tab1_grid_layout_2) self.tab1.addTab(self.tab1_widget_2, 'Const.') self.top_grid_layout.addWidget(self.tab1, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.fec_generic_decoder_0 = fec.decoder(dec_hdr, gr.sizeof_float, gr.sizeof_char) self.fec_async_encoder_0_0 = fec.async_encoder(enc, True, False, False, 1500) self.fec_async_encoder_0 = fec.async_encoder(enc, True, False, False, 1500) self.fec_async_decoder_0 = fec.async_decoder(dec_hdr, True, False, 1500*8) self.digital_protocol_parser_b_0 = digital.protocol_parser_b(hdr_format) self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async(hdr_format) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/400.0, (rx_rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code())) self.digital_map_bb_1 = digital.map_bb((hdr_const.pre_diff_code())) self.digital_header_payload_demux_0 = digital.header_payload_demux( (hdr_format.header_nbits() * int(1.0/dec_hdr.rate())) / hdr_const.bits_per_symbol(), 1, 0, "payload symbols", "time_est", True, gr.sizeof_gr_complex, "rx_time", 1, "", 0, ) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(6.28/200.0, pld_const.arity(), False) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(6.28/200.0, hdr_const.arity(), False) self.digital_corr_est_cc_0 = digital.corr_est_cc((modulated_sync_word), sps, mark_delay, 0.999) self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf(hdr_const) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((pld_const.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((hdr_const.points()), 1) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((firdes.window(firdes.WIN_HANN, 20, 0)), 0, filt_delay, True, 'packet_len') (self.digital_burst_shaper_xx_0).set_block_alias("burst_shaper0") self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0, ), noise_seed=0, block_tags=True ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(blocks.float_t, "payload symbols") self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'pacote') self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, 'packet_len', 0) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(gr.sizeof_float*1, "payload symbols", pld_const.bits_per_symbol()) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'packet_len', sps) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 100, 'pacote') self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, pld_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, hdr_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, )) self.blocks_multiply_by_tag_value_cc_0 = blocks.multiply_by_tag_value_cc("amp_est", 1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/andre/Desktop/transmit_maior.txt', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/andre/Desktop/transmitido/depois.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_1, 'in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.fec_async_decoder_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.fec_async_encoder_0, 'in')) self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.fec_async_encoder_0_0, 'in')) self.msg_connect((self.digital_protocol_parser_b_0, 'info'), (self.digital_header_payload_demux_0, 'header_data')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.fec_async_encoder_0, 'out'), (self.digital_protocol_formatter_async_0, 'in')) self.msg_connect((self.fec_async_encoder_0_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_by_tag_value_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_burst_shaper_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_burst_shaper_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0_0, 0), (self.fec_generic_decoder_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_multiply_by_tag_value_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_soft_decoder_cf_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self.digital_map_bb_1, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.fec_generic_decoder_0, 0), (self.digital_protocol_parser_b_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
def __init__(self, chiprate=2000000, data_seed_rx=2345432, data_seed_tx=2345432, fec_tailbiting=True, max_freq_hypo=2, ovsf_code_index=0, ovsf_spreading_factor=0, preamble_len=32, preamble_seed_rx=54321, preamble_seed_tx=54321, psdu_len=32, roll_off=1, sfd_present=False, spread_factor=2**10, sps=4): gr.top_block.__init__(self, "my personal playground") Qt.QWidget.__init__(self) self.setWindowTitle("my personal playground") 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", "playground") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.chiprate = chiprate self.data_seed_rx = data_seed_rx self.data_seed_tx = data_seed_tx self.fec_tailbiting = fec_tailbiting self.max_freq_hypo = max_freq_hypo self.ovsf_code_index = ovsf_code_index self.ovsf_spreading_factor = ovsf_spreading_factor self.preamble_len = preamble_len self.preamble_seed_rx = preamble_seed_rx self.preamble_seed_tx = preamble_seed_tx self.psdu_len = psdu_len self.roll_off = roll_off self.sfd_present = sfd_present self.spread_factor = spread_factor self.sps = sps ################################################## # Variables ################################################## self.sfd = sfd = lpwan.dsss_const.sfd32 if preamble_len == 32 else lpwan.dsss_const.sfd16 self.preamble = preamble = lpwan.dsss_const.preamble32 if preamble_len == 32 else lpwan.dsss_const.preamble16 self.taps_num_0 = taps_num_0 = 64 self.taps_num = taps_num = 64 self.shr = shr = np.append(preamble, sfd) if sfd_present else preamble self.len_tag_var = len_tag_var = "packet_len" self.freq_vec = freq_vec = lpwan.dsss_const.gen_freq_hypo_vec( spread_factor, chiprate, max_freq_hypo) ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, sps, 1, 1, taps_num)) self.qtgui_time_sink_x_3_0 = qtgui.time_sink_f( 1024000, #size 1, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_3_0.set_update_time(0.10) self.qtgui_time_sink_x_3_0.set_y_axis(-1, 2e6) self.qtgui_time_sink_x_3_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_3_0.enable_tags(-1, True) self.qtgui_time_sink_x_3_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 200, 40000, 0, "PSDU") self.qtgui_time_sink_x_3_0.enable_autoscale(True) self.qtgui_time_sink_x_3_0.enable_grid(False) self.qtgui_time_sink_x_3_0.enable_axis_labels(True) self.qtgui_time_sink_x_3_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_3_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_3_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_3_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_3_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_3_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_3_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_3_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_3_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_3_0_win = sip.wrapinstance( self.qtgui_time_sink_x_3_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_3_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 256, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(True) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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 xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.lpwan_message_counter_0 = lpwan.message_counter(0, 1) self.lpwan_dsss_spreading_bb_0_0 = lpwan.dsss_spreading_bb( len_tag_var, spread_factor, preamble_seed_tx, True, ovsf_code_index, ovsf_spreading_factor) self.lpwan_dsss_spreading_bb_0 = lpwan.dsss_spreading_bb( len_tag_var, spread_factor, data_seed_tx, False, ovsf_code_index, ovsf_spreading_factor) self.lpwan_dsss_preamble_search_cc_0 = lpwan.dsss_preamble_search_cc( spread_factor, preamble_seed_rx, ovsf_code_index, ovsf_spreading_factor, (freq_vec), preamble_len, sfd_present, sps, 0, chiprate, "oqpsk", (firdes.root_raised_cosine(1, sps, 1, roll_off, taps_num))) self.lpwan_dsss_normalize_ff_0 = lpwan.dsss_normalize_ff(len_tag_var) self.lpwan_dsss_interleaver_bb_0 = lpwan.dsss_interleaver_bb( len_tag_var) self.lpwan_dsss_filter_crc_packets_0 = lpwan.dsss_filter_crc_packets() self.lpwan_dsss_diff_decoding_ff_0 = lpwan.dsss_diff_decoding_ff( len_tag_var, True, len(shr)) self.lpwan_dsss_diff_coding_bb_0_0_0 = lpwan.dsss_diff_coding_bb( len_tag_var) self.lpwan_dsss_diff_coding_bb_0 = lpwan.dsss_diff_coding_bb( len_tag_var) self.lpwan_dsss_despread_cc_0 = lpwan.dsss_despread_cc( spread_factor, data_seed_rx, preamble_seed_rx, ovsf_code_index, ovsf_spreading_factor, sps, psdu_len, 1, chiprate, False, True, 1, 0.05, 0.8, 0.5) self.lpwan_dsss_deinterleaver_ff_0_0 = lpwan.dsss_deinterleaver_ff( len_tag_var) self.foo_periodic_msg_source_0 = foo.periodic_msg_source( pmt.intern("Hello World!"), 20, 200, True, False) self.dsss_oqpsk_mod_0 = dsss_oqpsk_mod( burst_tag="burst", num_of_taps=taps_num, packet_length=(psdu_len * 8 * 2 + len(shr)) * spread_factor, roll_off=roll_off, sps=sps, ) self.dsss_fec_enc_b_0_0 = dsss_fec_enc_b( len_tag_var=len_tag_var, tailbiting=fec_tailbiting, ) self.dsss_fec_dec_fb_0 = dsss_fec_dec_fb( len_tag_var=len_tag_var, tailbiting=fec_tailbiting, ) self.digital_crc32_async_bb_1_0 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(True) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.blocks_vector_source_x_0_0 = blocks.vector_source_b( shr.tolist(), True, 1, [ gr.tag_utils.python_to_tag( (0, pmt.intern(len_tag_var), pmt.from_long(len(shr)))) ]) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_tag_gate_1 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_stream_mux_0 = blocks.stream_mux( gr.sizeof_char * 1, (len(shr) * spread_factor, psdu_len * 2 * 8 * spread_factor)) self.blocks_random_pdu_0 = blocks.random_pdu(psdu_len - 4, psdu_len - 4, chr(0xFF), 1) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_null_sink_1_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 1, 213) ################################################## # Connections ################################################## self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.lpwan_dsss_filter_crc_packets_0, 'in_soft')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.dsss_fec_enc_b_0_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.digital_crc32_async_bb_1_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.lpwan_message_counter_0, 'in')) self.msg_connect( (self.digital_crc32_async_bb_1_0, 'out'), (self.lpwan_dsss_filter_crc_packets_0, 'in_hard_crc_ok')) self.msg_connect((self.dsss_fec_dec_fb_0, 'out'), (self.digital_crc32_async_bb_1, 'in')) self.msg_connect((self.dsss_fec_dec_fb_0, 'out'), (self.lpwan_dsss_filter_crc_packets_0, 'in_hard')) self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.lpwan_dsss_filter_crc_packets_0, 'out_soft'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_3_0, 0)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_3_0, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.lpwan_dsss_deinterleaver_ff_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.dsss_oqpsk_mod_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_tag_gate_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.lpwan_dsss_diff_coding_bb_0_0_0, 0)) self.connect((self.dsss_fec_enc_b_0_0, 0), (self.lpwan_dsss_interleaver_bb_0, 0)) self.connect((self.dsss_oqpsk_mod_0, 0), (self.blocks_tag_gate_1, 0)) self.connect((self.lpwan_dsss_deinterleaver_ff_0_0, 0), (self.lpwan_dsss_normalize_ff_0, 0)) self.connect((self.lpwan_dsss_despread_cc_0, 0), (self.lpwan_dsss_diff_decoding_ff_0, 0)) self.connect((self.lpwan_dsss_diff_coding_bb_0, 0), (self.lpwan_dsss_spreading_bb_0, 0)) self.connect((self.lpwan_dsss_diff_coding_bb_0_0_0, 0), (self.lpwan_dsss_spreading_bb_0_0, 0)) self.connect((self.lpwan_dsss_diff_decoding_ff_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.lpwan_dsss_diff_decoding_ff_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.lpwan_dsss_interleaver_bb_0, 0), (self.lpwan_dsss_diff_coding_bb_0, 0)) self.connect((self.lpwan_dsss_normalize_ff_0, 0), (self.dsss_fec_dec_fb_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0, 1), (self.blocks_null_sink_1_0_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0, 1), (self.blocks_tag_gate_0, 0)) self.connect((self.lpwan_dsss_preamble_search_cc_0, 0), (self.lpwan_dsss_despread_cc_0, 0)) self.connect((self.lpwan_dsss_spreading_bb_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.lpwan_dsss_spreading_bb_0_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.lpwan_message_counter_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.lpwan_dsss_preamble_search_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Loop Back") Qt.QWidget.__init__(self) self.setWindowTitle("Loop Back") 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", "lb_system") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.time_offset = time_offset = 1 self.samp_rate = samp_rate = 4000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.preamble_dec = preamble_dec = [ 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc ] self.preamble = preamble = [ 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1 ] self.phase = phase = 0.8 self.payload_size = payload_size = 56 self.nr_packet = nr_packet = 1 self.noise = noise = 0.005 self.freq_offset = freq_offset = 0 self.constel = constel = digital.constellation_bpsk().base() self.constel.gen_soft_dec_lut(8) ################################################## # Blocks ################################################## self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Time') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Freq.') self.tab0_widget_2 = Qt.QWidget() self.tab0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_2) self.tab0_grid_layout_2 = Qt.QGridLayout() self.tab0_layout_2.addLayout(self.tab0_grid_layout_2) self.tab0.addTab(self.tab0_widget_2, 'phase') self.tab0_widget_3 = Qt.QWidget() self.tab0_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_3) self.tab0_grid_layout_3 = Qt.QGridLayout() self.tab0_layout_3.addLayout(self.tab0_grid_layout_3) self.tab0.addTab(self.tab0_widget_3, 'noise') self.top_grid_layout.addWidget(self.tab0) self._time_offset_range = Range(0.995, 1.005, 0.00001, 1, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Timing Offset', "slider", float) self.tab0_grid_layout_0.addWidget(self._time_offset_win) self._phase_range = Range(-2 * 3.14, 2 * 3.14, 0.1, 0.8, 200) self._phase_win = RangeWidget(self._phase_range, self.set_phase, 'Phase offset', "slider", float) self.tab0_grid_layout_2.addWidget(self._phase_win) self._noise_range = Range(0, 1, 0.005, 0.005, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "noise", "counter_slider", float) self.tab0_grid_layout_3.addWidget(self._noise_win) self._freq_offset_range = Range(-0.001, 0.001, 0.00002, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Frequency Offset', "slider", float) self.tab0_grid_layout_1.addWidget(self._freq_offset_win) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("GEN"), 1000 / nr_packet) self.blocks_message_debug_0 = blocks.message_debug() self.Packet_Builder = Packet_Builder.msg_block( Packet_len=payload_size + 4) ################################################## # Connections ################################################## self.msg_connect((self.Packet_Builder, 'packet'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.Packet_Builder, 'GEN')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
def __init__(self, freq): gr.top_block.__init__(self, "Burst Receiver") ################################################## # Variables ################################################## self.sps = sps = 4 self.hdr_cons = hdr_cons = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.eb = eb = .700 self.tsh = tsh = 0 self.rxmod = rxmod = digital.generic_mod(hdr_cons, False, sps, True, eb, False, False) self.preamble = preamble = [ 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc ] self.nfilts = nfilts = 64 self.mark_delays = mark_delays = [0, 34, 87, 0, 262] self.usrp_rate = usrp_rate = 500e3 self.rx_psf_taps = rx_psf_taps = firdes.root_raised_cosine( nfilts, sps * nfilts, 1.0, eb, nfilts * sps * 11) self.pld_cons = pld_cons = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc( rxmod.to_basic_block(), (preamble), ([1])) self.mark_delay = mark_delay = mark_delays[sps / 2] self.freq = freq self.format_0 = format_0 = digital.header_format_default( digital.packet_utils.default_access_code, tsh) ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(usrp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.digital_protocol_parser_b_0 = digital.protocol_parser_b(format_0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 400, (rx_psf_taps), nfilts, 16, 1.5, 1) self.digital_header_payload_demux_0 = digital.header_payload_demux( format_0.header_nbits() / hdr_cons.bits_per_symbol(), 1, 0, "payload symbols", "time_est", False, gr.sizeof_gr_complex, "rx_time", 1, "", 0, ) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, eb, 16, 6.28 / 100) self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb( pld_cons.arity()) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(True) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 400, pld_cons.arity(), False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 6.28 / 400, hdr_cons.arity(), False) self.digital_corr_est_cc_0 = digital.corr_est_cc( (modulated_sync_word), sps, mark_delay, 0.9999999) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( pld_cons) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( hdr_cons) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "payload symbols") self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", '127.0.0.1', '52002', 10000, False) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 8, "payload symbols", True, gr.GR_MSB_FIRST) self.blocks_multiply_by_tag_value_cc_0 = blocks.multiply_by_tag_value_cc( "amp_est", 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_1, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.digital_protocol_parser_b_0, 'info'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.blocks_multiply_by_tag_value_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_protocol_parser_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.digital_diff_decoder_bb_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_multiply_by_tag_value_cc_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_diff_decoder_bb_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_fll_band_edge_cc_0, 0))
def __init__(self, eb=0.35, hdr_const=digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base(), hdr_dec=fec.dummy_decoder.make(8000), hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0), pld_const=digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base(), pld_dec=fec.dummy_decoder.make(8000), psf_taps=[ 0, ], sps=2): gr.hier_block2.__init__( self, "Packet Rx", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(5, 5, [ gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1 ]), ) self.message_port_register_hier_out("pkt out") self.message_port_register_hier_out("precrc") ################################################## # Parameters ################################################## self.eb = eb self.hdr_const = hdr_const self.hdr_dec = hdr_dec self.hdr_format = hdr_format self.pld_const = pld_const self.pld_dec = pld_dec self.psf_taps = psf_taps self.sps = sps ################################################## # Variables ################################################## self.preamble_rep = preamble_rep = [ 0xe3, 0x8f, 0xc0, 0xfc, 0x7f, 0xc7, 0xe3, 0x81, 0xc0, 0xff, 0x80, 0x38, 0xff, 0xf0, 0x38, 0xe0, 0x0f, 0xc0, 0x03, 0x80, 0x00, 0xff, 0xff, 0xc0 ] self.preamble_dummy = preamble_dummy = [ 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc ] self.preamble_select = preamble_select = { 1: preamble_dummy, 3: preamble_rep } self.rxmod = rxmod = digital.generic_mod(hdr_const, False, sps, True, eb, False, False) self.preamble = preamble = preamble_select[int(1.0 / hdr_dec.rate())] self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119] self.nfilts = nfilts = 32 self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc( rxmod.to_basic_block(), preamble, [1]) self.mark_delay = mark_delay = mark_delays[sps] ################################################## # Blocks ################################################## self.fec_generic_decoder_0 = fec.decoder(hdr_dec, gr.sizeof_float, gr.sizeof_char) self.fec_async_decoder_0 = fec.async_decoder(pld_dec, True, False, 1500 * 8) self.digital_protocol_parser_b_0 = digital.protocol_parser_b( hdr_format) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 400.0, psf_taps, nfilts, nfilts / 2, 1.5, 1) self.digital_header_payload_demux_0 = digital.header_payload_demux( (hdr_format.header_nbits() * int(1.0 / hdr_dec.rate())) // hdr_const.bits_per_symbol(), 1, 0, "payload symbols", "time_est", True, gr.sizeof_gr_complex, "rx_time", 1, "", 0) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc( 6.28 / 200.0, pld_const.arity(), False) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 200.0, hdr_const.arity(), False) self.digital_corr_est_cc_0 = digital.corr_est_cc( modulated_sync_word, sps, mark_delay, 0.999, digital.THRESHOLD_ABSOLUTE) self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf( hdr_const) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf( pld_const) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.float_t, "payload symbols") self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_float * 1, "payload symbols", pld_const.bits_per_symbol()) self.blocks_multiply_by_tag_value_cc_0 = blocks.multiply_by_tag_value_cc( "amp_est", 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.fec_async_decoder_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self, 'pkt out')) self.msg_connect((self.digital_protocol_parser_b_0, 'info'), (self.digital_header_payload_demux_0, 'header_data')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self, 'precrc')) self.connect((self.blocks_multiply_by_tag_value_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0_0, 0), (self.fec_generic_decoder_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_multiply_by_tag_value_cc_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self, 4)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_soft_decoder_cf_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self, 2)) self.connect((self.digital_header_payload_demux_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self, 1)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self, 3)) self.connect((self.fec_generic_decoder_0, 0), (self.digital_protocol_parser_b_0, 0)) self.connect((self, 0), (self.digital_corr_est_cc_0, 0))
def __init__(self, freq): gr.top_block.__init__(self, "Burst Transmitter") ################################################## # Variables ################################################## self.tsh = tsh = 0 self.sps = sps = 4 self.nfilts = nfilts = 64 self.eb = eb = .700 self.usrp_rate = usrp_rate = 500e3 self.psf_taps = psf_taps = firdes.root_raised_cosine( nfilts / 1.5, nfilts, 1.0, eb, 5 * sps * nfilts) self.pld_cons = pld_cons = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 4, 1).base() self.hdr_cons = hdr_cons = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.freq = freq self.format_0 = format_0 = digital.header_format_default( digital.packet_utils.default_access_code, tsh) self.b_ntaps = b_ntaps = 50 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_samp_rate(usrp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps, taps=(psf_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, usrp_rate, usrp_rate / sps * 1.4, 10e3, firdes.WIN_KAISER, 6.76)) self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async( format_0) self.digital_map_bb_0_0 = digital.map_bb((pld_cons.pre_diff_code())) self.digital_map_bb_0 = digital.map_bb((hdr_cons.pre_diff_code())) self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb( pld_cons.arity()) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_cons.points()), pld_cons.dimensionality()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (hdr_cons.points()), hdr_cons.dimensionality()) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc( (firdes.window(firdes.WIN_HANN, b_ntaps, 0)), 10, 20, True, "packet_len") self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, "packet_len", 0) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", sps) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '52001', 10000, False) self.blocks_repack_bits_bb_2 = blocks.repack_bits_bb( 8, 1, "packet_len", False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 8, 1, "packet_len", False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.digital_protocol_formatter_async_0, 'in')) self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.blocks_pdu_to_tagged_stream_1_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_repack_bits_bb_2, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_2, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_burst_shaper_xx_0, 0)) self.connect((self.digital_burst_shaper_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_diff_encoder_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.digital_diff_encoder_bb_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
def __init__(self, hdr_const=digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base(), hdr_enc=fec.dummy_encoder_make(8000), hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0), pld_const=digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base(), pld_enc=fec.dummy_encoder_make(8000), psf_taps=[ 0, ], sps=2): gr.hier_block2.__init__( self, "Packet Tx", gr.io_signature(0, 0, 0), gr.io_signaturev(3, 3, [ gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1 ]), ) self.message_port_register_hier_in("in") self.message_port_register_hier_out("postcrc") ################################################## # Parameters ################################################## self.hdr_const = hdr_const self.hdr_enc = hdr_enc self.hdr_format = hdr_format self.pld_const = pld_const self.pld_enc = pld_enc self.psf_taps = psf_taps self.sps = sps ################################################## # Variables ################################################## self.nfilts = nfilts = 32 self.taps_per_filt = taps_per_filt = len(psf_taps) / nfilts self.filt_delay = filt_delay = int(1 + (taps_per_filt - 1) // 2) ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps, taps=psf_taps, flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.fec_async_encoder_0_0 = fec.async_encoder(hdr_enc, True, False, False, 1500) self.fec_async_encoder_0 = fec.async_encoder(pld_enc, True, False, False, 1500) self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async( hdr_format) self.digital_map_bb_1_0 = digital.map_bb(pld_const.pre_diff_code()) self.digital_map_bb_1 = digital.map_bb(hdr_const.pre_diff_code()) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( pld_const.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( hdr_const.points(), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, 'packet_len', 0) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, 'packet_len', sps) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, pld_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, hdr_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') ################################################## # Connections ################################################## self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.fec_async_encoder_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self, 'postcrc')) self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.fec_async_encoder_0_0, 'in')) self.msg_connect((self.fec_async_encoder_0, 'out'), (self.digital_protocol_formatter_async_0, 'in')) self.msg_connect((self.fec_async_encoder_0_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self, 'in'), (self.digital_crc32_async_bb_1, 'in')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self, 1)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self, 2)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_map_bb_1, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
def __init__(self): gr.top_block.__init__(self, "Fer Bpsk Rs Tx Verification") Qt.QWidget.__init__(self) self.setWindowTitle("Fer Bpsk Rs Tx Verification") 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", "fer_bpsk_rs_tx_verification") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 500e3 self.sps = sps = 4 self.value = value = [0, 1] self.symbol = symbol = [-1, 1] self.scramble = scramble = 0 self.samp_rate = samp_rate = symbol_rate * sps self.rs = rs = 1 self.reset = reset = 500 self.nTaps = nTaps = 10 * sps self.nFrames = nFrames = 10000000 self.linecode = linecode = 0 self.intDepth = intDepth = 1 self.frame_size = frame_size = 40 self.cfo = cfo = 0.0 self.bn = bn = 0.07 self.SNR = SNR = 1000 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:B", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(72e6, 0) self.uhd_usrp_sink_0.set_gain(35, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.tdd_ferMsgCount_0 = tdd.ferMsgCount(1) self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len", True) self.digital_crc32_async_bb_1_0 = digital.crc32_async_bb(True) self.ccsds_genCADU_0 = ccsds.genCADU(frame_size + 4, '1ACFFC1D', scramble, rs, intDepth, "frame_len") self.bpsk_bpskPulseshapeRRC_0 = bpsk.bpskPulseshapeRRC( sps, 1, samp_rate, samp_rate / sps, 0.35, nTaps) self.bpsk_bpskIQMap_0 = bpsk.bpskIQMap() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'frame_len') self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, frame_size + 4, 'frame_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, frame_size, "packet_len") self.blocks_message_debug_0 = blocks.message_debug() self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, frame_size)), True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_1_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1_0, 'out'), (self.tdd_ferMsgCount_0, 'in')) self.msg_connect((self.tdd_ferMsgCount_0, 'out'), (self.blocks_message_debug_0, 'store')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.ccsds_genCADU_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.bpsk_bpskPulseshapeRRC_0, 0)) self.connect((self.bpsk_bpskIQMap_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.bpsk_bpskPulseshapeRRC_0, 0), (self.bpsk_bpskIQMap_0, 0)) self.connect((self.ccsds_genCADU_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_stream_to_tagged_stream_1, 0))
def __init__(self): gr.top_block.__init__(self, "Basic Stream") Qt.QWidget.__init__(self) self.setWindowTitle("Basic Stream") 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", "basic_stream") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.noise = noise = -3.0 self.hdr_format = hdr_format = digital.header_format_default(digital.packet_utils.default_access_code, 0) self.enc = enc = fec.cc_encoder_make(8192, 7, 2, ([109,79]), 0, fec.CC_TERMINATED, False) self.dec = dec = fec.cc_decoder.make(8192, 7, 2, ([109,79]), 0, -1, fec.CC_TERMINATED, False) self.const = const = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self._noise_range = Range(-30.0, 3.0, 1.0, -3.0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.fec_async_encoder_0 = fec.async_encoder(enc, True, False, False, 1500) self.fec_async_decoder_0 = fec.async_decoder(dec, True, False, 1500) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(True) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(const) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([-1,1]), 1) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.float_t, 'packet_len') self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, 'packet_len', False, gr.GR_MSB_FIRST) self.blocks_random_pdu_0 = blocks.random_pdu(10, 400, chr(0xFF), 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 500) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, pow(10.0,noise/10.0), 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.fec_async_decoder_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.fec_async_encoder_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self.digital_crc32_async_bb_1, 'in')) self.msg_connect((self.fec_async_encoder_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_soft_decoder_cf_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_constellation_soft_decoder_cf_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
def __init__(self): gr.top_block.__init__(self, "LECIM DSSS Loopback Test") Qt.QWidget.__init__(self) self.setWindowTitle("LECIM DSSS Loopback Test") 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", "loopback_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Blocks ################################################## self.lpwan_dsss_oqpsk_phy_0 = lpwan_dsss_oqpsk_phy( burst_tag="burst", chiprate=2000000, data_seed_rx=2345432, data_seed_tx=2345432, fec_tailbiting=True, max_freq_hypo=2000, ovsf_code_index=0, ovsf_spreading_factor=0, preamble_len=32, preamble_seed_rx=54321, preamble_seed_tx=54321, psdu_len=32, roll_off=1, sfd_present=False, spread_factor=2**8, sps=4, ) self.digital_crc32_async_bb_0_0 = digital.crc32_async_bb(True) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=2, frequency_offset=0.0001, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_random_pdu_0 = blocks.random_pdu(28, 28, chr(0xFF), 1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("generate"), 140) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.lpwan_dsss_oqpsk_phy_0, 'in_tx')) self.msg_connect((self.digital_crc32_async_bb_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lpwan_dsss_oqpsk_phy_0, 'out_rx'), (self.digital_crc32_async_bb_0_0, 'in')) self.connect((self.channels_channel_model_0, 0), (self.lpwan_dsss_oqpsk_phy_0, 0)) self.connect((self.lpwan_dsss_oqpsk_phy_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "Shipping Passing App") Qt.QWidget.__init__(self) self.setWindowTitle("Shipping Passing App") 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", "audioTxRx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.msg_str = msg_str = "CSQ305438" self.QPSK = QPSK = digital.constellation_calcdist( ([1 + 1j, -1 + 1j, 1 - 1j, -1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self._msg_str_tool_bar = Qt.QToolBar(self) self._msg_str_tool_bar.addWidget(Qt.QLabel("msg_str" + ": ")) self._msg_str_line_edit = Qt.QLineEdit(str(self.msg_str)) self._msg_str_tool_bar.addWidget(self._msg_str_line_edit) self._msg_str_line_edit.returnPressed.connect(lambda: self.set_msg_str( str(str(self._msg_str_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._msg_str_tool_bar) self.tutorial_my_qpsk_demod_cb_0 = tutorial.my_qpsk_demod_cb(True) self.tutorial_chat_sanitizer_0 = tutorial.chat_sanitizer('', '') self.gnuShipping_shippingReciever_0 = gnuShipping.shippingReciever( msg_str) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( 1, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (QPSK.points()), 1) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'pdu_length') self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 2, 8, 'pdu_length', True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, 2, 'pdu_length', False, gr.GR_LSB_FIRST) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'pdu_length') self.blocks_message_debug_0 = blocks.message_debug() self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( False, False) self.blocks_float_to_short_0 = blocks.float_to_short(1, 1) self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short( False) self.audio_source_0 = audio.source(samp_rate, '', True) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.gnuShipping_shippingReciever_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.tutorial_chat_sanitizer_0, 'out'), (self.digital_crc32_async_bb_1, 'in')) self.connect((self.audio_source_0, 0), (self.blocks_float_to_short_0, 0)) self.connect((self.blocks_complex_to_interleaved_short_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_float_to_short_0, 0), (self.blocks_interleaved_short_to_complex_0, 0)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_complex_to_interleaved_short_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.tutorial_my_qpsk_demod_cb_0, 0)) self.connect((self.tutorial_my_qpsk_demod_cb_0, 0), (self.blocks_throttle_0_0, 0))