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

        ##################################################
        # Blocks
        ##################################################
        self.tfg_test_nwk_0 = tfg.test_nwk()
        self.tfg_NWK_stack_0 = tfg.NWK_stack(True, True)
        self.tfg_MAC_stack_0 = tfg.MAC_stack(False, False)
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, True, 0.1, 2000, 2000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("A"), 1000)
        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.tfg_test_nwk_0, 'entrada'))    
        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.tfg_MAC_stack_0, 'in(PHY)'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(PHY)'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(PHY)'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(NWK)'), (self.tfg_NWK_stack_0, 'in(MAC)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(MAC)'), (self.tfg_MAC_stack_0, 'in(NWK)'))    
        self.msg_connect((self.tfg_test_nwk_0, 'salida'), (self.tfg_NWK_stack_0, 'in(APS)'))    
        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))    
Example #2
0
    def __init__(self):
        gr.top_block.__init__(self, "TFG")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TFG")
        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", "SDR_QT")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.profileID = profileID = 0xDCBA
        self.profile = profile = ""
        self.payload = payload = "EJEMPLO"
        self.nseq = nseq = ""
        self.label_payload = label_payload = ""
        self.label_nwk_src = label_nwk_src = ""
        self.label_nwk_dst = label_nwk_dst = ""
        self.gain = gain = 30
        self.freq = freq = 2480000000
        self.enviar = enviar = False
        self.endpoint_src = endpoint_src = ""
        self.endpoint_dst = endpoint_dst = ""
        self.clusterID = clusterID = 0xABCD
        self.cluster = cluster = ""
        self.NWK_add_src = NWK_add_src = 0xABCD
        self.NWK_add_dst = NWK_add_dst = 0xDCBA
        self.Endpoint_src = Endpoint_src = 10
        self.Endpoint_dst = Endpoint_dst = 20

        ##################################################
        # Blocks
        ##################################################
        self.Tab = Qt.QTabWidget()
        self.Tab_widget_0 = Qt.QWidget()
        self.Tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tab_widget_0)
        self.Tab_grid_layout_0 = Qt.QGridLayout()
        self.Tab_layout_0.addLayout(self.Tab_grid_layout_0)
        self.Tab.addTab(self.Tab_widget_0, 'Transmision')
        self.Tab_widget_1 = Qt.QWidget()
        self.Tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.Tab_widget_1)
        self.Tab_grid_layout_1 = Qt.QGridLayout()
        self.Tab_layout_1.addLayout(self.Tab_grid_layout_1)
        self.Tab.addTab(self.Tab_widget_1, 'Recepcion')
        self.top_layout.addWidget(self.Tab)
        self._NWK_add_src_tool_bar = Qt.QToolBar(self)
        self._NWK_add_src_tool_bar.addWidget(Qt.QLabel("Direccion NWK origen"+": "))
        self._NWK_add_src_line_edit = Qt.QLineEdit(str(self.NWK_add_src))
        self._NWK_add_src_tool_bar.addWidget(self._NWK_add_src_line_edit)
        self._NWK_add_src_line_edit.returnPressed.connect(
        	lambda: self.set_NWK_add_src(int(str(self._NWK_add_src_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._NWK_add_src_tool_bar,  1,0,1,1)
        self.tfg_translation_block_0 = tfg.translation_block()
        self.tfg_NWK_stack_0 = tfg.NWK_stack(True, False)
        self.tfg_Aplication_0 = tfg.Aplication()
        self.tfg_APS_stack_0 = tfg.APS_stack(True, False)
        self._profileID_tool_bar = Qt.QToolBar(self)
        self._profileID_tool_bar.addWidget(Qt.QLabel("ID de perfil"+": "))
        self._profileID_line_edit = Qt.QLineEdit(str(self.profileID))
        self._profileID_tool_bar.addWidget(self._profileID_line_edit)
        self._profileID_line_edit.returnPressed.connect(
        	lambda: self.set_profileID(int(str(self._profileID_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._profileID_tool_bar,  3,2,1,1)
        self._profile_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._profile_formatter = None
        else:
          self._profile_formatter = lambda x: x
        
        self._profile_tool_bar.addWidget(Qt.QLabel('ID de perfil'+": "))
        self._profile_label = Qt.QLabel(str(self._profile_formatter(self.profile)))
        self._profile_tool_bar.addWidget(self._profile_label)
        self.Tab_grid_layout_1 .addWidget(self._profile_tool_bar,  3,2,1,1)
          
        self.perfl_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "perfil")
        self._perfl_r_win = sip.wrapinstance(self.perfl_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._perfl_r_win,  3,3,1,1)
        self.payload_r = qtgui.edit_box_msg(qtgui.STRING, '', '', True, True, "payload")
        self._payload_r_win = sip.wrapinstance(self.payload_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._payload_r_win,  0,1,1,3)
        self._payload_tool_bar = Qt.QToolBar(self)
        self._payload_tool_bar.addWidget(Qt.QLabel('Carga del mensaje'+": "))
        self._payload_line_edit = Qt.QLineEdit(str(self.payload))
        self._payload_tool_bar.addWidget(self._payload_line_edit)
        self._payload_line_edit.returnPressed.connect(
        	lambda: self.set_payload(str(str(self._payload_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._payload_tool_bar,  0,0,1,3)
        self.nseq_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "nseq")
        self._nseq_r_win = sip.wrapinstance(self.nseq_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._nseq_r_win,  4,1,1,1)
        self._nseq_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._nseq_formatter = None
        else:
          self._nseq_formatter = lambda x: x
        
        self._nseq_tool_bar.addWidget(Qt.QLabel('Numero de secuencia'+": "))
        self._nseq_label = Qt.QLabel(str(self._nseq_formatter(self.nseq)))
        self._nseq_tool_bar.addWidget(self._nseq_label)
        self.Tab_grid_layout_1 .addWidget(self._nseq_tool_bar,  4,0,1,1)
          
        self._label_payload_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_payload_formatter = None
        else:
          self._label_payload_formatter = lambda x: x
        
        self._label_payload_tool_bar.addWidget(Qt.QLabel('Carga'+": "))
        self._label_payload_label = Qt.QLabel(str(self._label_payload_formatter(self.label_payload)))
        self._label_payload_tool_bar.addWidget(self._label_payload_label)
        self.Tab_grid_layout_1 .addWidget(self._label_payload_tool_bar,  0,0,1,1)
          
        self._label_nwk_src_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_nwk_src_formatter = None
        else:
          self._label_nwk_src_formatter = lambda x: x
        
        self._label_nwk_src_tool_bar.addWidget(Qt.QLabel('Direccion NWK origen'+": "))
        self._label_nwk_src_label = Qt.QLabel(str(self._label_nwk_src_formatter(self.label_nwk_src)))
        self._label_nwk_src_tool_bar.addWidget(self._label_nwk_src_label)
        self.Tab_grid_layout_1 .addWidget(self._label_nwk_src_tool_bar,  1,0,1,1)
          
        self._label_nwk_dst_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_nwk_dst_formatter = None
        else:
          self._label_nwk_dst_formatter = lambda x: x
        
        self._label_nwk_dst_tool_bar.addWidget(Qt.QLabel('Direccion NWK destino'+": "))
        self._label_nwk_dst_label = Qt.QLabel(str(self._label_nwk_dst_formatter(self.label_nwk_dst)))
        self._label_nwk_dst_tool_bar.addWidget(self._label_nwk_dst_label)
        self.Tab_grid_layout_1 .addWidget(self._label_nwk_dst_tool_bar,  1,2,1,1)
          
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(False)
        self._gain_range = Range(1, 100, 1, 30, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Ganancia TX', "counter_slider", int)
        self.top_grid_layout.addWidget(self._gain_win, 0,0,1,1)
        self._freq_options = [1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)]
        self._freq_labels = ["11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27"]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Canal'+": "))
        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, 0,1,1,1)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, True, 10, 2000, 2000)
        _enviar_push_button = Qt.QPushButton('Enviar')
        self._enviar_choices = {'Pressed': True, 'Released': False}
        _enviar_push_button.pressed.connect(lambda: self.tfg_Aplication_0.send())
        _enviar_push_button.released.connect(lambda: self.set_enviar(self._enviar_choices['Released']))
        self.Tab_grid_layout_0 .addWidget(_enviar_push_button,  7,0,1,3)
        self.endpoint_src_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "endpoint_src")
        self._endpoint_src_r_win = sip.wrapinstance(self.endpoint_src_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_src_r_win,  2,1,1,1)
        self._endpoint_src_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._endpoint_src_formatter = None
        else:
          self._endpoint_src_formatter = lambda x: x
        
        self._endpoint_src_tool_bar.addWidget(Qt.QLabel('Enpoint origen'+": "))
        self._endpoint_src_label = Qt.QLabel(str(self._endpoint_src_formatter(self.endpoint_src)))
        self._endpoint_src_tool_bar.addWidget(self._endpoint_src_label)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_src_tool_bar,  2,0,1,1)
          
        self.endpoint_dst_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "endpoint_dst")
        self._endpoint_dst_r_win = sip.wrapinstance(self.endpoint_dst_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_dst_r_win,  2,3,1,1)
        self._endpoint_dst_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._endpoint_dst_formatter = None
        else:
          self._endpoint_dst_formatter = lambda x: x
        
        self._endpoint_dst_tool_bar.addWidget(Qt.QLabel('Endpoint destino'+": "))
        self._endpoint_dst_label = Qt.QLabel(str(self._endpoint_dst_formatter(self.endpoint_dst)))
        self._endpoint_dst_tool_bar.addWidget(self._endpoint_dst_label)
        self.Tab_grid_layout_1 .addWidget(self._endpoint_dst_tool_bar,  2,2,1,1)
          
        self.cluster_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "cluster")
        self._cluster_r_win = sip.wrapinstance(self.cluster_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._cluster_r_win,  3,1,1,1)
        self._clusterID_tool_bar = Qt.QToolBar(self)
        self._clusterID_tool_bar.addWidget(Qt.QLabel("ID de cluster"+": "))
        self._clusterID_line_edit = Qt.QLineEdit(str(self.clusterID))
        self._clusterID_tool_bar.addWidget(self._clusterID_line_edit)
        self._clusterID_line_edit.returnPressed.connect(
        	lambda: self.set_clusterID(int(str(self._clusterID_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._clusterID_tool_bar,  3,0,1,1)
        self._cluster_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._cluster_formatter = None
        else:
          self._cluster_formatter = lambda x: x
        
        self._cluster_tool_bar.addWidget(Qt.QLabel('ID de cluster'+": "))
        self._cluster_label = Qt.QLabel(str(self._cluster_formatter(self.cluster)))
        self._cluster_tool_bar.addWidget(self._cluster_label)
        self.Tab_grid_layout_1 .addWidget(self._cluster_tool_bar,  3,0,1,1)
          
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.NWK_add_src_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "NWK_add_src")
        self._NWK_add_src_r_win = sip.wrapinstance(self.NWK_add_src_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._NWK_add_src_r_win,  1,1,1,1)
        self.NWK_add_dst_r = qtgui.edit_box_msg(qtgui.INT, '', '', True, True, "NWK_add_dst")
        self._NWK_add_dst_r_win = sip.wrapinstance(self.NWK_add_dst_r.pyqwidget(), Qt.QWidget)
        self.Tab_grid_layout_1 .addWidget(self._NWK_add_dst_r_win,  1,3,1,1)
        self._NWK_add_dst_tool_bar = Qt.QToolBar(self)
        self._NWK_add_dst_tool_bar.addWidget(Qt.QLabel("Direccion NWK destino"+": "))
        self._NWK_add_dst_line_edit = Qt.QLineEdit(str(self.NWK_add_dst))
        self._NWK_add_dst_tool_bar.addWidget(self._NWK_add_dst_line_edit)
        self._NWK_add_dst_line_edit.returnPressed.connect(
        	lambda: self.set_NWK_add_dst(int(str(self._NWK_add_dst_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._NWK_add_dst_tool_bar,  1,2,1,1)
        self._Endpoint_src_tool_bar = Qt.QToolBar(self)
        self._Endpoint_src_tool_bar.addWidget(Qt.QLabel("Endpoint origen"+": "))
        self._Endpoint_src_line_edit = Qt.QLineEdit(str(self.Endpoint_src))
        self._Endpoint_src_tool_bar.addWidget(self._Endpoint_src_line_edit)
        self._Endpoint_src_line_edit.returnPressed.connect(
        	lambda: self.set_Endpoint_src(int(str(self._Endpoint_src_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._Endpoint_src_tool_bar,  2,0,1,1)
        self._Endpoint_dst_tool_bar = Qt.QToolBar(self)
        self._Endpoint_dst_tool_bar.addWidget(Qt.QLabel("Endpoint destino"+": "))
        self._Endpoint_dst_line_edit = Qt.QLineEdit(str(self.Endpoint_dst))
        self._Endpoint_dst_tool_bar.addWidget(self._Endpoint_dst_line_edit)
        self._Endpoint_dst_line_edit.returnPressed.connect(
        	lambda: self.set_Endpoint_dst(int(str(self._Endpoint_dst_line_edit.text().toAscii()))))
        self.Tab_grid_layout_0 .addWidget(self._Endpoint_dst_tool_bar,  2,2,1,1)

        ##################################################
        # Connections
        ##################################################
        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.tfg_translation_block_0, 'in(bastibl)'))    
        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.tfg_APS_stack_0, 'out(ZCL)'), (self.tfg_Aplication_0, 'in'))    
        self.msg_connect((self.tfg_APS_stack_0, 'out(NWK)'), (self.tfg_NWK_stack_0, 'in(APS)'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.NWK_add_dst_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.NWK_add_src_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.cluster_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.endpoint_dst_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.endpoint_src_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.nseq_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.payload_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.perfl_r, 'val'))    
        self.msg_connect((self.tfg_Aplication_0, 'out'), (self.tfg_APS_stack_0, 'in(ZCL)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(APS)'), (self.tfg_APS_stack_0, 'in(NWK)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(MAC)'), (self.tfg_translation_block_0, 'in(david)'))    
        self.msg_connect((self.tfg_translation_block_0, 'out(bastibl)'), (self.ieee802_15_4_mac_0, 'app in'))    
        self.msg_connect((self.tfg_translation_block_0, 'out(david)'), (self.tfg_NWK_stack_0, 'in(MAC)'))    
        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))    
Example #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))
Example #4
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))
Example #5
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Test Cognitiva Streaming")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8e6
        self.phy_ver = phy_ver = 0

        ##################################################
        # Blocks
        ##################################################
        self.foo_packet_pad_0_0_0 = foo.packet_pad(False, False, 0.001, 100, 100)
        self.foo_packet_pad_0_0 = foo.packet_pad(False, False, 0.001, 100, 100)
        self.cognitiva_phy_0_0 = cognitiva_phy(
            debug_mask=0,
            phy_ver=phy_ver,
        )
        self.cognitiva_phy_0 = cognitiva_phy(
            debug_mask=0,
            phy_ver=phy_ver,
        )
        self.cognitiva_cognitiva_mac_1 = cognitiva.cognitiva_mac(
          "::3040", 
          False, 
          0, 
          10, 
          0.1, 
          2.0, 
          True, 
          0.05, 
          10.0, 
          True, 
          True, 
          0)
          
        self.cognitiva_cognitiva_mac_0 = cognitiva.cognitiva_mac(
          "::1020", 
          False, 
          0, 
          10, 
          0.1, 
          2.0, 
          True, 
          0.05, 
          10.0, 
          True, 
          True, 
          0)
          
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len_stream")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 1024, "packet_len_stream")
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "../../../data/music_.mp3", True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/tchiwewe/Documents/music_fifo.mp3", False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.foo_packet_pad_0_0, 0), (self.cognitiva_phy_0_0, 0))
        self.connect((self.cognitiva_phy_0, 0), (self.blocks_throttle_1, 0))
        self.connect((self.blocks_throttle_1, 0), (self.foo_packet_pad_0_0, 0))
        self.connect((self.cognitiva_phy_0_0, 0), (self.foo_packet_pad_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.cognitiva_phy_0, 0))
        self.connect((self.foo_packet_pad_0_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_file_sink_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.cognitiva_cognitiva_mac_0, "mpdu out", self.cognitiva_phy_0, "from_mac")
        self.msg_connect(self.cognitiva_phy_0_0, "to_mac", self.cognitiva_cognitiva_mac_1, "mpdu in")
        self.msg_connect(self.cognitiva_phy_0, "to_mac", self.cognitiva_cognitiva_mac_0, "mpdu in")
        self.msg_connect(self.cognitiva_cognitiva_mac_1, "mpdu out", self.cognitiva_phy_0_0, "from_mac")
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0, "pdus", self.cognitiva_cognitiva_mac_0, "payload in")
        self.msg_connect(self.cognitiva_cognitiva_mac_1, "payload out", self.blocks_pdu_to_tagged_stream_0, "pdus")
Example #6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Test Cognitiva")

        ##################################################
        # Variables
        ##################################################
        self.variable_slider_0 = variable_slider_0 = 0
        self.samp_rate = samp_rate = 4e6
        self.phy_ver = phy_ver = 0

        ##################################################
        # Blocks
        ##################################################
        _variable_slider_0_sizer = wx.BoxSizer(wx.VERTICAL)
        self._variable_slider_0_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_variable_slider_0_sizer,
            value=self.variable_slider_0,
            callback=self.set_variable_slider_0,
            label='variable_slider_0',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._variable_slider_0_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_variable_slider_0_sizer,
            value=self.variable_slider_0,
            callback=self.set_variable_slider_0,
            minimum=0,
            maximum=1000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_variable_slider_0_sizer)
        self.foo_packet_pad_1 = foo.packet_pad(False, False, 0.001, 2000, 2000)
        self.foo_packet_pad_0 = foo.packet_pad(False, False, 0.001, 2000, 2000)
        self.cognitiva_phy_1 = cognitiva_phy(
            debug_mask=0,
            parameter_dwell_delay=0.001,
            parameter_fft_size=1024,
            parameter_tune_delay=0.1,
            phy_ver=phy_ver,
            samp_rate=samp_rate,
        )
        self.cognitiva_phy_0 = cognitiva_phy(
            debug_mask=0,
            parameter_dwell_delay=0.001,
            parameter_fft_size=1024,
            parameter_tune_delay=0.1,
            phy_ver=phy_ver,
            samp_rate=samp_rate,
        )
        self.cognitiva_cognitiva_mac_2 = cognitiva.cognitiva_mac(
            "::1020", 0, True, 0, 0, 0.1, 2.0, True, 0.05, 10.0, True, False,
            0)

        self.cognitiva_cognitiva_mac_1 = cognitiva.cognitiva_mac(
            "::3040", 0, True, 0, 10, 0.1, 2.0, True, 0.05, 10.0, True, True,
            0)

        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_socket_pdu_1 = blocks.socket_pdu("UDP_SERVER", "localhost",
                                                     "52002", 10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost",
                                                     "52001", 10000, False)
        self.blocks_random_pdu_0 = blocks.random_pdu(1024, 1024, chr(0xFF), 2)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern("TEST"), 1000)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, variable_slider_0 / 1000, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.blocks_random_pdu_0, 'generate'))
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'),
                         (self.cognitiva_cognitiva_mac_2, 'payload_in'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.cognitiva_cognitiva_mac_2, 'payload_in'))
        self.msg_connect((self.blocks_socket_pdu_1, 'pdus'),
                         (self.cognitiva_cognitiva_mac_1, 'payload_in'))
        self.msg_connect((self.cognitiva_cognitiva_mac_1, 'payload_out'),
                         (self.blocks_socket_pdu_1, 'pdus'))
        self.msg_connect((self.cognitiva_cognitiva_mac_1, 'control_out'),
                         (self.cognitiva_phy_1, 'control_in'))
        self.msg_connect((self.cognitiva_cognitiva_mac_1, 'mpdu_out'),
                         (self.cognitiva_phy_1, 'psdu_in'))
        self.msg_connect((self.cognitiva_cognitiva_mac_2, 'payload_out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.cognitiva_cognitiva_mac_2, 'control_out'),
                         (self.cognitiva_phy_0, 'control_in'))
        self.msg_connect((self.cognitiva_cognitiva_mac_2, 'mpdu_out'),
                         (self.cognitiva_phy_0, 'psdu_in'))
        self.msg_connect((self.cognitiva_phy_0, 'control_out'),
                         (self.cognitiva_cognitiva_mac_2, 'control_in'))
        self.msg_connect((self.cognitiva_phy_0, 'psdu_out'),
                         (self.cognitiva_cognitiva_mac_2, 'mpdu_in'))
        self.msg_connect((self.cognitiva_phy_1, 'control_out'),
                         (self.cognitiva_cognitiva_mac_1, 'control_in'))
        self.msg_connect((self.cognitiva_phy_1, 'psdu_out'),
                         (self.cognitiva_cognitiva_mac_1, 'mpdu_in'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.cognitiva_phy_0, 0), (self.foo_packet_pad_0, 0))
        self.connect((self.cognitiva_phy_1, 0), (self.foo_packet_pad_1, 0))
        self.connect((self.foo_packet_pad_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.foo_packet_pad_1, 0), (self.blocks_throttle_1, 0))
        self.connect((self.blocks_throttle_1, 0), (self.cognitiva_phy_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.cognitiva_phy_1, 0))
Example #7
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))
Example #8
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.time_preamble = time_preamble = [
            0.125000 + 0.000000j, 0.522104 - 0.148216j, -0.495528 + 0.114832j,
            -0.267916 + 0.091700j, 0.236544 - 0.138456j, -0.098500 + 0.473800j,
            0.476480 - 0.225344j, -0.187516 + 0.035372j, 0.051776 - 0.353552j,
            -0.104936 + 0.059916j, 0.228684 + 0.117504j, -0.530912 + 0.560756j,
            0.359128 + 0.015872j, -0.132852 + 0.632840j, -0.105164 - 0.368872j,
            0.368272 - 0.032412j, 0.125000 + 0.750000j, 0.463968 + 0.457792j,
            0.151476 - 0.430948j, 0.685052 + 0.238524j, 0.494428 + 0.119428j,
            -0.557540 - 0.050056j, 0.416348 + 0.017368j, 0.104256 - 0.568836j,
            -0.301776 - 0.353552j, 0.079812 + 0.451516j, 0.439152 + 0.528072j,
            0.642060 + 0.178484j, -0.090096 + 0.465096j, -0.446492 + 0.305776j,
            -0.111440 - 0.093688j, -0.538848 - 0.320228j, 0.125000 + 0.000000j,
            -0.538848 + 0.320228j, -0.111440 + 0.093688j,
            -0.446492 - 0.305776j, -0.090096 - 0.465096j, 0.642060 - 0.178484j,
            0.439152 - 0.528072j, 0.079812 - 0.451516j, -0.301776 + 0.353552j,
            0.104256 + 0.568836j, 0.416348 - 0.017368j, -0.557540 + 0.050056j,
            0.494428 - 0.119428j, 0.685052 - 0.238524j, 0.151476 + 0.430948j,
            0.463968 - 0.457792j, 0.125000 - 0.750000j, 0.368272 + 0.032412j,
            -0.105164 + 0.368872j, -0.132852 - 0.632840j, 0.359128 - 0.015872j,
            -0.530912 - 0.560756j, 0.228684 - 0.117504j, -0.104936 - 0.059916j,
            0.051776 + 0.353552j, -0.187516 - 0.035372j, 0.476480 + 0.225344j,
            -0.098500 - 0.473800j, 0.236544 + 0.138456j, -0.267916 - 0.091700j,
            -0.495528 - 0.114832j, 0.522104 + 0.148216j
        ]
        self.samp_rate = samp_rate = 2000000
        self.preamble_len = preamble_len = 64
        self.padding = padding = 12
        self.packet_len = packet_len = 1024 * 4
        self.length = length = 96
        self.gain = gain = 0.6850
        self.freq = freq = 3550e6

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 1, 0.001, 0.6850, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain",
                                     "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("", "serial= 30C6272")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_subdev_spec("A:A", 0)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0_0.set_normalized_gain(gain, 0)
        self.uhd_usrp_sink_0_0.set_antenna("TX/RX", 0)
        self.qtgui_freq_sink_x_0_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Virtual spectrum 2 at Tx",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_1.set_y_axis(-95, -25)
        self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1.enable_grid(False)
        self.qtgui_freq_sink_x_0_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_1.disable_legend()

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

        labels = ["MySVL Tx", "", "", "", "", "", "", "", "", ""]
        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_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_1_win, 2, 1,
                                       1, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Real Spectrum at the Transmitter",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-95, -25)
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

        labels = ["MySVL Tx", "", "", "", "", "", "", "", "", ""]
        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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 3, 0,
                                       1, 2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Virtual spectrum 1 at Tx",  #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(-95, -25)
        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_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 = ["MySVL Tx", "", "", "", "", "", "", "", "", ""]
        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, 2, 0, 1,
                                       1)
        self.mysvl_svl_0 = mysvl.svl(
            gr.sizeof_gr_complex * 1, 1,
            "/home/jonathan/Dropbox/repos/gr-mysvl/demo/inputs/maps/demo1b_tx.txt",
            "/home/jonathan/Dropbox/repos/gr-mysvl/demo/inputs/params/demo1b_tx.txt"
        )
        self.mysvl_stream_demux_0 = mysvl.stream_demux(
            gr.sizeof_gr_complex * 1, (1, packet_len - 2, 1), False)
        self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf(
            4,
            firdes.low_pass(1, samp_rate, samp_rate / 8 - samp_rate / 32,
                            samp_rate / 32, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, samp_rate / 2 - samp_rate / 32,
                            samp_rate / 32, firdes.WIN_HAMMING, 6.76))
        self.foo_packet_pad_0_0 = foo.packet_pad(False, False, 0.001, 1000, 0)
        self.foo_burst_tagger_0_0 = foo.burst_tagger(pmt.intern("len"), 1)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
            fft_len=64,
            cp_len=16,
            packet_length_tag_key="length",
            bps_header=1,
            bps_payload=1,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            time_preamble, True, 1, [])
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     "127.0.0.1", 3000, 1472,
                                                     True)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, length, "length")
        self.blocks_stream_mux_1 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1,
            (padding + 1, packet_len - 2, padding + 1))
        self.blocks_stream_mux_0 = blocks.stream_mux(
            gr.sizeof_gr_complex * 1, (preamble_len, packet_len + padding * 2))
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * 1,
                                               padding + 1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1,
                                             padding + 1)
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc(
            (0.3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.025, ))
        self.blocks_file_source_0_0_1 = blocks.file_source(
            gr.sizeof_char * 1,
            "/home/jonathan/Dropbox/repos/gr-mysvl/examples/inputs/Memory_and_Forgetting.mp3",
            True)
        self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=1,
                preamble="",
                access_code="",
                pad_for_usrp=False,
            ),
            payload_length=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_encoder_1, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0_0_1, 0),
                     (self.blks2_packet_encoder_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0),
                     (self.low_pass_filter_1_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_mux_1, 2))
        self.connect((self.blocks_repeat_0_0, 0),
                     (self.blocks_stream_mux_1, 0))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_stream_mux_1, 0),
                     (self.blocks_stream_mux_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_mux_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.digital_ofdm_tx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.foo_burst_tagger_0_0, 0),
                     (self.foo_packet_pad_0_0, 0))
        self.connect((self.foo_packet_pad_0_0, 0), (self.mysvl_svl_0, 1))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.foo_burst_tagger_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_1_0, 0), (self.mysvl_svl_0, 0))
        self.connect((self.low_pass_filter_1_0, 0),
                     (self.qtgui_freq_sink_x_0_1, 0))
        self.connect((self.mysvl_stream_demux_0, 2), (self.blocks_repeat_0, 0))
        self.connect((self.mysvl_stream_demux_0, 0),
                     (self.blocks_repeat_0_0, 0))
        self.connect((self.mysvl_stream_demux_0, 1),
                     (self.blocks_stream_mux_1, 1))
        self.connect((self.mysvl_svl_0, 0), (self.mysvl_stream_demux_0, 0))