Exemple #1
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_decision")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_decision")
        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", "Test_decision")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 320000
        self.develop_mode_list = develop_mode_list = [1, 3, 4, 14, 21, 22]

        ##################################################
        # Blocks
        ##################################################
        self.inets_null_message_source_0 = inets.null_message_source()
        self.inets_decision_cpp_0 = inets.decision_cpp((develop_mode_list), 14)
        self.inets_counter_0_0 = inets.counter(1, 22, 1)
        self.inets_counter_0 = inets.counter(1, 21, 1)
        self.blocks_message_strobe_random_0_0 = blocks.message_strobe_random(
            pmt.from_bool(False), blocks.STROBE_POISSON, 2000, 500)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 3000, 500)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'),
                         (self.inets_decision_cpp_0, 'spark_in'))
        self.msg_connect((self.blocks_message_strobe_random_0_0, 'strobe'),
                         (self.inets_decision_cpp_0, 'spark_in'))
        self.msg_connect((self.inets_decision_cpp_0, 'spark_out_t'),
                         (self.inets_counter_0, 'message_in'))
        self.msg_connect((self.inets_decision_cpp_0, 'spark_out_f'),
                         (self.inets_counter_0_0, 'message_in'))
        self.msg_connect(
            (self.inets_null_message_source_0, 'null_message_out'),
            (self.inets_decision_cpp_0, 'spark_in'))
Exemple #2
0
    def __init__(self):
        gr.top_block.__init__(self, "Hdlc Frame")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Hdlc Frame")
        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", "hdlc_Frame")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.message = message = 'a', 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0

        ##################################################
        # Blocks
        ##################################################
        self.satellites_pdu_to_kiss_0 = satellites.pdu_to_kiss()
        self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '',
                                                       False, False, '')
        self._qtgui_edit_box_msg_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len')
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(32, 500)
        self.blocks_random_pdu_0 = blocks.random_pdu(16, 64, chr(0xFF), 2)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(
            pmt.intern("TEST"), blocks.STROBE_POISSON, 10000, 500)
        self.blocks_message_debug_1 = blocks.message_debug()
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'),
                         (self.blocks_random_pdu_0, 'generate'))
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'),
                         (self.satellites_pdu_to_kiss_0, 'in'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.satellites_pdu_to_kiss_0, 'out'),
                         (self.digital_hdlc_framer_pb_0, 'in'))
        self.connect((self.digital_hdlc_framer_pb_0, 0),
                     (self.digital_hdlc_deframer_bp_0, 0))
Exemple #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Test Tx buffer function")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test Tx buffer function")
        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", "Test_tx_buff")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.max_buffer_size = max_buffer_size = 5
        self.develop_mode_list = develop_mode_list = [1, 2, 3, 4, 5, 6]

        ##################################################
        # Blocks
        ##################################################
        self.inets_tx_buffer_0 = inets.tx_buffer((develop_mode_list),
                                                 max_buffer_size, 1)
        self.inets_message_tomb_0 = inets.message_tomb()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost',
                                                     '52001', 10000, False)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2500, 100)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'),
                         (self.inets_tx_buffer_0, 'spark_in'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_tx_buffer_0, 'payload_in'))
        self.msg_connect((self.inets_tx_buffer_0, 'payload_out'),
                         (self.inets_message_tomb_0, 'message_in'))
Exemple #4
0
    def test_34(self):
        """
        Test case generated by test-case generator
        """
        ##################################################
        # Variables
        ##################################################
        # Input data into the system
        src_data = "PKdhtXMmr18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1yhc3uavuaOb9vyJ"
        self.bw = bw = 250000
        self.sf = sf = 8
        self.samp_rate = samp_rate = 250000
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 2
        self.impl_head = impl_head = False
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 7

        ##################################################
        # Blocks
        ##################################################
        # Tx side
        self.lora_sdr_whitening_0 = lora_sdr.whitening()
        self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
        self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
        self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
        self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
        self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
        self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
        self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source(
            pay_len, n_frame, src_data)
        self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random(
            pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)
        # Rx side
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=4, decimation=1, taps=None, fractional_bw=None)
        self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
            impl_head, cr, pay_len, has_crc)
        self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
        self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
        self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf,
                                                       impl_head)
        self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
        self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf)
        self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)

        ##################################################
        # Connections
        ##################################################
        # Tx side
        self.tb.msg_connect(
            (self.blocks_message_strobe_random_0_1_0, 'strobe'),
            (self.lora_sdr_data_source_0_1_0, 'trigg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_add_crc_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_header_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_interleaver_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_modulate_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_whitening_0, 'msg'))
        self.tb.connect((self.lora_sdr_add_crc_0, 0),
                        (self.lora_sdr_hamming_enc_0, 0))
        self.tb.connect((self.lora_sdr_gray_decode_0, 0),
                        (self.lora_sdr_modulate_0, 0))
        self.tb.connect((self.lora_sdr_hamming_enc_0, 0),
                        (self.lora_sdr_interleaver_0, 0))
        self.tb.connect((self.lora_sdr_header_0, 0),
                        (self.lora_sdr_add_crc_0, 0))
        self.tb.connect((self.lora_sdr_interleaver_0, 0),
                        (self.lora_sdr_gray_decode_0, 0))
        self.tb.connect((self.lora_sdr_whitening_0, 0),
                        (self.lora_sdr_header_0, 0))
        self.tb.connect((self.lora_sdr_modulate_0, 0),
                        (self.blocks_throttle_0, 0))
        # Rx side

        self.tb.connect((self.blocks_throttle_0, 0),
                        (self.rational_resampler_xxx_0, 0))
        self.tb.msg_connect((self.lora_sdr_crc_verif_0, 'msg'),
                            (self.blocks_message_debug_0, 'store'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_deinterleaver_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_dewhitening_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_fft_demod_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_hamming_dec_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_header_decoder_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                            (self.lora_sdr_crc_verif_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                            (self.lora_sdr_crc_verif_0, 'CRC'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_deinterleaver_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                            (self.lora_sdr_dewhitening_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                            (self.lora_sdr_dewhitening_0, 'CRC'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_fft_demod_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_frame_sync_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'err'),
                            (self.lora_sdr_frame_sync_0, 'err'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                            (self.lora_sdr_frame_sync_0, 'crc'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                            (self.lora_sdr_frame_sync_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_hamming_dec_0, 'CR'))
        self.tb.connect((self.lora_sdr_deinterleaver_0, 0),
                        (self.lora_sdr_hamming_dec_0, 0))
        self.tb.connect((self.lora_sdr_dewhitening_0, 0),
                        (self.lora_sdr_crc_verif_0, 0))
        self.tb.connect((self.lora_sdr_fft_demod_0, 0),
                        (self.lora_sdr_gray_enc_0, 0))
        self.tb.connect((self.lora_sdr_frame_sync_0, 0),
                        (self.lora_sdr_fft_demod_0, 0))
        self.tb.connect((self.lora_sdr_gray_enc_0, 0),
                        (self.lora_sdr_deinterleaver_0, 0))
        self.tb.connect((self.lora_sdr_hamming_dec_0, 0),
                        (self.lora_sdr_header_decoder_0, 0))
        self.tb.connect((self.lora_sdr_header_decoder_0, 0),
                        (self.lora_sdr_dewhitening_0, 0))
        self.tb.connect((self.rational_resampler_xxx_0, 0),
                        (self.lora_sdr_frame_sync_0, 0))

        # run the flowgraph, since we use a message strobe we have to run and stop the flowgraph with some computation time inbetween
        self.tb.start()
        time.sleep(10)
        self.tb.stop()
        self.tb.wait()
        # try to get get the message from the store port of the message debug printer and convert to string from pmt message
        try:
            msg = pmt.symbol_to_string(
                self.blocks_message_debug_0.get_message(0))
        except:
            # if not possible set message to be None
            msg = None

        # check if message received is the same as the message decoded
        self.assertMultiLineEqual(
            src_data,
            msg,
            msg="Error decoded data {0} is not the same as input data {1}".
            format(msg, src_data))
Exemple #5
0
    def __init__(self):
        gr.top_block.__init__(self, "Tx Rx")

        ##################################################
        # Variables
        ##################################################
        self.bw = bw = 250000
        self.sf = sf = 7
        self.samp_rate = samp_rate = bw
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 200
        self.mult_const = mult_const = 1
        self.impl_head = impl_head = True
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 0
        self.TX_gain = TX_gain = 3

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr0=192.168.10.2,addr1=192.168.10.3", '')),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 2)),
            ),
        )
        self.uhd_usrp_source_0.set_time_source('mimo', 1)
        self.uhd_usrp_source_0.set_clock_source('mimo', 1)
        self.uhd_usrp_source_0.set_center_freq(0, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_center_freq(915e6, 1)
        self.uhd_usrp_source_0.set_gain(31.5, 1)
        self.uhd_usrp_source_0.set_antenna('RX2', 1)
        self.uhd_usrp_source_0.set_bandwidth(bw, 1)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr0=192.168.10.2,addr1=192.168.10.3", '')),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            '',
        )
        self.uhd_usrp_sink_0.set_center_freq(915e6, 0)
        self.uhd_usrp_sink_0.set_gain(TX_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(bw, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.lora_sdr_whitening_0 = lora_sdr.whitening()
        self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
        self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
        self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
        self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
            impl_head, cr, pay_len, has_crc)
        self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
        self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
        self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
        self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
        self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
        self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf,
                                                       impl_head)
        self.lora_sdr_err_measures_0 = lora_sdr.err_measures()
        self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
        self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf)
        self.lora_sdr_data_source_0 = lora_sdr.data_source(pay_len, n_frame)
        self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif()
        self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccf(
            4, -0.128616616593872, -0.212206590789194, -0.180063263231421,
            3.89817183251938e-17, 0.300105438719035, 0.636619772367581,
            0.900316316157106, 1, 0.900316316157106, 0.636619772367581,
            0.300105438719035, 3.89817183251938e-17, -0.180063263231421,
            -0.212206590789194, -0.128616616593872)
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(mult_const)
        self.blocks_multiply_const_vxx_0.set_min_output_buffer(10000000)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(
            pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'),
                         (self.lora_sdr_data_source_0, 'trigg'))
        self.msg_connect((self.lora_sdr_crc_verif_0, 'msg'),
                         (self.lora_sdr_err_measures_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0, 'msg'),
                         (self.lora_sdr_add_crc_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0, 'msg'),
                         (self.lora_sdr_err_measures_0, 'ref'))
        self.msg_connect((self.lora_sdr_data_source_0, 'msg'),
                         (self.lora_sdr_header_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0, 'msg'),
                         (self.lora_sdr_interleaver_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0, 'msg'),
                         (self.lora_sdr_modulate_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0, 'msg'),
                         (self.lora_sdr_whitening_0, 'msg'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_deinterleaver_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_dewhitening_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_fft_demod_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_hamming_dec_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_header_decoder_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_crc_verif_0, 'CRC'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_crc_verif_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_deinterleaver_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_dewhitening_0, 'CRC'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_dewhitening_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_fft_demod_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_frame_sync_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_frame_sync_0, 'crc'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_frame_sync_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'err'),
                         (self.lora_sdr_frame_sync_0, 'err'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_hamming_dec_0, 'CR'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.lora_sdr_frame_sync_0, 0))
        self.connect((self.lora_sdr_add_crc_0, 0),
                     (self.lora_sdr_hamming_enc_0, 0))
        self.connect((self.lora_sdr_deinterleaver_0, 0),
                     (self.lora_sdr_hamming_dec_0, 0))
        self.connect((self.lora_sdr_dewhitening_0, 0),
                     (self.lora_sdr_crc_verif_0, 0))
        self.connect((self.lora_sdr_fft_demod_0, 0),
                     (self.lora_sdr_gray_enc_0, 0))
        self.connect((self.lora_sdr_frame_sync_0, 0),
                     (self.lora_sdr_fft_demod_0, 0))
        self.connect((self.lora_sdr_gray_decode_0, 0),
                     (self.lora_sdr_modulate_0, 0))
        self.connect((self.lora_sdr_gray_enc_0, 0),
                     (self.lora_sdr_deinterleaver_0, 0))
        self.connect((self.lora_sdr_hamming_dec_0, 0),
                     (self.lora_sdr_header_decoder_0, 0))
        self.connect((self.lora_sdr_hamming_enc_0, 0),
                     (self.lora_sdr_interleaver_0, 0))
        self.connect((self.lora_sdr_header_0, 0), (self.lora_sdr_add_crc_0, 0))
        self.connect((self.lora_sdr_header_decoder_0, 0),
                     (self.lora_sdr_dewhitening_0, 0))
        self.connect((self.lora_sdr_interleaver_0, 0),
                     (self.lora_sdr_gray_decode_0, 0))
        self.connect((self.lora_sdr_modulate_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.lora_sdr_whitening_0, 0),
                     (self.lora_sdr_header_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 1),
                     (self.interp_fir_filter_xxx_0, 0))
Exemple #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Sim Lor")

        self._lock = threading.RLock()

        ##################################################
        # Variables
        ##################################################
        self.bw = bw = 250000
        self.sf = sf = 7
        self.samp_rate = samp_rate = bw
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 5
        self.mult_const = mult_const = 1
        self.impl_head = impl_head = True
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 0

        ##################################################
        # Blocks
        ##################################################
        self.lora_sdr_whitening_0 = lora_sdr.whitening()
        self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
        self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
        self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
        self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
            impl_head, cr, pay_len, has_crc)
        self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
        self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
        self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
        self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
        self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
        self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf,
                                                       impl_head)
        self.lora_sdr_err_measures_0 = lora_sdr.err_measures()
        self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
        self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf)
        self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source(
            pay_len, n_frame, '')
        self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif()
        self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccf(
            4, (-0.128616616593872, -0.212206590789194, -0.180063263231421,
                3.89817183251938e-17, 0.300105438719035, 0.636619772367581,
                0.900316316157106, 1, 0.900316316157106, 0.636619772367581,
                0.300105438719035, 3.89817183251938e-17, -0.180063263231421,
                -0.212206590789194, -0.128616616593872))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random(
            pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)
        self.blocks_message_debug_1 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0_1_0, 'strobe'),
                         (self.lora_sdr_data_source_0_1_0, 'trigg'))
        self.msg_connect((self.lora_sdr_crc_verif_0, 'msg'),
                         (self.lora_sdr_err_measures_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_add_crc_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_err_measures_0, 'ref'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_header_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_interleaver_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_modulate_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_whitening_0, 'msg'))
        self.msg_connect((self.lora_sdr_err_measures_0, 'err'),
                         (self.blocks_message_debug_1, 'print'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_deinterleaver_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_dewhitening_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_fft_demod_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_hamming_dec_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_header_decoder_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_crc_verif_0, 'CRC'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_crc_verif_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_deinterleaver_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_dewhitening_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_dewhitening_0, 'CRC'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_fft_demod_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_frame_sync_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_frame_sync_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_frame_sync_0, 'crc'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'err'),
                         (self.lora_sdr_frame_sync_0, 'err'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_hamming_dec_0, 'CR'))
        self.connect((self.blocks_throttle_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.lora_sdr_frame_sync_0, 0))
        self.connect((self.lora_sdr_add_crc_0, 0),
                     (self.lora_sdr_hamming_enc_0, 0))
        self.connect((self.lora_sdr_deinterleaver_0, 0),
                     (self.lora_sdr_hamming_dec_0, 0))
        self.connect((self.lora_sdr_dewhitening_0, 0),
                     (self.lora_sdr_crc_verif_0, 0))
        self.connect((self.lora_sdr_fft_demod_0, 0),
                     (self.lora_sdr_gray_enc_0, 0))
        self.connect((self.lora_sdr_frame_sync_0, 0),
                     (self.lora_sdr_fft_demod_0, 0))
        self.connect((self.lora_sdr_gray_decode_0, 0),
                     (self.lora_sdr_modulate_0, 0))
        self.connect((self.lora_sdr_gray_enc_0, 0),
                     (self.lora_sdr_deinterleaver_0, 0))
        self.connect((self.lora_sdr_hamming_dec_0, 0),
                     (self.lora_sdr_header_decoder_0, 0))
        self.connect((self.lora_sdr_hamming_enc_0, 0),
                     (self.lora_sdr_interleaver_0, 0))
        self.connect((self.lora_sdr_header_0, 0), (self.lora_sdr_add_crc_0, 0))
        self.connect((self.lora_sdr_header_decoder_0, 0),
                     (self.lora_sdr_dewhitening_0, 0))
        self.connect((self.lora_sdr_interleaver_0, 0),
                     (self.lora_sdr_gray_decode_0, 0))
        self.connect((self.lora_sdr_modulate_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.lora_sdr_whitening_0, 0),
                     (self.lora_sdr_header_0, 0))
Exemple #7
0
    def __init__(self):
        gr.top_block.__init__(self, "aloha")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("aloha")
        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", "aloha")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 5
        self.range_mu = range_mu = 0.6
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.6"
        self.timeout_duration_ms = timeout_duration_ms = 500
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.self_ack_info = self_ack_info = pmt.to_pmt({
            'frame_type': 2,
            'frame_index': 1,
            'destination_address': 2,
            'source_address': 1,
            'num_resend': 0,
            'reserved_field_I': 1,
            'reserved_field_II': 1,
            'pay_load_length': 0
        })
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = range_rx_gain

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps)

        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.preamble_detector_threshold = preamble_detector_threshold = 30
        self.mu = mu = range_mu
        self.min_backoff_ms = min_backoff_ms = 50
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        self.diff_preamble_128 = diff_preamble_128 = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ][0:128]
        self.develop_mode_list = develop_mode_list = [0]
        self.destination_address = destination_address = 2
        self.cs_threshold = cs_threshold = 0.005
        self.cs_duration = cs_duration = 1000
        self.counter_id = counter_id = 20
        self.backoff_time_unit_ms = backoff_time_unit_ms = 50
        self.apply_address_check = apply_address_check = 1
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'good_frame':
            1,
            'address_check':
            1,
            'header_length':
            9,
            'payload_length':
            0,
            'reserved_field_II':
            6,
            'reserved_field_I':
            5,
            'num_transmission':
            0,
            'source_address':
            1,
            'destination_address':
            3,
            'frame_index':
            22,
            'frame_type':
            1
        })

        ##################################################
        # Blocks
        ##################################################
        self.send_frame_0 = send_frame(
            block_id=2,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=1,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
            usrp_device_address=usrp_device_address,
        )
        self.receive_frame_0_0 = receive_frame(
            apply_address_check=apply_address_check,
            block_id=3,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=[11],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=source_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
            usrp_device_address=usrp_device_address,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 5, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range,
                                              self.set_range_rx_gain,
                                              'Rx Gain', "counter_slider",
                                              float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range,
                                         self.set_range_mu,
                                         'BB Derotation Gain',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1)
        self.inets_timeout_cpp_0 = inets.timeout_cpp(
            0, 10, timeout_duration_ms, system_time_granularity_us)
        self.inets_idle_0 = inets.idle(
            0, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.inets_frame_info_selector_0_0_0 = inets.frame_info_selector()
        self.inets_frame_info_selector_0_0 = inets.frame_info_selector()
        self.inets_frame_info_selector_0 = inets.frame_info_selector()
        self.inets_exponential_backoff_cpp_0 = inets.exponential_backoff_cpp(
            0, 11, backoff_time_unit_ms, max_num_retransmission,
            min_backoff_ms)
        self.inets_counter_0_1 = inets.counter(([22]), 22)
        self.frame_info_simulator = blocks.message_strobe_random(
            pmt.to_pmt({
                'good_frame': 1,
                'address_check': 1,
                'header_length': 9,
                'payload_length': 0,
                'reserved_field_II': 6,
                'reserved_field_I': 5,
                'num_transmission': 0,
                'source_address': 1,
                'destination_address': 3,
                'frame_index': 22,
                'frame_type': 1
            }), blocks.STROBE_POISSON, 2000, 1000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost',
                                                     '52001', 10000, False)
        self.blocks_message_strobe_random_1 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 5)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect(
            (self.inets_exponential_backoff_cpp_0, 'frame_info_out'),
            (self.inets_idle_0, 'data_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0, 'data_frame_info_out'),
            (self.inets_idle_0, 'data_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0, 'ack_frame_info_out'),
            (self.inets_timeout_cpp_0, 'ack_frame_info_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0_0, 'data_frame_info_out'),
            (self.inets_timeout_cpp_0, 'data_frame_info_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0_0_0, 'data_frame_info_out'),
            (self.inets_exponential_backoff_cpp_0, 'frame_info_trigger_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0_0_0, 'ack_frame_info_out'),
            (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_counter_0_1, 'message_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.send_frame_0, 'in'))
        self.msg_connect(
            (self.inets_timeout_cpp_0, 'frame_info_out'),
            (self.inets_frame_info_selector_0_0_0, 'frame_info_in'))
        self.msg_connect((self.receive_frame_0_0, 'rx_frame_info_out'),
                         (self.inets_frame_info_selector_0, 'frame_info_in'))
        self.msg_connect((self.send_frame_0, 'tx_frame_info_out'),
                         (self.inets_frame_info_selector_0_0, 'frame_info_in'))
 ##################################################
 # Blocks
 ##################################################
 # Tx side
 self.lora_sdr_whitening_0 = lora_sdr.whitening()
 self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
 self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
 self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
 self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
 self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
 self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
 self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source(
     pay_len, n_frame, src_data)
 self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
 self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
 self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random(
     pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)
 # Rx side
 self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
     interpolation=4,
     decimation=1,
     taps=None,
     fractional_bw=None)
 self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
     impl_head, cr, pay_len, has_crc)
 self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
 self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
 self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
     samp_rate, bw, sf, impl_head)
 self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(
     samp_rate, bw, sf, impl_head)
 self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
Exemple #9
0
    def __init__(self):
        gr.top_block.__init__(self, "Sim Lor")

        self._lock = threading.RLock()

        ##################################################
        # Variables
        ##################################################
        self.bw = bw = 250000
        self.sf = sf = 7
        self.samp_rate = samp_rate = bw
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 8
        self.mult_const = mult_const = 1
        self.impl_head = impl_head = True
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 0

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=4, decimation=1, taps=None, fractional_bw=None)
        self.lora_sdr_whitening_0 = lora_sdr.whitening()
        self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
        self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
        self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
        self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
            impl_head, cr, pay_len, has_crc)
        self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
        self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
        self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
        self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
        self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
        self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf,
                                                       impl_head)
        self.lora_sdr_err_measures_0 = lora_sdr.err_measures()
        self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
        self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf)
        self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source(
            pay_len, n_frame, '')
        self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif()
        self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random(
            pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0_1_0, 'strobe'),
                         (self.lora_sdr_data_source_0_1_0, 'trigg'))
        self.msg_connect((self.lora_sdr_crc_verif_0, 'msg'),
                         (self.lora_sdr_err_measures_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_add_crc_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_err_measures_0, 'ref'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_header_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_interleaver_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_modulate_0, 'msg'))
        self.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                         (self.lora_sdr_whitening_0, 'msg'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_deinterleaver_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_dewhitening_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_fft_demod_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_hamming_dec_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                         (self.lora_sdr_header_decoder_0, 'new_frame'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_crc_verif_0, 'CRC'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_crc_verif_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_deinterleaver_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_dewhitening_0, 'CRC'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_dewhitening_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_fft_demod_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                         (self.lora_sdr_frame_sync_0, 'crc'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'err'),
                         (self.lora_sdr_frame_sync_0, 'err'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_frame_sync_0, 'CR'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                         (self.lora_sdr_frame_sync_0, 'pay_len'))
        self.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                         (self.lora_sdr_hamming_dec_0, 'CR'))
        self.connect((self.blocks_throttle_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.lora_sdr_add_crc_0, 0),
                     (self.lora_sdr_hamming_enc_0, 0))
        self.connect((self.lora_sdr_deinterleaver_0, 0),
                     (self.lora_sdr_hamming_dec_0, 0))
        self.connect((self.lora_sdr_dewhitening_0, 0),
                     (self.lora_sdr_crc_verif_0, 0))
        self.connect((self.lora_sdr_fft_demod_0, 0),
                     (self.lora_sdr_gray_enc_0, 0))
        self.connect((self.lora_sdr_frame_sync_0, 0),
                     (self.lora_sdr_fft_demod_0, 0))
        self.connect((self.lora_sdr_gray_decode_0, 0),
                     (self.lora_sdr_modulate_0, 0))
        self.connect((self.lora_sdr_gray_enc_0, 0),
                     (self.lora_sdr_deinterleaver_0, 0))
        self.connect((self.lora_sdr_hamming_dec_0, 0),
                     (self.lora_sdr_header_decoder_0, 0))
        self.connect((self.lora_sdr_hamming_enc_0, 0),
                     (self.lora_sdr_interleaver_0, 0))
        self.connect((self.lora_sdr_header_0, 0), (self.lora_sdr_add_crc_0, 0))
        self.connect((self.lora_sdr_header_decoder_0, 0),
                     (self.lora_sdr_dewhitening_0, 0))
        self.connect((self.lora_sdr_interleaver_0, 0),
                     (self.lora_sdr_gray_decode_0, 0))
        self.connect((self.lora_sdr_modulate_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.lora_sdr_whitening_0, 0),
                     (self.lora_sdr_header_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.lora_sdr_frame_sync_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle_sendframe_receiveframe_idle")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle_sendframe_receiveframe_idle")
        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", "Test_idle_sendframe_receiveframe_idle")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 5
        self.range_mu = range_mu = 0.6
        self.timeout_duration_ms = timeout_duration_ms = 500
        self.system_time_granularity_us = system_time_granularity_us = 10000
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({'frame_type': 1, 'frame_index': 1, 'destination_address': 2, 'source_address': 1, 'num_resend': 3, 'reserved_field_I': 1, 'reserved_field_II': 1, 'pay_load_length': 200})
        self.self_ack_info = self_ack_info = pmt.to_pmt({'frame_type': 2, 'frame_index': 1, 'destination_address': 2, 'source_address': 1, 'num_resend': 0, 'reserved_field_I': 1, 'reserved_field_II': 1, 'pay_load_length': 0})
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.preamble_detector_threshold = preamble_detector_threshold = 30
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.develop_mode_list = develop_mode_list = [0]
        self.destination_address = destination_address = 3
        self.counter_id = counter_id = 20
        self.apply_address_check = apply_address_check = 1
        self.another_data_info = another_data_info = pmt.to_pmt({'frame_type': 1, 'frame_index': 1, 'destination_address': 1, 'source_address': 2, 'num_resend': 3, 'reserved_field_I': 1, 'reserved_field_II': 1, 'pay_load_length': 200})
        self.another_ack_info = another_ack_info = pmt.to_pmt({'good_frame' : 1, 'address_check' : 1, 'header_length' : 9, 'payload_length' : 0, 'reserved_field_II' : 6, 'reserved_field_I' : 5, 'num_transmission' : 0, 'source_address' : 1, 'destination_address': 3, 'frame_index' : 22, 'frame_type' : 1})

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr=10.0.0.6", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(4e8, 0)
        self.uhd_usrp_source_0_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("addr=10.0.0.13", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(4e8, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("addr=10.0.0.13", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(4e8, 0)
        self.uhd_usrp_sink_0_0.set_gain(0, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=10.0.0.6", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(4e8, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.send_frame_0_0 = send_frame(
            block_id=102,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=source_address,
            develop_mode=1,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=destination_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.send_frame_0 = send_frame(
            block_id=2,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode=1,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0_0 = receive_frame(
            apply_address_check=apply_address_check,
            block_id=3,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=[11],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=source_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            block_id=103,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=[11],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 5, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.inets_idle_0_0 = inets.idle(1, 100, experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, source_address, len_destination_address, destination_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.inets_idle_0 = inets.idle(2, 1, experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, destination_address, len_destination_address, source_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.inets_frame_info_selector_0 = inets.frame_info_selector()
        self.frame_info_simulator = blocks.message_strobe_random(pmt.to_pmt({'good_frame' : 1, 'address_check' : 1, 'header_length' : 9, 'payload_length' : 0, 'reserved_field_II' : 6, 'reserved_field_I' : 5, 'num_transmission' : 0, 'source_address' : 1, 'destination_address': 3, 'frame_index' : 22, 'frame_type' : 1}), blocks.STROBE_POISSON, 2000, 1000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False)
        self.blocks_message_strobe_random_1 = blocks.message_strobe_random(pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 5)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_frame_info_selector_0, 'data_frame_info_out'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_idle_0, 'data_out'), (self.send_frame_0, 'in'))    
        self.msg_connect((self.inets_idle_0_0, 'data_out'), (self.send_frame_0_0, 'in'))    
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'), (self.inets_idle_0_0, 'data_in'))    
        self.msg_connect((self.receive_frame_0_0, 'rx_frame_info_out'), (self.inets_frame_info_selector_0, 'frame_info_in'))    
        self.connect((self.send_frame_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.send_frame_0_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.receive_frame_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.receive_frame_0_0, 0))    
Exemple #11
0
    def __init__(self, apply_address_check=1, destination_address=3, frame_index=2, frame_type=1, increase_index=1, len_destination_address=1, len_frame_index=1, len_frame_type=1, len_payload_length=1, len_reserved_field_I=2, len_reserved_field_II=2, len_source_address=1, reserved_field_I=5, reserved_field_II=6, source_address=4, system_time_granularity_us=5):
        gr.top_block.__init__(self, "Test tx rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test tx 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", "Test_tx_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.apply_address_check = apply_address_check
        self.destination_address = destination_address
        self.frame_index = frame_index
        self.frame_type = frame_type
        self.increase_index = increase_index
        self.len_destination_address = len_destination_address
        self.len_frame_index = len_frame_index
        self.len_frame_type = len_frame_type
        self.len_payload_length = len_payload_length
        self.len_reserved_field_I = len_reserved_field_I
        self.len_reserved_field_II = len_reserved_field_II
        self.len_source_address = len_source_address
        self.reserved_field_I = reserved_field_I
        self.reserved_field_II = reserved_field_II
        self.source_address = source_address
        self.system_time_granularity_us = system_time_granularity_us

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 15
        self.range_mu = range_mu = 0.6
        self.threshold = threshold = 40
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_num_transmission = len_num_transmission = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.develop_mode_list = develop_mode_list = [0]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # 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, 'TX')
        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, 'RX')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Demod')
        self.top_layout.addWidget(self.tab)
        self.send_frame_0 = send_frame(
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode_list=develop_mode_list,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode_list=[10],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=30,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 15, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_noise_range = Range(0, 0.01, 0.00001, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, 'noise', "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.inets_null_message_source_0 = inets.null_message_source()
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle((develop_mode_list), experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, destination_address, len_destination_address, source_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(pmt.from_bool(True), blocks.STROBE_POISSON, 10000, 5000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_bool(True), 1000)
        self.blocks_message_debug_0_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'), (self.receive_frame_0, 'rx_switch_in'))    
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_idle_0, 'successful_transmission'), (self.inets_message_tomb_0, 'message_in'))    
        self.msg_connect((self.inets_idle_0, 'data_out'), (self.send_frame_0, 'in'))    
        self.msg_connect((self.inets_null_message_source_0, 'null_message_out'), (self.inets_idle_0, 'reset_idle'))    
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'), (self.blocks_message_debug_0_0, 'print'))    
        self.msg_connect((self.send_frame_0, 'tx_frame_info_out'), (self.inets_message_tomb_0, 'message_in'))    
        self.connect((self.send_frame_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.send_frame_0, 0), (self.receive_frame_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle_sendframe")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle_sendframe")
        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", "Test_idle_sendframe")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.self_ack_info = self_ack_info = pmt.to_pmt({
            'frame_type': 2,
            'frame_index': 1,
            'destination_address': 2,
            'source_address': 1,
            'num_resend': 0,
            'reserved_field_I': 1,
            'reserved_field_II': 1,
            'pay_load_length': 0
        })
        self.samp_rate = samp_rate = 1000000
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 0
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        self.develop_mode_list = develop_mode_list = [0]
        self.destination_address = destination_address = 3
        self.counter_id = counter_id = 20
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("addr=10.0.0.13", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(4e8, 0)
        self.uhd_usrp_sink_0_0.set_gain(0, 0)
        self.send_frame_0 = send_frame(
            block_id=2,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=3,
            develop_mode=1,
            frame_index=2,
            frame_type=1,
            increase_index=1,
            len_destination_address=1,
            len_frame_index=1,
            len_frame_type=1,
            len_payload_length=1,
            len_reserved_field_I=2,
            len_reserved_field_II=2,
            len_source_address=1,
            preamble=[],
            reserved_field_I=5,
            reserved_field_II=6,
            samp_rate=4e6,
            source_address=4,
            sps=4,
            system_time_granularity_us=10,
        )
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle(
            2, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.frame_info_simulator = blocks.message_strobe_random(
            another_ack_info, blocks.STROBE_POISSON, 4000, 2000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost",
                                                     "52001", 10000, False)
        self.blocks_message_strobe_random_0_0_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0_0_0, 'strobe'),
                         (self.inets_idle_0, 'reset_idle'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_message_tomb_0, 'message_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.send_frame_0, 'in'))
        self.connect((self.send_frame_0, 0), (self.uhd_usrp_sink_0_0, 0))
Exemple #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle")
        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", "Test_idle")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.samp_rate = samp_rate = 320000
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        self.develop_mode = develop_mode = 2
        self.destination_address = destination_address = 3
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.inets_null_message_source_0 = inets.null_message_source()
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle(
            2, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost',
                                                     '52001', 10000, False)
        self.blocks_message_strobe_random_0_0_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 0)
        self.blocks_message_strobe_random_0_0 = blocks.message_strobe_random(
            another_ack_info, blocks.STROBE_POISSON, 2000, 0)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_message_tomb_0, 'message_in'))
        self.msg_connect(
            (self.inets_null_message_source_0, 'null_message_out'),
            (self.inets_idle_0, 'reset_idle'))
Exemple #14
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_receive_ack")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_receive_ack")
        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", "Test_receive_ack")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 25
        self.range_mu = range_mu = 0.6
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.self_ack_info = self_ack_info = pmt.to_pmt({
            'frame_type': 2,
            'frame_index': 1,
            'destination_address': 2,
            'source_address': 1,
            'num_resend': 0,
            'reserved_field_I': 1,
            'reserved_field_II': 1,
            'pay_load_length': 0
        })
        self.samp_rate = samp_rate = 4000000
        self.rx_gain = rx_gain = range_rx_gain

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps)

        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.preamble_detector_threshold = preamble_detector_threshold = 30
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        self.diff_preamble_128 = diff_preamble_128 = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ][0:128]
        self.develop_mode_list = develop_mode_list = [20, 21, 22]
        self.destination_address = destination_address = 3
        self.counter_id = counter_id = 20
        self.apply_address_check = apply_address_check = 1
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            2,
            'destination_address':
            1,
            'source_address':
            3,
            'num_transmission':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200,
            'header_length':
            9,
            'address_check':
            1,
            'good_frame':
            1
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.send_frame_0 = send_frame(
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode_list=develop_mode_list,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode_list=develop_mode_list,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 25, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range,
                                              self.set_range_rx_gain,
                                              'Rx Gain', "counter_slider",
                                              float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range,
                                         self.set_range_mu,
                                         'BB Derotation Gain',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1)
        self.inets_idle_0 = inets.idle(
            (develop_mode_list), experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.inets_counter_0 = inets.counter((develop_mode_list), 20)
        self.frame_info_simulator = blocks.message_strobe_random(
            another_data_info, blocks.STROBE_POISSON, 4000, 2000)
        self.blocks_message_strobe_random_1 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 50, 5)
        self.blocks_message_debug_1 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_1, 'strobe'),
                         (self.inets_idle_0, 'reset_idle'))
        self.msg_connect((self.frame_info_simulator, 'strobe'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.inets_counter_0, 'message_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.send_frame_0, 'in'))
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'),
                         (self.blocks_message_debug_1, 'print'))
        self.connect((self.send_frame_0, 0), (self.receive_frame_0, 0))
Exemple #15
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_timeout_cpp")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_timeout_cpp")
        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", "Test_timeout_cpp")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.timeout_duration_ms = timeout_duration_ms = 1000
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.samp_rate = samp_rate = 320000
        self.develop_mode_list = develop_mode_list = [1, 3, 4, 16]

        ##################################################
        # Blocks
        ##################################################
        self.inets_timeout_cpp_0 = inets.timeout_cpp(
            (develop_mode_list), timeout_duration_ms,
            system_time_granularity_us)
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_decision_cpp_0 = inets.decision_cpp((develop_mode_list), 14)
        self.blocks_message_strobe_random_0_0 = blocks.message_strobe_random(
            pmt.make_dict(), blocks.STROBE_POISSON, 2000, 1000)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(
            pmt.make_dict(), blocks.STROBE_POISSON, 5000, 1000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'),
                         (self.inets_timeout_cpp_0, 'tx_frame_info_in'))
        self.msg_connect((self.blocks_message_strobe_random_0_0, 'strobe'),
                         (self.inets_timeout_cpp_0, 'ack_info_in'))
        self.msg_connect((self.inets_decision_cpp_0, 'spark_out_t'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.inets_decision_cpp_0, 'spark_out_f'),
                         (self.inets_message_tomb_0, 'message_in'))
        self.msg_connect((self.inets_timeout_cpp_0, 'spark_out'),
                         (self.inets_decision_cpp_0, 'spark_in'))
        self.msg_connect((self.inets_timeout_cpp_0, 'spark_out'),
                         (self.inets_message_tomb_0, 'message_in'))