Ejemplo n.º 1
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.rx_gain = rx_gain = 0.75
        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(4000000)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.futebol_msg_to_file_0 = futebol.msg_to_file()
        self.futebol_msg_rssi_msg_0 = futebol.msg_rssi_msg(-0.5)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     '/tmp/teste.csv', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.RSSI_0 = RSSI()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.futebol_msg_rssi_msg_0, 'msg_out'),
                         (self.futebol_msg_to_file_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.futebol_msg_rssi_msg_0, 'msg_in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.RSSI_0, 0), (self.futebol_msg_rssi_msg_0, 0))
        self.connect((self.futebol_msg_to_file_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.RSSI_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
Ejemplo n.º 2
0
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.gain = gain = 50
        self.freq = freq = 2.45e9

        ##################################################
        # Blocks
        ##################################################
        self.rftap_rftap_encap_0 = rftap.rftap_encap(2, 195, "")
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(4e6)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.epy_block_0 = blk()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, zb_file, False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.epy_block_0, 'out'), (self.rftap_rftap_encap_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.epy_block_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))    
Ejemplo n.º 3
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        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", "ber_ser")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = float(d_txdb)
        self.samp = samp = 4
        self.rx_gain = rx_gain = float(d_rxdb)
        self.freq = freq = float(d_freq)
        self.buf = buf = 0x8000
        self.bits = bits = 16

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(-20, 64, 0.01, float(d_txdb), 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 72, 0.01, float(d_rxdb), 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._freq_options = [2450000000, 915000000, 430000000]
        self._freq_labels = ['2.45GHz', '915MHz', '430MHz']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._bits_range = Range(1, 127, 1, 43, 200)
        self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits",
                                     "counter_slider", int)
        self.top_layout.addWidget(self._bits_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 1,
                                                     qtgui.NUM_GRAPH_HORIZ, 2)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = [
            'BER', 'SER', 'Latency', 'Bit Error Rate', 'Symbol Error Rate',
            'SNR', '', '', '', ''
        ]
        units = ['', '', 'ms', '', '', 'dB', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(2):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6),
                                               int(20000000), buf * 16, True,
                                               True, True, "manual", rx_gain,
                                               '', True)
        self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6),
                                           int(20000000), buf, False, tx_gain,
                                           '', True)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        self.ieee802_15_4_phy_0_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy()
        if argv[7] == 'ook':
            exec "d_thr = " + argv[8] in locals()
            self.ieee802_15_4_phy_0_0 = ieee802_15_4_ook_phy(threshold=d_thr)
            self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy(threshold=d_thr)
            print "Modulation: OOK\nThreshold: " + str(d_thr) + "\n"
        elif argv[7] == 'fsk':
            self.ieee802_15_4_phy_0_0 = ieee802_15_4_cpfsk_phy()
            self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy()
            print "Modulation: FSK\n"

        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, buf, buf)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '',
                                                       '52001', 10000, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern(''.join(chr(e) for e in range(65, 65 + bits))), 500)
        self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                     d_dir + '/ser.bin', False)
        self.blocks_file_sink_1_0.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1,
                                                   d_dir + '/ber.bin', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/hrbenitez/Desktop/output_padded.pcap',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_error_rate_0_0 = grc_blks2.error_rate(
            type='SER',
            win_size=2**20,
            bits_per_symbol=2,
        )
        self.blks2_error_rate_0 = grc_blks2.error_rate(
            type='BER',
            win_size=2**20,
            bits_per_symbol=1,
        )
        self.bar_out_sync_0 = bar.out_sync(10)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_phy_0_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_phy_0_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.bar_out_sync_0, 0), (self.blks2_error_rate_0, 0))
        self.connect((self.bar_out_sync_0, 2), (self.blks2_error_rate_0, 1))
        self.connect((self.bar_out_sync_0, 1), (self.blks2_error_rate_0_0, 0))
        self.connect((self.bar_out_sync_0, 3), (self.blks2_error_rate_0_0, 1))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blks2_error_rate_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.blocks_file_sink_1_0, 0))
        self.connect((self.blks2_error_rate_0_0, 0),
                     (self.qtgui_number_sink_0, 1))
        self.connect((self.foo_packet_pad_0, 0), (self.ieee802_15_4_phy_0, 0))
        self.connect((self.foo_packet_pad_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))

        self.connect((self.ieee802_15_4_phy_0, 2), (self.bar_out_sync_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 3), (self.bar_out_sync_0, 1))
        self.connect((self.ieee802_15_4_phy_0, 1), (self.bar_out_sync_0, 2))
        self.connect((self.ieee802_15_4_phy_0, 0), (self.foo_packet_pad_0, 0))
        self.connect((self.ieee802_15_4_phy_0_0, 2), (self.bar_out_sync_0, 3))
        self.connect((self.ieee802_15_4_phy_0_0, 3), (self.bar_out_sync_0, 4))
        self.connect((self.ieee802_15_4_phy_0_0, 1), (self.bar_out_sync_0, 5))
        self.connect((self.ieee802_15_4_phy_0_0, 0),
                     (self.blocks_null_sink_0_0, 0))

        self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0_0, 0))
    def __init__(self, addr, no_usrp, initialFreq, otw, source, no_self_loop,
                 debug_MAC, wireshark):
        gr.top_block.__init__(
            self, "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        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", "transceiver_OQPSK_Slave")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.addr = addr
        self.no_usrp = no_usrp
        self.freq = initialFreq
        self.otw = otw
        self.no_self_loop = no_self_loop
        self.debug_MAC = debug_MAC
        self.source = source
        self.wireshark = wireshark
        self.tx_gain = tx_gain = 0.25
        self.rx_gain = rx_gain = 0.25
        ##################################################
        # Blocks
        ##################################################
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     4 * 1e6, True)
            ## Using files instead of USRPs
            self.blocks_file_source_slave = blocks.file_source(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/masterFileSink"), True)
            self.blocks_file_sink_slave = blocks.file_sink(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/slaveFileSink"), False)
            self.blocks_file_sink_slave.set_unbuffered(False)
        else:
            ## usrp_source
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
            ## usrp_sink
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )

            # TODO Explain the usage
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                                uhd.ALL_MBOARDS)
            self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
            self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
            self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)

        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            4e6,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        # 802.15.4m MAC layer #
        #self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_mac_0 = mac_15_4m(self.debug_MAC, self.no_self_loop)
        # Ethernet Encapsulation #TODO explain its usage, Specific to 802.11 ?
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        self._freq_options = [
            TVWS_channelmap.get_TVWS_freq(i) for i in range(2, 69)
        ]
        self._freq_labels = [str(i) for i in range(2, 69)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))

        self.top_layout.addWidget(self._freq_tool_bar)

        ##################################################
        # Asynch Message Connections
        ##################################################
        if self.source == "tuntap":  # Tuntap Block to quantify the achievable throughput
            print "TUNTAP"
            self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap1", 440)
            self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                             self.blocks_tuntap_pdu_0, "pdus")
            self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                             self.ieee802_11_ether_encap_0, "from tap")

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.ieee802_11_ether_encap_0, "from wifi")
            self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "socket":  #using PDU Sockets instead #TODO Test ME !
            self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                "UDP_SERVER", "localhost", "52004", 10000)
            self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                "UDP_CLIENT", "localhost", "3333", 10000)

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.blocks_socket_pdu_0_Rx, "pdus")
            self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "strobe":
            self.blocks_message_strobe_0 = blocks.message_strobe(
                pmt.intern("Hello World!\n"), 1000)
            self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                             (self.ieee802_15_4_rime_stack_0, 'bcin'))

        if self.wireshark:
            self.foo_wireshark_connector_0 = foo.wireshark_connector(127, True)

            self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       "/tmp/ofdm.pcap", True)
            self.blocks_file_sink_0.set_unbuffered(True)

            self.connect((self.foo_wireshark_connector_0, 0),
                         (self.blocks_file_sink_0, 0))

            self.msg_connect(self.ieee802_15_4_mac_0, "PHY",
                             self.foo_wireshark_connector_0, "in")
            self.msg_connect(self.ieee802_15_4_oqpsk_phy_0, "mac_out",
                             self.foo_wireshark_connector_0, "in")

        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        if self.no_usrp:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.blocks_file_sink_slave, 0)))
            self.connect((self.blocks_file_source_slave, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
        else:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.uhd_usrp_sink_0, 0)))
            self.connect((self.uhd_usrp_source_0, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
Ejemplo n.º 5
0
    def __init__(self, addr, no_usrp, rate, lo_offset, encod, rime, otw,
                 source, no_self_loop, debug_MAC):
        grc_wxgui.top_block_gui.__init__(self, title="TransceiverSlave")

        ##################################################
        # Variables
        ##################################################
        self.addr = addr
        self.no_usrp = no_usrp
        self.samp_rate = rate
        self.rime = rime
        self.otw = otw
        self.no_self_loop = no_self_loop
        self.debug_MAC = debug_MAC
        self.lo_offset = lo_offset
        ##################################################
        # Blocks
        ##################################################
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     self.samp_rate * 1e6,
                                                     True)
            ################################
            ## Using files instead of USRPs
            ###############################
            self.blocks_slaveFileSource = blocks.file_source(
                gr.sizeof_gr_complex * 1, (os.getcwd() + "/masterFileSink"),
                True)
            self.blocks_slaveFileSink = blocks.file_sink(
                gr.sizeof_gr_complex * 1, (os.getcwd() + "/slaveFileSink"),
                False)
            self.blocks_slaveFileSink.set_unbuffered(False)

        else:
            ############
            ## source
            ############
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                stream_args=uhd.stream_args(
                    cpu_format="fc32",
                    otw_format=self.otw,
                    channels=range(1),
                ),
            )

            # TODO Explain the usage
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                                uhd.ALL_MBOARDS)

            #############
            ## sink
            #############
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    otw_format=self.otw,
                    channels=range(1),
                ),
                "packet_len",
            )

            # TODO Explain the usage
            self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)

        # 802.15.4 PHY Layer O-QPSK
        #self.PHY = ieee802_15_4_phy()

        # 802.11 a,g,p PHY Layer OFDM
        # Encoding choices=[0,1,2,3,4,5,6,7]="BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        self.PHY = wifi_phy_hier(encoding=int(encod), )

        # Foo block #TODO explain its usage
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 0,
                                                 10000)  ## ?! ##
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)

        # Multiply Const Block
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (0.38, ))  #mult = 0.38
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)

        # 802.15.4m MAC layer #
        self.MAC = mac(self.debug_MAC, self.no_self_loop)

        # 802.11 a,g,p OFDM MAC Layer
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]),
            ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))

        # ofdm_parse_mac block for debugging purpose TODO Modify it so that it parse the frames structure of the MAC am using
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False, True)

        # Communication Layer RIME Stack
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        # Ethernet Encapsulation #TODO explain its usage
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        ##################################################
        # Asynch Message Connections
        ##################################################

        if self.rime:

            if source == "tuntap":  # Tuntap Block to quantify the achievable throughput
                self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, True)
                # istunFlag == True: TUN(IP Packet)
                # 	    == False: TAP(Ethernet Frame)
                self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                                 self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                                 self.ieee802_11_ether_encap_0, "from tap")

                self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                                 self.ieee802_11_ether_encap_0, "from wifi")
                self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi",
                                 self.ieee802_15_4_rime_stack_0, "bcin")

            else:  #using PDU Sockets instead #TODO Test ME !
                self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                    "UDP_SERVER", "localhost", "52004", 10000)
                self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                    "UDP_CLIENT", "localhost", "3333", 10000)

                self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                                 self.self.blocks_socket_pdu_0_Rx, "pdus")
                self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                                 self.ieee802_15_4_rime_stack_0, "bcin")

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "toMAC",
                             self.ieee802_11_ofdm_parse_mac_0, "app in")
            self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "app out",
                             self.ieee802_15_4_rime_stack_0, "fromMAC")
        else:

            if source == "tuntap":  # Tuntap Block to quantify the achievable throughput
                # istunFlag == True: TUN(IP Packet)
                #           == False: TAP(Ethernet Frame)
                self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, True)
                self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                                 self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                                 self.ieee802_11_ether_encap_0, "from tap")

                self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out",
                                 self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                                 self.ieee802_11_ofdm_mac_0, "app in")

#print "Using Tap interface (IP) ==> No ethernet Encapsulation used !!"
#self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, True)
#self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out", self.blocks_tuntap_pdu_0, "pdus")
#self.msg_connect(self.blocks_tuntap_pdu_0, "pdus", self.ieee802_11_ofdm_mac_0, "app in")

            else:  ##using PDU Sockets instead #TODO Test ME !
                self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                    "UDP_SERVER", "localhost", "52004", 10000)
                self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                    "UDP_CLIENT", "localhost", "3333", 10000)

                self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out",
                                 self.blocks_socket_pdu_0_Rx, "pdus")
                self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                                 self.ieee802_11_ofdm_mac_0, "app in")

        ## Debugging at the MAC level To parse at the level of MAC ! Look at the flowgraph
        ##self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_parse_mac_0, "in")
        self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_parse_mac_0,
                         "in")
        self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_mac_0,
                         "phy in")
        self.msg_connect(self.ieee802_11_ofdm_mac_0, "phy out", self.PHY,
                         "mac_in")

        ##################################################
        # Connections
        ##################################################

        if self.no_usrp:
            self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0))
            self.connect((self.blocks_slaveFileSource, 0), (self.PHY, 0))
            self.connect((self.foo_packet_pad2_0, 0),
                         (self.blocks_slaveFileSink, 0))
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.foo_packet_pad2_0, 0))
        else:
            self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0))
            self.connect((self.uhd_usrp_source_0, 0), (self.PHY, 0))
            self.connect((self.foo_packet_pad2_0, 0),
                         (self.uhd_usrp_sink_0, 0))
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.foo_packet_pad2_0, 0))
Ejemplo n.º 6
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.rx_gain = rx_gain = 0.75
        self.period = period = 10
        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            'pdu_length',
        )
        self.uhd_usrp_sink_0.set_samp_rate(4000000)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, 2000, 2000)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("Hello World!\n"), period)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.foo_packet_pad_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.foo_packet_pad_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.uhd_usrp_sink_0, 0))
Ejemplo n.º 7
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="IEEE 802.15.4 Transceiver using CSS PHY")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.text_msg = text_msg = "This is a test message"
        self.c = c = ieee802_15_4.css_phy(chirp_number=4,
                                          phy_packetsize_bytes=len(text_msg) +
                                          15)
        self.samp_rate = samp_rate = 32e6
        self.phi = phi = 10
        self.pad_len = pad_len = c.nsamp_frame * 0
        self.msg_interval = msg_interval = 1000
        self.freq_off = freq_off = 0
        self.enable = enable = 1.0
        self.delay = delay = 0
        self.ampl = ampl = 0

        ##################################################
        # Blocks
        ##################################################
        _pad_len_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pad_len_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_pad_len_sizer,
            value=self.pad_len,
            callback=self.set_pad_len,
            label="Pad Length",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._pad_len_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_pad_len_sizer,
            value=self.pad_len,
            callback=self.set_pad_len,
            minimum=0,
            maximum=10000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_pad_len_sizer)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols")
        self.Add(self.nb)
        _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL)
        self._msg_interval_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_msg_interval_sizer,
            value=self.msg_interval,
            callback=self.set_msg_interval,
            label="Message Interval [ms]",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._msg_interval_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_msg_interval_sizer,
            value=self.msg_interval,
            callback=self.set_msg_interval,
            minimum=1,
            maximum=5000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_msg_interval_sizer)
        _freq_off_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_off_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_off_sizer,
            value=self.freq_off,
            callback=self.set_freq_off,
            label="Frequency Offset",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_off_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_off_sizer,
            value=self.freq_off,
            callback=self.set_freq_off,
            minimum=-1e5,
            maximum=1e5,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_off_sizer)
        _delay_sizer = wx.BoxSizer(wx.VERTICAL)
        self._delay_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_delay_sizer,
            value=self.delay,
            callback=self.set_delay,
            label="Delay",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._delay_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_delay_sizer,
            value=self.delay,
            callback=self.set_delay,
            minimum=0,
            maximum=100000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_delay_sizer)
        _ampl_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ampl_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ampl_sizer,
            value=self.ampl,
            callback=self.set_ampl,
            label="Noise Amplitude",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._ampl_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ampl_sizer,
            value=self.ampl,
            callback=self.set_ampl,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_ampl_sizer)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="RX Waterfall",
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_3 = scopesink2.scope_sink_c(
            self.nb.GetPage(3).GetWin(),
            title="RX Correlator Output",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_3.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.nb.GetPage(2).GetWin(),
            title="RX Time Signal",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title="RX FFT",
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        _phi_sizer = wx.BoxSizer(wx.VERTICAL)
        self._phi_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_phi_sizer,
            value=self.phi,
            callback=self.set_phi,
            label="Phi",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._phi_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_phi_sizer,
            value=self.phi,
            callback=self.set_phi,
            minimum=2,
            maximum=20,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_phi_sizer)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy(
            bits_per_cw=c.bits_per_symbol,
            chirp_seq=c.chirp_seq,
            codewords=c.codewords,
            intlv_seq=c.intlv_seq,
            len_sub=38,
            nbytes_payload=c.phy_packetsize_bytes,
            nsamp_frame=c.nsamp_frame,
            num_subchirps=c.n_subchirps,
            nzeros_padding=c.padded_zeros,
            phr=c.PHR,
            preamble=c.preamble,
            sfd=c.SFD,
            sym_per_frame=c.nsym_frame,
            threshold=0.95,
            time_gap_1=c.time_gap_1,
            time_gap_2=c.time_gap_2,
        )
        self._enable_chooser = forms.button(
            parent=self.GetWin(),
            value=self.enable,
            callback=self.set_enable,
            label="TX Enable",
            choices=[1.0, 0.0],
            labels=['on', 'off'],
        )
        self.Add(self._enable_chooser)
        self.blocks_vector_insert_x_0 = blocks.vector_insert_c(
            ([0 for i in range(pad_len)]), 3 * c.nsamp_frame,
            3 * c.nsamp_frame)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "",
                                                       "52001", 10000, False)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern(text_msg), msg_interval)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           int(delay))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, freq_off, 1, 0)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, ampl, 0, 8192)
        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 10)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_css_phy_1, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.ieee802_15_4_css_phy_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_vector_insert_x_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_vector_insert_x_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.ieee802_15_4_css_phy_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.ieee802_15_4_css_phy_1, 1),
                     (self.wxgui_scopesink2_3, 0))
Ejemplo n.º 8
0
    def __init__(self,
                 num_messages=1000000000,
                 pad=0x00,
                 preamble=0x000000a7,
                 tx_gain=.75):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transmitter using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transmitter using OQPSK PHY")
        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", "transmitter_OQPSK")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.num_messages = num_messages
        self.pad = pad
        self.preamble = preamble
        self.tx_gain = tx_gain

        ##################################################
        # Variables
        ##################################################
        self.ch = ch = 11
        self.samp_rate = samp_rate = 4000000
        self.freq = freq = 1000000 * (2400 + 5 * (ch - 10))

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            'pdu_length',
        )
        self.uhd_usrp_sink_0.set_samp_rate(4000000)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.ieee802_15_4_access_code_prefixer_0 = ieee802_15_4.access_code_prefixer(
            pad, preamble)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ([(1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
              (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
              (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 - 1j), (-1 - 1j),
              (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
              (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
              (1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
              (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
              (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
              (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
              (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
              (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
              (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
              (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
              (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
              (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
              (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
              (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
              (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
              (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
              (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
              (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
              (1 + 1j), (-1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
              (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
              (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
              (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
              (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
              (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (1 + 1j),
              (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
              (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
              (1 + 1j), (-1 - 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
              (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
              (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
              (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
              (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
              (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 + 1j), (1 + 1j),
              (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
              (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
              (-1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
              (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
              (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
              (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
              (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
              (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j)]), 16)
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc(
            (([])), 0, 4, False, "pdu_length")
        self._ch_range = Range(11, 26, 1, 11, 200)
        self._ch_win = RangeWidget(self._ch_range, self.set_ch, "ch",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._ch_win)
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            [0, sin(pi / 4), 1, sin(3 * pi / 4)], True, 1, [])
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, 'pdu_length', 128)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_float * 1, False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 4)
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'pdu_length')
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            4, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("Hello World!\n"), 1000)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 2)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_access_code_prefixer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_access_code_prefixer_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_repeat_0, 0))
Ejemplo n.º 9
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="IEEE 802.15.4 Transceiver using CSS PHY")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!"
        self.freq = freq = 2480000000
        self.samp_rate = samp_rate = 1e6
        self.msg_interval = msg_interval = 1000
        self.gain = gain = 20
        self.cur_freq = cur_freq = freq
        self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15)

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols")
        self.Add(self.nb)
        _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL)
        self._msg_interval_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_msg_interval_sizer,
        	value=self.msg_interval,
        	callback=self.set_msg_interval,
        	label="Message interval [ms]",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._msg_interval_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_msg_interval_sizer,
        	value=self.msg_interval,
        	callback=self.set_msg_interval,
        	minimum=1,
        	maximum=5000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_msg_interval_sizer)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="TX/RX Gain",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=1,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)],
        	labels=[i for i in range(11, 27)],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._freq_chooser)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RX Waterfall",
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_3 = scopesink2.scope_sink_c(
        	self.nb.GetPage(3).GetWin(),
        	title="RX Correlator Output",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_3.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
        	self.nb.GetPage(2).GetWin(),
        	title="RX Time Signal",
        	sample_rate=samp_rate,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="RX FFT",
        	peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_1.set_center_freq(freq, 0)
        self.uhd_usrp_sink_1.set_gain(gain, 0)
        self.uhd_usrp_sink_1.set_antenna("TX/RX", 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy(
            bits_per_cw=c.bits_per_symbol,
            chirp_seq=c.chirp_seq,
            codewords=c.codewords,
            intlv_seq=c.intlv_seq,
            len_sub=38,
            nbytes_payload=c.phy_packetsize_bytes,
            nsamp_frame=c.nsamp_frame,
            num_subchirps=c.n_subchirps,
            nzeros_padding=c.padded_zeros,
            phr=c.PHR,
            preamble=c.preamble,
            sfd=c.SFD,
            sym_per_frame=c.nsym_frame,
            threshold=0.95,
            time_gap_1=c.time_gap_1,
            time_gap_2=c.time_gap_2,
        )
        self._cur_freq_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.cur_freq,
        	callback=self.set_cur_freq,
        	label="Current center frequency",
        	converter=forms.float_converter(),
        )
        self.Add(self._cur_freq_static_text)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "8048", 10000, False)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), msg_interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin'))    
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin'))    
        self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, 'txin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.connect((self.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0))    
        self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))    
Ejemplo n.º 10
0
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 RX")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 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", "Zigbee_RX")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4e06
        self.rx_gain = rx_gain = 0.75
        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self._freq_options = [
            1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)
        ]
        self._freq_labels = [str(i) for i in range(11, 27)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_RX_0 = ieee802_15_4_oqpsk_phy_RX()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, True)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT",
                                                     '151.97.13.245', '33333',
                                                     10000, False)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/lab/Progetti_Gnuradio/Brincat/802.15.4/zigbee.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_RX_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_RX_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_RX_0, 0))
Ejemplo n.º 11
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.freq = freq = 2.48e9

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(0, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.uhd_usrp_sink_0.set_antenna("J1", 0)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([130]), ([131]), ([23,42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52001", 10000, False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))    
Ejemplo n.º 12
0
    def __init__(self):
        parser = OptionParser()
        parser.add_option("--length",
                          type="int",
                          dest="length",
                          help="MAC payload length(1-112)",
                          default="10")
        parser.add_option("--rate",
                          type="float",
                          dest="rate",
                          help="Tx and Rx sample rate",
                          default=4e6)
        parser.add_option("--period",
                          type="int",
                          dest="period",
                          help="Message Source Period",
                          default=500)
        (options, args) = parser.parse_args()

        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        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", "transceiver_OQPSK")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = options.rate
        self.rx_gain = rx_gain = 0.75

        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            4e6,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.output_chain_0 = output_chain(samp_rate=samp_rate, )
        self.limesdr_source_0_0 = limesdr.source(
            0, 2, 1, 0, 0,
            '/home/saptarshi/Documents/MasterThesis@RISE/lime-gnuradio/src/limesuite/build/example',
            2.48e9, samp_rate, 0, 1, samp_rate, 0, 10e6, 1, 2, 1, 1,
            5e6 + samp_rate % 5e6 * int(samp_rate / 5e6), 0, 10e6, 0,
            samp_rate, 0, 0, 60, 60)
        self.limesdr_sink_1 = limesdr.sink(
            0, 2, 1, 0, 0, '', 2.48e9, samp_rate, 0, 1, samp_rate, 0, 10e6, 1,
            2, 1, 1, 5e6 + samp_rate % 5e6 * int(samp_rate / 5e6), 0, 10e6, 0,
            4e6, 0, 0, 60, 60)
        self.input_chain_0 = input_chain(omega=samp_rate / 2e6, )
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self._freq_options = [
            1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)
        ]
        self._freq_labels = [str(i) for i in range(11, 27)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_grid_layout.addWidget(self._freq_tool_bar)
        self.foo_rtt_0 = foo.rtt(options.period, options.length)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     '/tmp/timings', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.foo_rtt_0, 'out'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.output_chain_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.foo_rtt_0, 'in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.input_chain_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.connect((self.foo_rtt_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.limesdr_source_0_0, 0), (self.input_chain_0, 0))
        #self.connect((self.limesdr_source_0_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.output_chain_0, 0), (self.limesdr_sink_1, 0))
Ejemplo n.º 13
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Variables
        ##################################################
        self.gain = gain = 50
        self.freq = freq = 2450000000

        ##################################################
        # Blocks
        ##################################################
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label='gain',
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=1,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)],
            labels=[i for i in range(11, 27)],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._freq_chooser)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=4e6,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(2, 195, "")
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(4e6)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.epy_block_0 = blk()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                                     "52001", 10000, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/zigbee.pcap", False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.epy_block_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.epy_block_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.wxgui_fftsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
Ejemplo n.º 14
0
    def __init__(self, freq=2480000000, gain=48, method=7):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain
        self.method = method

        ##################################################
        # Blocks
        ##################################################
        self.uhdgps_cpdu_average_power_0 = uhdgps.cpdu_average_power(-60)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(5000000)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(5000000)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(gain, 0)
        self.lqe_powerControl_0 = lqe.powerControl(
            gain, '/home/wendley/SerieGanho100ms.txt', False)
        self.lqe_getRSSI_0 = lqe.getRSSI(False, 2, 2, 40, -108, -67, 0.500,
                                         0.2, 0.1, 0.05)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.foo_periodic_msg_source_1 = foo.periodic_msg_source(
            pmt.intern(
                "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
            ), 400, 1000, True, False)
        self.es_trigger_sample_timer_0 = es.trigger_sample_timer(
            gr.sizeof_gr_complex, int(2000), 2, int(4000000), 512)
        self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 8, 64, 0, 2, 0)
        self.es_handler_pdu_0 = es.es_make_handler_pdu(
            es.es_handler_print.TYPE_C32)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(
            2, 1000, 0.001)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '',
                                                       '52001', 10000, False)
        self.blocks_pdu_remove_0 = blocks.pdu_remove(
            pmt.intern("es::event_buffer"))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_pdu_remove_0, 'pdus'),
                         (self.ieee802_15_4_mac_0, 'cs in'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'),
                         (self.lqe_getRSSI_0, 'SNR'))
        self.msg_connect((self.es_handler_pdu_0, 'pdus_out'),
                         (self.uhdgps_cpdu_average_power_0, 'cpdus'))
        self.msg_connect(
            (self.es_trigger_sample_timer_0, 'sample_timer_event'),
            (self.es_handler_pdu_0, 'handle_event'))
        self.msg_connect((self.es_trigger_sample_timer_0, 'which_stream'),
                         (self.es_sink_0, 'schedule_event'))
        self.msg_connect((self.foo_periodic_msg_source_1, 'out'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.foo_periodic_msg_source_1, 'out'),
                         (self.lqe_getRSSI_0, 'sendOrder'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'ackOut'),
                         (self.lqe_getRSSI_0, 'Ackin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'packLost'),
                         (self.lqe_getRSSI_0, 'lostPacks'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'resendPck'),
                         (self.lqe_getRSSI_0, 'sendPacks'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'ackOut'),
                         (self.lqe_powerControl_0, 'saveGain'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'resendPck'),
                         (self.lqe_powerControl_0, 'saveGain'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.lqe_getRSSI_0, 'estimation'),
                         (self.lqe_powerControl_0, 'estimation'))
        self.msg_connect((self.uhdgps_cpdu_average_power_0, 'cpdus'),
                         (self.blocks_pdu_remove_0, 'pdus'))
        self.msg_connect((self.uhdgps_cpdu_average_power_0, 'rssi'),
                         (self.lqe_getRSSI_0, 'RSSIin'))
        self.connect((self.es_trigger_sample_timer_0, 0), (self.es_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.es_trigger_sample_timer_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
Ejemplo n.º 15
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        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", "pure_sig")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = float(d_txdb)
        self.samp = samp = 4
        self.rx_gain = rx_gain = float(d_rxdb)
        self.freq = freq = float(d_freq)
        self.buf = buf = 0x8000
        self.bits = bits = 16
        self.samp_rate = samp_rate = 4e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(-20, 64, 0.01, tx_gain, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 72, 0.01, rx_gain, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._freq_options = [2450000000, 915000000, 430000000]
        self._freq_labels = ['2.45GHz', '915MHz', '430MHz']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._bits_range = Range(1, 127, 1, 16, 200)
        self._bits_win = RangeWidget(self._bits_range, self.set_bits, "bits",
                                     "counter_slider", int)
        self.top_layout.addWidget(self._bits_win)
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f(
            buf * 16,  #size
            samp_rate,  #samp_rate
            "HSS OQPSK",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1_0.set_y_axis(0, 2e-4)

        self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_1_0.enable_tags(-1, False)
        self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_1_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1_0.enable_grid(False)
        self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_1_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_1_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_1_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win)
        self.pluto_source_0 = iio.pluto_source(d_rxid, int(freq), int(4e6),
                                               int(20000000), buf * 16, True,
                                               True, True, "manual", rx_gain,
                                               '', True)
        self.pluto_sink_0 = iio.pluto_sink(d_txid, int(freq), int(4e6),
                                           int(20000000), buf, True, tx_gain,
                                           '', True)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        self.ieee802_15_4_phy_0 = ieee802_15_4_oqpsk_phy()
        if argv[7] == 'ook':
            self.ieee802_15_4_phy_0 = ieee802_15_4_ook_phy(
                threshold=float(argv[8]))
        if argv[7] == 'fsk':
            self.ieee802_15_4_phy_0 = ieee802_15_4_cpfsk_phy()

        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '',
                                                       '52001', 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern('a' * bits), 10)
        self.blocks_file_sink_1_0_0 = blocks.file_sink(
            gr.sizeof_float * 1, '/home/hrbenitez/Desktop/just_sig.bin', False)
        self.blocks_file_sink_1_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/hrbenitez/Desktop/2_pluto.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_file_sink_1_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 2),
                     (self.blocks_null_sink_0, 1))
        self.connect((self.ieee802_15_4_phy_0, 3),
                     (self.blocks_null_sink_0, 2))
        self.connect((self.ieee802_15_4_phy_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.ieee802_15_4_phy_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.pluto_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.pluto_source_0, 0), (self.ieee802_15_4_phy_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using CSS PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using CSS PHY")
        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", "transceiver_CSS_USRP")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!"
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 1e6
        self.rx_gain = rx_gain = 0.75
        self.interval = interval = 300
        self.freq = freq = 2480000000
        self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15)

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self._interval_range = Range(10, 1000, 1, 300, 200)
        self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int)
        self.top_layout.addWidget(self._interval_win)
        self._freq_options = [1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)]
        self._freq_labels = [str(i) for i in range(11, 27)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel'+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(('addr=192.168.10.4', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
        	",".join(('addr=192.168.10.6', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_1.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_1.set_center_freq(freq, 0)
        self.uhd_usrp_sink_1.set_normalized_gain(tx_gain, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy(
            bits_per_cw=c.bits_per_symbol,
            chirp_seq=c.chirp_seq,
            codewords=c.codewords,
            intlv_seq=c.intlv_seq,
            len_sub=38,
            nbytes_payload=c.phy_packetsize_bytes,
            nsamp_frame=c.nsamp_frame,
            num_subchirps=c.n_subchirps,
            nzeros_padding=c.padded_zeros,
            phr=c.PHR,
            preamble=c.preamble,
            sfd=c.SFD,
            sym_per_frame=c.nsym_frame,
            threshold=0.95,
            time_gap_1=c.time_gap_1,
            time_gap_2=c.time_gap_2,
        )
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
Ejemplo n.º 17
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="IEEE 802.15.4 Transceiver using CSS PHY")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!"
        self.freq = freq = 2480000000
        self.samp_rate = samp_rate = 1e6
        self.msg_interval = msg_interval = 1000
        self.gain = gain = 20
        self.cur_freq = cur_freq = freq
        self.c = c = ieee802_15_4.css_phy(chirp_number=4,
                                          phy_packetsize_bytes=len(text_msg) +
                                          15)

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols")
        self.Add(self.nb)
        _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL)
        self._msg_interval_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_msg_interval_sizer,
            value=self.msg_interval,
            callback=self.set_msg_interval,
            label="Message interval [ms]",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._msg_interval_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_msg_interval_sizer,
            value=self.msg_interval,
            callback=self.set_msg_interval,
            minimum=1,
            maximum=5000,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_msg_interval_sizer)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            label="TX/RX Gain",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_gain_sizer,
            value=self.gain,
            callback=self.set_gain,
            minimum=1,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_gain_sizer)
        self._freq_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)],
            labels=[i for i in range(11, 27)],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._freq_chooser)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.nb.GetPage(0).GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="RX Waterfall",
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_3 = scopesink2.scope_sink_c(
            self.nb.GetPage(3).GetWin(),
            title="RX Correlator Output",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(3).Add(self.wxgui_scopesink2_3.win)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.nb.GetPage(2).GetWin(),
            title="RX Time Signal",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb.GetPage(1).GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=True,
            avg_alpha=None,
            title="RX FFT",
            peak_hold=False,
        )
        self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr=192.168.10.4", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("J1", 0)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.6", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_1.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_1.set_center_freq(freq, 0)
        self.uhd_usrp_sink_1.set_gain(gain, 0)
        self.trafficGenerator_Distribution_0 = trafficGenerator.Distribution(
            0, 100, 4, 5, int)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy(
            bits_per_cw=c.bits_per_symbol,
            chirp_seq=c.chirp_seq,
            codewords=c.codewords,
            intlv_seq=c.intlv_seq,
            len_sub=38,
            nbytes_payload=c.phy_packetsize_bytes,
            nsamp_frame=c.nsamp_frame,
            num_subchirps=c.n_subchirps,
            nzeros_padding=c.padded_zeros,
            phr=c.PHR,
            preamble=c.preamble,
            sfd=c.SFD,
            sym_per_frame=c.nsym_frame,
            threshold=0.95,
            time_gap_1=c.time_gap_1,
            time_gap_2=c.time_gap_2,
        )
        self._cur_freq_static_text = forms.static_text(
            parent=self.GetWin(),
            value=self.cur_freq,
            callback=self.set_cur_freq,
            label="Current center frequency",
            converter=forms.float_converter(),
        )
        self.Add(self._cur_freq_static_text)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "",
                                                       "52001", 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int * 1)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern(text_msg), msg_interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_css_phy_1, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.ieee802_15_4_css_phy_1, 0),
                     (self.uhd_usrp_sink_1, 0))
        self.connect((self.ieee802_15_4_css_phy_1, 1),
                     (self.wxgui_scopesink2_3, 0))
        self.connect((self.trafficGenerator_Distribution_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.ieee802_15_4_css_phy_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
Ejemplo n.º 18
0
    def __init__(self):
        gr.top_block.__init__(self, "zigbee_simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("zigbee_simulation")
        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", "zigbee_demod_fsk")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.zigbee_channel = zigbee_channel = 11
        self.transition_width = transition_width = 100e3
        self.samp_rate = samp_rate = 5000000
        self.cutoff_freq = cutoff_freq = 750e3
        self.channel_spacing = channel_spacing = 5e6
        self.central_frequency = central_frequency = 2405e6
        self.squelch_threshold = squelch_threshold = -80
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.lowpass_filter = lowpass_filter = firdes.low_pass(1, samp_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING, 6.76)
        self.iq_output = iq_output = "ble2.iq"
        self.half_preamble_len = half_preamble_len = 2*32*2
        self.freq_channel = freq_channel = central_frequency+(zigbee_channel-11)*channel_spacing
        self.dsss_mode = dsss_mode = 32
        self.dsss_4_8 = dsss_4_8 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (1+1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j)]
        self.dsss_4_64 = dsss_4_64 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]
        self.dsss_4_32_LSB = dsss_4_32_LSB = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]
        self.dsss_4_32 = dsss_4_32 = [(1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1+1j), (-1+1j), (1+1j), (1-1j), (1+1j), (1-1j), (-1-1j)]
        self.dsss_4_16 = dsss_4_16 = [(-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1+1j), (-1-1j), (-1-1j), (-1+1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (1+1j), (1-1j), (-1-1j), (1-1j), (-1+1j), (-1+1j), (-1-1j), (1-1j), (1-1j), (1+1j), (-1+1j), (1+1j), (-1-1j), (-1-1j), (-1+1j)]
        self.csv_file = csv_file = "packet_index2.csv"

        ##################################################
        # Blocks
        ##################################################
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c(
        	1024, #size
        	"after filtering", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_1.enable_autoscale(True)
        self.qtgui_const_sink_x_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_1.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win)
        self.qtgui_const_sink_x_0_0_1 = qtgui.const_sink_c(
        	1024, #size
        	"after filter", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_1.enable_autoscale(True)
        self.qtgui_const_sink_x_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_1.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_0_1.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_1_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"after filter", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(True)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"after noise", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(True)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.oqpsk_dsss_packet_sink_0 = oqpsk_dsss.packet_sink(12, dsss_mode, 0, 0,csv_file,zigbee_channel,int(samp_rate))
        self.oqpsk_dsss_access_code_prefixer_0 = oqpsk_dsss.access_code_prefixer(0x00,0x000000a7)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(([129]), ([131]), ([132]), ([23,42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True,0x8841,0,0x1aaa,0x0000,0x1780)
        self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(1, (lowpass_filter), 0, samp_rate)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((dsss_4_32), 16)
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((([])), 0, 4, False, "pdu_length")
        self.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, 'pdu_length', 512)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_float * 1, False)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 4)
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pdu_length')
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(4, gr.GR_LSB_FIRST)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("Hello World!\n"), 120)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/home/ousseynou/ZIGBEE.pcap', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 2)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.5, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.oqpsk_dsss_access_code_prefixer_0, 'in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.oqpsk_dsss_access_code_prefixer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'), (self.foo_wireshark_connector_0, 'in'))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_repeat_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_lp, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.oqpsk_dsss_packet_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.freq_xlating_fir_filter_lp, 0), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_lp, 0), (self.qtgui_const_sink_x_0_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
Ejemplo n.º 19
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        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", "transceiver_OQPSK")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.rx_gain = rx_gain = 0.75
        self.freq = freq = 2480000000

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            4e6,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True, 0x8841, 0, 0x1aaa,
                                                   0xffff, 0x3344)
        self._freq_options = [
            1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)
        ]
        self._freq_labels = [str(i) for i in range(11, 27)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_grid_layout.addWidget(self._freq_tool_bar)
        self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, 2000, 2000)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("Hello World!\n"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.connect((self.foo_packet_pad_0, 0),
                     (self.ieee802_15_4_oqpsk_phy_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.foo_packet_pad_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))