def __init__(self, options):
        gr.top_block.__init__(self)

        self.samp_rate = samp_rate = 1000000
        self.band_width = band_width = 20000000
        if (options.tx_freq is not None):
            self.sink = iio.pluto_sink('193.168.2.1',
                                       options.tx_freq, samp_rate,
                                       long(options.bandwidth), 0x8000, False,
                                       10.0, '', True)
            #self.sink = uhd_transmitter(options.args,
            #                            options.bandwidth, options.tx_freq,
            #                            options.lo_offset, options.tx_gain,
            #                            options.spec, options.antenna,
            #                            options.clock_source, options.verbose)
        elif (options.to_file is not None):
            self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = blocks.null_sink(gr.sizeof_gr_complex)

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.txpath = transmit_path(options)

        self.connect(self.txpath, self.sink)
Example #2
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.samp_rate = samp_rate = 1000000

        self.source = iio.pluto_source(options.dev_ip,
                                       options.rx_freq, samp_rate,
                                       long(options.bandwidth * 2), 0xA000,
                                       True, True, True, "fast_attack", 64.0,
                                       '', True)
        """
        self.source = uhd_receiver(options.args,
                                   options.bandwidth,
                                   options.rx_freq,
                                   options.lo_offset, options.rx_gain,
                                   options.spec, options.antenna,
                                   options.clock_source, options.verbose)
        """
        #0x8000
        self.sink = iio.pluto_sink(options.dev_ip, options.tx_freq, samp_rate,
                                   long(options.bandwidth), 0xA000, False,
                                   10.0, '', True)
        """self.sink = uhd_transmitter(options.args,
                                    options.bandwidth, options.tx_freq,
                                    options.lo_offset, options.tx_gain,
                                    options.spec, options.antenna,
                                    options.clock_source, options.verbose)
        """
        self.txpath = transmit_path(options)
        self.rxpath = receive_path(callback, options)

        self.connect(self.txpath, self.sink)
        self.connect(self.source, self.rxpath)
 def __init__(self):
     gr.top_block.__init__(self, "Top Block")
     udp_source = blocks.udp_source(1, "192.168.0.2", 9992, 4)
     #ofdm_trans = digital.ofdm_txrx.ofdm_tx()
     ofdm_trans = o.Transmitter()
     radio = iio.pluto_sink(TRANSMITTER, CENTRAL_FREQUENCY, SAMPLE_RATE,
                            BANDWIDTH_RF, BUFFER_SIZE, False, ATTENUATION,
                            FILTER, AUTO_FILTER)
     self.connect(udp_source, ofdm_trans, radio)
Example #4
0
    def __init__(self):
        gr.top_block.__init__(self, "plutotransmitter")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.freq = freq = 2400000000

        ##################################################
        # Blocks
        ##################################################
        self.pluto_sink_0 = iio.pluto_sink('', 2400000000, freq, 500000,
                                           0x8000, False, 10.0, '', True)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=2,
            sensitivity=1.0,
            bt=.75,
            verbose=False,
            log=False,
        )
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/esft/datafiles/packet', True)
        self.blks2_packet_encoder_0 = 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_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.pluto_sink_0, 0))
Example #5
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Sin")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.pluto_sink_0 = iio.pluto_sink('192.168.2.1', 2400000000, 2084000,
                                           20000000, 0x8000, False, 10.0, '',
                                           True)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.pluto_sink_0, 0))
Example #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Transmitqpsk")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 6e6
        self.freq = freq = 2e6

        ##################################################
        # Blocks
        ##################################################
        self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', int(2400000000),
                                           int(samp_rate), int(freq), 0x8000,
                                           False, 10.0, '', True)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="none",
            differential=True,
            samples_per_symbol=3,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, 'ARGUS/SDRSDRTest/transmitted.bin', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 256, 2500000)), False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.pluto_sink_0, 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", "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 #8
0
    def __init__(self):
        gr.top_block.__init__(self, "Transmit")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Transmit")
        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", "transmit")

        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.samp_rate = samp_rate = 6e6
        self.freq = freq = 2e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            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.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', int(2500000000),
                                           int(samp_rate), int(freq), 0x8000,
                                           False, 10.0, '', True)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=4,
            mod_code="none",
            differential=True,
            samples_per_symbol=3,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   'transmitted.bin', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
Example #9
0
    def __init__(self, uri='ip:192.168.3.1'):
        grc_wxgui.top_block_gui.__init__(self,
                                         title="Video Transceiver (GMSK)")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Parameters
        ##################################################
        self.uri = uri

        ##################################################
        # Variables
        ##################################################
        self.signal = signal = 5000
        self.samp_rate = samp_rate = 2000000
        self.rfgain_tx = rfgain_tx = 0
        self.rfgain_rx = rfgain_rx = 15
        self.freq = freq = 437000000

        ##################################################
        # Blocks
        ##################################################
        _rfgain_rx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rfgain_rx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rfgain_rx_sizer,
            value=self.rfgain_rx,
            callback=self.set_rfgain_rx,
            label='RX Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rfgain_rx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rfgain_rx_sizer,
            value=self.rfgain_rx,
            callback=self.set_rfgain_rx,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rfgain_rx_sizer)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='TX FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            y_per_div=10,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='RX FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        _signal_sizer = wx.BoxSizer(wx.VERTICAL)
        self._signal_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_signal_sizer,
            value=self.signal,
            callback=self.set_signal,
            label='Signal',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._signal_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_signal_sizer,
            value=self.signal,
            callback=self.set_signal,
            minimum=0,
            maximum=32000,
            num_steps=320,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_signal_sizer)
        _rfgain_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rfgain_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rfgain_tx_sizer,
            value=self.rfgain_tx,
            callback=self.set_rfgain_tx,
            label='TX Gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rfgain_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rfgain_tx_sizer,
            value=self.rfgain_tx,
            callback=self.set_rfgain_tx,
            minimum=0,
            maximum=50,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rfgain_tx_sizer)
        self.pluto_source_0 = iio.pluto_source(uri, freq, samp_rate, 1 - 1,
                                               20000000, 0x8000, False, True,
                                               True, "manual", rfgain_rx, '',
                                               True)
        self.pluto_sink_0 = iio.pluto_sink(uri, freq, samp_rate, 1 - 1,
                                           20000000, 0x8000, False, 10.0, '',
                                           True)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 350000, 50000, firdes.WIN_HAMMING,
                            6.76))
        self.digital_gmskmod_bc_0 = digital.gmskmod_bc(2, 4, 0.350)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((30000, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       '/home/jay/txfifo.mkv',
                                                       False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/jay/Desktop/pluto_sink.mkv', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=True,
            ),
            payload_length=4000,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gmskmod_bc_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gmskmod_bc_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.pluto_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.pluto_source_0, 0), (self.wxgui_fftsink2_0, 0))
Example #10
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

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

        ##################################################
        # Variables
        ##################################################

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_qpsk(
        ).base()

        self.taps = taps = firdes.root_raised_cosine(32, 32, 0.5, 0.35,
                                                     50 * 32)

        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            400,  #size
            samp_rate,  #samp_rate
            "bits receiver",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(1)
        self.qtgui_time_sink_x_0_1.set_y_axis(-2, 2)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

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

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

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            320,  #size
            samp_rate,  #samp_rate
            "receiver",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(1)
        self.qtgui_time_sink_x_0_0.set_y_axis(-2, 2)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            400,  #size
            samp_rate,  #samp_rate
            "bits sender",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(1)
        self.qtgui_time_sink_x_0.set_y_axis(-2, 2)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

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

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pluto_source_0 = iio.pluto_source('ip:192.168.3.2',
                                               int(900000000), int(2000000),
                                               int(500000), 0x8000, True, True,
                                               True, "manual", 50, '', True)
        self.pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', int(900000000),
                                           int(2000000), int(1000000), 0x8000,
                                           False, 0, '', True)
        self.epy_block_3 = epy_block_3.blk(startString='10101010',
                                           escapeString='01111000',
                                           endString='01100110',
                                           preambleString='10000111',
                                           preambleLength=18)
        self.epy_block_2 = epy_block_2.blk(threshold=0.3)
        self.epy_block_1 = epy_block_1.blk()
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            4, 0.0628, (taps), 32, 16, 1.5, 1)
        self.digital_crc32_async_bb_0_0 = digital.crc32_async_bb(True)
        self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.055, 4, True)
        self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(
            variable_constellation_0)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=variable_constellation_0,
            differential=False,
            samples_per_symbol=4,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            30, 1, 0.001, 1)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_vector_source_x_0 = blocks.vector_source_b(
            (180, 180, 180, 180, 180, 180, 180, 180, 0), True, 1, [])
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 0.001)
        self.blocks_message_debug_1 = blocks.message_debug()
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.epy_block_1, 'msg_in'))
        self.msg_connect((self.digital_crc32_async_bb_0, 'out'),
                         (self.epy_block_3, 'packet_in'))
        self.msg_connect((self.digital_crc32_async_bb_0_0, 'out'),
                         (self.blocks_message_debug_1, 'print_pdu'))
        self.msg_connect((self.epy_block_1, 'msg_out'),
                         (self.digital_crc32_async_bb_0, 'in'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.epy_block_2, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.epy_block_2, 0),
                     (self.digital_constellation_soft_decoder_cf_0, 0))
        self.connect((self.epy_block_2, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_add_xx_0, 0))
Example #11
0
    def __init__(self,
                 hdr_format=digital.header_format_default(
                     digital.packet_utils.default_access_code, 0)):
        grc_wxgui.top_block_gui.__init__(self, title="QPSK")

        ##################################################
        # Parameters
        ##################################################
        self.hdr_format = hdr_format

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.excess_bw = excess_bw = 0.35
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            1, sps, 1, excess_bw, 45)

        self.qpsk1 = qpsk1 = digital.constellation_qpsk().base()

        self.our_txt = our_txt = 0
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
            self.GetWin(),
            title='Scope Plot',
            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.Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title='Scope Plot',
            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.Add(self.wxgui_scopesink2_0_0.win)
        self.pluto_source_0 = iio.pluto_source('ip:pluto.local',
                                               int(800000000), int(2084000),
                                               int(20000000), 0x8000, True,
                                               True, True, "manual", 15, '',
                                               True)
        self.pluto_sink_2 = iio.pluto_sink('ip:pluto.local', int(800000000),
                                           int(2084000), int(20000000), 0x8000,
                                           False, 0, '', True)
        self._our_txt_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.our_txt,
            callback=self.set_our_txt,
            label='our_txt',
            converter=forms.str_converter(),
        )
        self.Add(self._our_txt_text_box)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab1")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab2")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tab3")
        self.Add(self.notebook_0)
        self.low_pass_filter_2 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, 2084000, 1000000, 500000, firdes.WIN_HAMMING,
                            6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 0.0682, (rrc_taps), 64, 16, 1.5, sps)
        self.digital_map_bb_0 = digital.map_bb(([0, 1, 2, 3]))
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            21, 0.050, sps, qpsk1)
        self.digital_diff_decoder_bb_1 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.0628, 4, True)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk1,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/Users/cake/Desktop/Projects/plutoSDR/2byte.txt', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/Users/cake/Desktop/Projects/plutoSDR/out.txt', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code=code1,
                pad_for_usrp=False,
            ),
            payload_length=8,
        )
        self.blks2_packet_decoder_0_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code=code1,
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_char_to_float_1, 0),
                     (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blks2_packet_decoder_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_char_to_float_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_map_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.pluto_sink_2, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_1, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.digital_diff_decoder_bb_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.pluto_source_0, 0), (self.low_pass_filter_2, 0))
Example #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Lang Tx")

        ##################################################
        # Variables
        ##################################################
        self.PTT = PTT = False
        self.Mode = Mode = 0
        self.MicGain = MicGain = 5.0
        self.KEY = KEY = False
        self.Filt_Low = Filt_Low = 300
        self.Filt_High = Filt_High = 3000
        self.FMMIC = FMMIC = 50

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=11,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', 1000000000,
                                           528000, 2000000, 0x800, False, 0,
                                           '', True)
        self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc(
            ((Mode < 4) or (Mode == 5), ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc(
            (Mode == 4, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (FMMIC / 10.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            ((MicGain / 10.0) * (not (Mode == 2)) * (not (Mode == 3)), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc(
            ((0.5 * int(Mode == 5)) + (int(Mode == 2) * KEY) +
             (int(Mode == 3) * KEY), ))
        self.band_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, 48000, 200, 3000, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(48000, "hw:CARD=Device,DEV=0",
                                           False)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            48000, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=48000,
            quad_rate=48000,
            tau=75e-6,
            max_dev=3000,
            fh=-1,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-1,
                                               1.3 - (0.65 * (int(Mode == 5))),
                                               1.0)
        self.analog_agc2_xx_1.set_max_gain(10)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_1, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_2, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.band_pass_filter_1, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.analog_agc2_xx_1, 0))
        self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_mute_xx_0_0, 0))
Example #13
0
    def __init__(self):
        #initializing GUI window
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Graphs
        ##################################################
        #freq_sink
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            64,  #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)
        #time sink
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            64,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(1)
        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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        ##################################################
        # Blocks
        ##################################################
        """
                pluto sdr reciever side:
                    all parameters are set in the file settings.py 
        """
        self.pluto_receiver = iio.pluto_source(
            settings.RECEIVER, settings.CENTRAL_FREQUENCY,
            settings.SAMPLE_RATE, settings.BANDWIDTH_RF, settings.BUFFER_SIZE,
            settings.QUADRA_TRACKING, settings.DC_TRACKING,
            settings.BB_TRACKING, settings.GAIN_MODE, settings.MANUAL_GAIN,
            settings.FILTER, settings.AUTO_FILTER)
        """
                pluto sdr transmitter
                    all parameters set in the file settings.py
        """
        self.pluto_transmitter = iio.pluto_sink(
            settings.TRANSMITTER, settings.CENTRAL_FREQUENCY,
            settings.SAMPLE_RATE, settings.BANDWIDTH_RF, settings.BUFFER_SIZE,
            False, settings.ATTENUATION, settings.FILTER, settings.AUTO_FILTER)
        #self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.source_0 = source.blk()  #data source
        self.tx_0 = transmitter()  #block to create the OFDM symbols
        self.rx_0 = receiver(
        )  #block to handle and demodulate the received signal
        #self.throttler = blocks.throttle(gr.sizeof_char*1, 5000000,False)
        self.converter = blocks.char_to_float(
            1, 255)  #block only needed to visualize the results
        self.connect((self.source_0, 0), (self.tx_0, 0))
        #self.connect((self.tx_0,0),(self.blocks_tag_gate_0,0), (self.pluto_transmitter,0))
        self.connect((self.tx_0, 0), blocks.multiply_const_vcc((100, )),
                     (self.pluto_transmitter, 0))
        self.connect((self.pluto_receiver, 0),
                     blocks.file_sink(gr.sizeof_gr_complex, "received.dat"))
        self.connect((self.pluto_receiver, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.pluto_receiver, 0), (self.rx_0, 0))
        self.connect((self.rx_0, 0), (self.converter, 0),
                     (self.qtgui_time_sink_x_0, 0))
Example #14
0
    def __init__(self):
        gr.top_block.__init__(self, "Pure Noise")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pure Noise")
        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_noise")

        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.haven = haven = 0x100000
        
        ##################################################
        # 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.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_HORIZ,
            1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        units = ['', '', '', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            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(True)
        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_0 = iio.pluto_sink(d_txid, int(freq), int(4e6), int(20000000), buf, False, tx_gain, '', True)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_moving_average_xx_1 = blocks.moving_average_ff(haven/32, 1, 4000)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(haven/32, 1, 4000)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_float*1, '/home/hrbenitez/Desktop/just_sig.bin', False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, d_dir + '/snr_pure.bin', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_divide_xx_0 = blocks.divide_ff(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.pluto_sink_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_1, 0))
        self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
Example #15
0
    def __init__(self):
        gr.top_block.__init__(self, "SSB Transmitter V2 - F1ATB - MARCH 2021")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.LSB_USB = LSB_USB = 1
        self.GainRF_TX = GainRF_TX = 100
        self.GainIF_TX = GainIF_TX = 300
        self.GainBB_TX = GainBB_TX = 40
        self.Fr_TX = Fr_TX = 145200000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 9004), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_ccc(
            interpolation=120,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.pluto_sink_0 = iio.pluto_sink('192.168.2.1', 145000000,
                                           int(samp_rate), 0, 0x8000, False, 0,
                                           '', True)
        self.iio_attr_updater_0 = iio.attr_updater('frequency',
                                                   str(int(Fr_TX)), 2500)
        self.iio_attr_sink_0 = iio.attr_sink("ip:192.168.2.1", "ad9361-phy",
                                             "altvoltage1", 0, True, False)
        self.hilbert_fc_0 = filter.hilbert_fc(64, firdes.WIN_HAMMING, 6.76)
        (self.hilbert_fc_0).set_min_output_buffer(10)
        (self.hilbert_fc_0).set_max_output_buffer(10)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1,
                                                     '127.0.0.1', 9005, 512,
                                                     True)
        (self.blocks_udp_source_0).set_max_output_buffer(2048)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (LSB_USB, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.band_pass_filter_0_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate / 120,
                                     -1300 + LSB_USB * 1500,
                                     1300 + LSB_USB * 1500, 200,
                                     firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.iio_attr_updater_0, 'out'),
                         (self.iio_attr_sink_0, 'attr'))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.rational_resampler_xxx_1_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_short_to_float_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.hilbert_fc_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.rational_resampler_xxx_1_0, 0),
                     (self.pluto_sink_0, 0))
Example #16
0
    def __init__(self):
        gr.top_block.__init__(self, "Lang Tx")

        ##################################################
        # Variables
        ##################################################
        plutoip = os.environ.get('PLUTO_IP')
        if plutoip == None:
            plutoip = 'pluto.local'
        plutoip = 'ip:' + plutoip
        self.ToneBurst = ToneBurst = False
        self.PTT = PTT = False
        self.Mode = Mode = 0
        self.MicGain = MicGain = 5.0
        self.KEY = KEY = False
        self.Filt_Low = Filt_Low = 300
        self.Filt_High = Filt_High = 3000
        self.FMMIC = FMMIC = 50
        self.FFTEn = FFTEn = 0

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=11,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.pluto_sink_0 = iio.pluto_sink(plutoip, 1000000000, 528000,
                                           2000000, 0x800, False, 0, '', True)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
            sample_rate=48000,
            fft_size=512,
            ref_scale=2,
            frame_rate=15,
            avg_alpha=0.9,
            average=True,
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 512,
                                                 '127.0.0.1', 7374, 1472,
                                                 False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 512)
        self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc(
            ((Mode < 4) or (Mode == 5), ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc(
            (Mode == 4, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (FMMIC / 5.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            ((MicGain / 10.0) * (not (Mode == 2)) * (not (Mode == 3)), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc(
            ((0.5 * int(Mode == 5)) + (int(Mode == 2) * KEY) +
             (int(Mode == 3) * KEY), ))
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_float * 512,
            num_inputs=1,
            num_outputs=2,
            input_index=0,
            output_index=FFTEn,
        )
        self.band_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, 48000, 200, 3500, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, 48000, Filt_Low, Filt_High, 100,
                                     firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(48000, "hw:CARD=Device,DEV=0",
                                           False)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            48000, analog.GR_COS_WAVE, 1750, 1.0 * ToneBurst, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            48000, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_rail_ff_0 = analog.rail_ff(-1, 1)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=48000,
            quad_rate=48000,
            tau=1000e-6,
            max_dev=250,
            fh=-1,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-1,
                                               1.3 - (0.65 * (int(Mode == 5))),
                                               1.0)
        self.analog_agc2_xx_1.set_max_gain(10)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_1, 0),
                     (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.analog_rail_ff_0, 0), (self.band_pass_filter_1, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.band_pass_filter_0_0, 0),
                     (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blks2_selector_0, 1), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_rail_ff_0, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.logpwrfft_x_0, 0))
        self.connect((self.blocks_add_xx_2, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.analog_agc2_xx_1, 0))
        self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.logpwrfft_x_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_mute_xx_0_0, 0))
Example #17
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        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_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.pluto_sink_0 = iio.pluto_sink('', 2400000000, 2084000, 20000000, 0x8000, False, 10.0, '', True)
        self.howto_gain_0 = howto.gain(0.2)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.howto_gain_0, 0))
        self.connect((self.howto_gain_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.howto_gain_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.howto_gain_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
Example #18
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 1000000
        self.username = username = os.environ.get('USER')
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rrc_taps = rrc_taps = 20
        self.frequency = frequency = 970e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=frequency,
            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='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.trellis_encoder_xx_0 = trellis.encoder_bb(
            trellis.fsm(1, 2,
                        (0171, 0133)), 0, 0) if False else trellis.encoder_bb(
                            trellis.fsm(1, 2, (0171, 0133)), 0)
        self._symbol_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.symbol_rate,
            callback=self.set_symbol_rate,
            label='symbol_rate',
            choices=[333000, 500000, 1000000, 1200000, 1500000],
            labels=["333kS/s", "500 kS/s", "1000kS/s", "1200kS/s", "1500kS/s"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._symbol_rate_chooser)
        self.pluto_sink_0 = iio.pluto_sink('', int(frequency), int(samp_rate),
                                           int(9000000), 0x8000, False, 0.0,
                                           '', True)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1.79, samp_rate, samp_rate / 2, 0.35,
                                          rrc_taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.dvbs_reed_solomon_enc_bb_0 = dvbs.reed_solomon_enc_bb()
        self.dvbs_randomizer_bb_0 = dvbs.randomizer_bb()
        self.dvbs_puncture_bb_0 = dvbs.puncture_bb(dvbs.C1_2)
        self.dvbs_modulator_bc_0 = dvbs.modulator_bc()
        self.dvbs_interleaver_bb_0 = dvbs.interleaver_bb()
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2)
        self.blocks_file_source_1 = blocks.file_source(
            gr.sizeof_char * 1,
            "/media/" + username + "/PlutoSDR/MPEG2-lalinea.ts", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_1, 0),
                     (self.dvbs_randomizer_bb_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.dvbs_modulator_bc_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.trellis_encoder_xx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.dvbs_puncture_bb_0, 0))
        self.connect((self.dvbs_interleaver_bb_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.dvbs_modulator_bc_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.dvbs_puncture_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.dvbs_randomizer_bb_0, 0),
                     (self.dvbs_reed_solomon_enc_bb_0, 0))
        self.connect((self.dvbs_reed_solomon_enc_bb_0, 0),
                     (self.dvbs_interleaver_bb_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.trellis_encoder_xx_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
Example #19
0
    def __init__(self):
        gr.top_block.__init__(
            self, "Test Signal.  Adds a Short pulse in a narrow Band")
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "Test Signal.  Adds a Short pulse in a narrow Band")
        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", "NsfPing")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.OffsetMHz = OffsetMHz = 0.111
        self.FreqMHz = FreqMHz = 1398
        self.samp_rate = samp_rate = 100000
        self.fftsize = fftsize = 2048
        self.Offset = Offset = OffsetMHz * 1.E6
        self.Mode = Mode = 2
        self.H1 = H1 = 1420.406E6
        self.Gain1 = Gain1 = 40
        self.Frequency = Frequency = FreqMHz * 1.E6
        self.EventMode = EventMode = 0
        self.Bandwidth = Bandwidth = 4e6
        self.Attn1 = Attn1 = 80

        ##################################################
        # Blocks
        ##################################################
        self._Mode_options = (
            0,
            2,
        )
        self._Mode_labels = (
            'Monitor',
            'Detect',
        )
        self._Mode_tool_bar = Qt.QToolBar(self)
        self._Mode_tool_bar.addWidget(Qt.QLabel('Data Mode' + ": "))
        self._Mode_combo_box = Qt.QComboBox()
        self._Mode_tool_bar.addWidget(self._Mode_combo_box)
        for label in self._Mode_labels:
            self._Mode_combo_box.addItem(label)
        self._Mode_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._Mode_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._Mode_options.index(i)))
        self._Mode_callback(self.Mode)
        self._Mode_combo_box.currentIndexChanged.connect(
            lambda i: self.set_Mode(self._Mode_options[i]))
        self.top_grid_layout.addWidget(self._Mode_tool_bar, 6, 0, 1, 2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Attn1_tool_bar = Qt.QToolBar(self)
        self._Attn1_tool_bar.addWidget(Qt.QLabel('Attn1' + ": "))
        self._Attn1_line_edit = Qt.QLineEdit(str(self.Attn1))
        self._Attn1_tool_bar.addWidget(self._Attn1_line_edit)
        self._Attn1_line_edit.returnPressed.connect(lambda: self.set_Attn1(
            eng_notation.str_to_num(str(self._Attn1_line_edit.text().toAscii())
                                    )))
        self.top_grid_layout.addWidget(self._Attn1_tool_bar, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.radio_astro_detect_0 = radio_astro.detect(
            fftsize, 5, Frequency, Bandwidth, fftsize * 1.e-6 / Bandwidth,
            Mode)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            fftsize,  #size
            Bandwidth,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(1)
        self.qtgui_time_sink_x_0_0.set_y_axis(-.3, .3)

        self.qtgui_time_sink_x_0_0.set_y_label('Event', "")

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 2, 2,
                                       5, 7)
        for r in range(2, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 9):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
            fftsize, 100, -.4, .4, "", 2)

        self.qtgui_histogram_sink_x_0.set_update_time(1.)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(False)
        self.qtgui_histogram_sink_x_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_histogram_sink_x_0.disable_legend()

        labels = ['I', 'Q', '', '', '', '', '', '', '', '']
        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"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(
            self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_histogram_sink_x_0_win, 2,
                                       0, 3, 2)
        for r in range(2, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pluto_sink_0 = iio.pluto_sink('', int(float(Frequency + Offset)),
                                           int(float(Bandwidth)),
                                           int(20000000), 0x8000, False,
                                           float(Attn1), '', True)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fftsize)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(.999999, 1., 1.)
        (self.blocks_threshold_ff_0).set_max_output_buffer(1)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fftsize)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((10, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.2, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_SAW_WAVE, .02, 1.00001, 0)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, .15, 0)
        self.Ping = qtgui.number_sink(gr.sizeof_float, 0,
                                      qtgui.NUM_GRAPH_HORIZ, 1)
        self.Ping.set_update_time(0.10)
        self.Ping.set_title("Ramp")

        labels = ['Ping', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.Ping.set_min(i, 0.)
            self.Ping.set_max(i, 1)
            self.Ping.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.Ping.set_label(i, "Data {0}".format(i))
            else:
                self.Ping.set_label(i, labels[i])
            self.Ping.set_unit(i, units[i])
            self.Ping.set_factor(i, factor[i])

        self.Ping.enable_autoscale(False)
        self._Ping_win = sip.wrapinstance(self.Ping.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._Ping_win, 0, 4, 2, 5)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 9):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._OffsetMHz_tool_bar = Qt.QToolBar(self)
        self._OffsetMHz_tool_bar.addWidget(Qt.QLabel('OffsetMHz)' + ": "))
        self._OffsetMHz_line_edit = Qt.QLineEdit(str(self.OffsetMHz))
        self._OffsetMHz_tool_bar.addWidget(self._OffsetMHz_line_edit)
        self._OffsetMHz_line_edit.returnPressed.connect(
            lambda: self.set_OffsetMHz(
                eng_notation.str_to_num(
                    str(self._OffsetMHz_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._OffsetMHz_tool_bar, 1, 2, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._Gain1_tool_bar = Qt.QToolBar(self)
        self._Gain1_tool_bar.addWidget(Qt.QLabel('Gain1' + ": "))
        self._Gain1_line_edit = Qt.QLineEdit(str(self.Gain1))
        self._Gain1_tool_bar.addWidget(self._Gain1_line_edit)
        self._Gain1_line_edit.returnPressed.connect(lambda: self.set_Gain1(
            eng_notation.str_to_num(str(self._Gain1_line_edit.text().toAscii())
                                    )))
        self.top_grid_layout.addWidget(self._Gain1_tool_bar, 0, 0, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._FreqMHz_tool_bar = Qt.QToolBar(self)
        self._FreqMHz_tool_bar.addWidget(Qt.QLabel('Freq (MHz)' + ": "))
        self._FreqMHz_line_edit = Qt.QLineEdit(str(self.FreqMHz))
        self._FreqMHz_tool_bar.addWidget(self._FreqMHz_line_edit)
        self._FreqMHz_line_edit.returnPressed.connect(lambda: self.set_FreqMHz(
            eng_notation.str_to_num(
                str(self._FreqMHz_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._FreqMHz_tool_bar, 0, 2, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._EventMode_options = (
            0,
            1,
        )
        self._EventMode_labels = (
            'Wait',
            'Write',
        )
        self._EventMode_tool_bar = Qt.QToolBar(self)
        self._EventMode_tool_bar.addWidget(Qt.QLabel('Write Mode' + ": "))
        self._EventMode_combo_box = Qt.QComboBox()
        self._EventMode_tool_bar.addWidget(self._EventMode_combo_box)
        for label in self._EventMode_labels:
            self._EventMode_combo_box.addItem(label)
        self._EventMode_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._EventMode_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._EventMode_options.index(i)))
        self._EventMode_callback(self.EventMode)
        self._EventMode_combo_box.currentIndexChanged.connect(
            lambda i: self.set_EventMode(self._EventMode_options[i]))
        self.top_grid_layout.addWidget(self._EventMode_tool_bar, 5, 0, 1, 2)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0), (self.Ping, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.qtgui_histogram_sink_x_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.radio_astro_detect_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.radio_astro_detect_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
Example #20
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):
        grc_wxgui.top_block_gui.__init__(self, title="Dvbs Tx Tcp Monitor")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.symbol_rate = symbol_rate = 1000000
        self.samp_rate = samp_rate = symbol_rate * 2
        self.rrc_taps = rrc_taps = 100
        self.frequency = frequency = 970000000

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=frequency,
            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=0.13333,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.trellis_encoder_xx_0 = trellis.encoder_bb(
            trellis.fsm(1, 2,
                        (0171, 0133)), 0, 0) if False else trellis.encoder_bb(
                            trellis.fsm(1, 2, (0171, 0133)), 0)
        self._symbol_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.symbol_rate,
            callback=self.set_symbol_rate,
            label='symbol_rate',
            choices=[250000, 333000, 500000, 1000000, 1200000, 1500000],
            labels=[
                "250kS/s", "333kS/s", "500 kS/s", "1000kS/s", "1200kS/s",
                "1500kS/s"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._symbol_rate_chooser)
        self.pluto_sink_0 = iio.pluto_sink('', int(frequency), int(samp_rate),
                                           int(20000000), 0x8000, False, 5.0,
                                           '', True)
        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.root_raised_cosine(1.0, samp_rate, samp_rate / 2, 0.35,
                                          rrc_taps)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.fec_puncture_xx_0 = fec.puncture_bb(14, 0b11010101100110, 0)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            136, 12, 17)
        self.dtv_dvbs2_modulator_bc_0 = dtv.dvbs2_modulator_bc(
            dtv.FECFRAME_NORMAL, dtv.C5_6, dtv.MOD_QPSK, dtv.INTERPOLATION_ON)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     '127.0.0.1', 58000, 1472,
                                                     False)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(2)
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
            itemsize=gr.sizeof_char * 1,
            addr='0.0.0.0',
            port=57000,
            server=True,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.dtv_dvbs2_modulator_bc_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.trellis_encoder_xx_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.fec_puncture_xx_0, 0))
        self.connect((self.dtv_dvbs2_modulator_bc_0, 0),
                     (self.fft_filter_xxx_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.fec_puncture_xx_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.trellis_encoder_xx_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
Example #22
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Tx")

        ##################################################
        # Variables
        ##################################################
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.length_tag_key = length_tag_key = "packet_len"
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 1000000
        self.rolloff = rolloff = 0
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_len = packet_len = 96
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.hdr_format = hdr_format = digital.header_format_ofdm(
            occupied_carriers,
            1,
            length_tag_key,
        )
        self.fft_len = fft_len = 64
        self.band_width = band_width = 20000000

        ##################################################
        # Blocks
        ##################################################
        self.pluto_sink_0 = iio.pluto_sink('193.168.2.1', 500000000, samp_rate,
                                           band_width, 0x8000, False, 10.0, '',
                                           True)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, length_tag_key)
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            frame_length_tag_key='frame_' + "length",
            packet_length_tag_key="length",
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len / 4, rolloff, length_tag_key)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), length_tag_key)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (payload_mod.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (header_mod.points()), 1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.0,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=True)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     '0.0.0.0', 1234, 1472,
                                                     True)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1,
                                                   "Rx'd Packets", "")
        self.blocks_tag_debug_0.set_display(True)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_ofdm_rx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
    def __init__(self, pluto_uri='usb:1.5.5'):
        gr.top_block.__init__(self, "Aprs Full Duplex Pluto")

        ##################################################
        # Parameters
        ##################################################
        self.pluto_uri = pluto_uri

        ##################################################
        # Variables
        ##################################################
        self.audio_samp = audio_samp = 24000
        self.source_samp = source_samp = 44100
        self.samp_rate = samp_rate = audio_samp * 22
        self.refresh_rate = refresh_rate = 10
        self.cutoff_frequency = cutoff_frequency = 100e3
        self.center_frequency = center_frequency = 435e6
        self.Decay = Decay = 0.1
        self.Attack = Attack = 0.8

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=source_samp,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.pluto_source_0 = iio.pluto_source(pluto_uri,
                                               int(center_frequency),
                                               samp_rate, 20000000, 0x8000,
                                               True, True, True, "manual",
                                               64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink(pluto_uri, int(center_frequency),
                                           samp_rate, 20000000, 0x8000, False,
                                           10.0, '', True)
        self.detectMarkSpace_1_0_0 = detectMarkSpace(
            decay=Decay,
            samp_rate=audio_samp,
            attack=Attack,
            Frequency=2200,
        )
        self.detectMarkSpace_0_0_0 = detectMarkSpace(
            decay=Decay,
            samp_rate=audio_samp,
            attack=Attack,
            Frequency=1200,
        )
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/pi/aprs_web_client/aprs_test_message.wav', True)
        self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/pi/aprs_web_client/full_duplex.log',
            True)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.band_pass_filter_0_0_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, audio_samp, 950, 2450, 100, firdes.WIN_HAMMING,
                             6.76))
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=source_samp,
            quad_rate=source_samp,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=audio_samp,
            quad_rate=int(samp_rate),
            tau=75e-6,
            max_dev=5e3,
        )
        self.afsk_ax25decode_1_0 = afsk.ax25decode(audio_samp, 5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.afsk_ax25decode_1_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.detectMarkSpace_0_0_0, 0))
        self.connect((self.band_pass_filter_0_0_0, 0),
                     (self.detectMarkSpace_1_0_0, 0))
        self.connect((self.blocks_sub_xx_0_0_0_0, 0),
                     (self.afsk_ax25decode_1_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.detectMarkSpace_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 0))
        self.connect((self.detectMarkSpace_1_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 1))
        self.connect((self.pluto_source_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.band_pass_filter_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0, 0),
                     (self.pluto_sink_0, 0))
Example #24
0
    def __init__(self):
        gr.top_block.__init__(self, "Ssb Trx")

        ##################################################
        # Variables
        ##################################################
        self.BaseFreq = BaseFreq = 1296250000
        self.USB = USB = True
        self.TxOffset = TxOffset = 0
        self.TxLO = TxLO = BaseFreq-10000
        self.SQL = SQL = 20
        self.RxOffset = RxOffset = 0
        self.PTT = PTT = False
        self.NCW = NCW = False
        self.MicGain = MicGain = 5.0
        self.MON = MON = False
        self.KEY = KEY = False
        self.FMMIC = FMMIC = 50
        self.FM = FM = True
        self.CW = CW = False
        self.AFGain = AFGain = 20

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=12,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.pluto_source_0 = iio.pluto_source('ip:192.168.2.1', BaseFreq, 529200, 2000000, 0x800, True, True, True, "slow_attack", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', TxLO, 529200, 2000000, 0x800, False, 0, '', True)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(12, (firdes.low_pass(1,529200,12000,6000)), RxOffset, 529200)
        self.blocks_mute_xx_0_0 = blocks.mute_cc(bool(not PTT))
        self.blocks_mute_xx_0 = blocks.mute_ff(bool(PTT and (not MON)))
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc((not FM, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc((FM, ))
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vff((int(FM) *0.1, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((not FM, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((AFGain/10.0, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((FMMIC/10.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(((MicGain/10.0)*(not CW), ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.band_pass_filter_1 = filter.fir_filter_fff(1, firdes.band_pass(
        	1, 44100, 200, 3000, 100, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.band_pass(
        	1, 44100, -3000+USB*3300+10000, -300+USB*3300+10000, 100, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass(
        	1, 44100, -3000+USB*3300+NCW*CW*250, -300+USB*3300-NCW*CW*1950, 100, firdes.WIN_HAMMING, 6.76))
        self.audio_source_0 = audio.source(44100, "hw:CARD=Device,DEV=0", True)
        self.audio_sink_0 = audio.sink(44100, "hw:CARD=Device,DEV=0", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60+SQL, 1)
        self.analog_sig_source_x_1_0 = analog.sig_source_f(44100, analog.GR_COS_WAVE, 800, int(CW and KEY), 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(529200, analog.GR_COS_WAVE, TxOffset, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(44100, analog.GR_COS_WAVE, 10000, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=44100,
        	quad_rate=44100,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_sig_source_x_1_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.band_pass_filter_1, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.blocks_mute_xx_0, 0))
        self.connect((self.blocks_add_xx_2, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.band_pass_filter_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0), (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_mute_xx_0_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_mute_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_mute_xx_0_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
Example #25
0
    def __init__(self, Pi=3.14159, chirp_time=260000000):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

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

        ##################################################
        # Parameters
        ##################################################
        self.Pi = Pi
        self.chirp_time = chirp_time

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2032920
        self.q = q = 10000
        self.lo = lo = 2033000000
        self.f_dev = f_dev = 10
        self.f_c = f_c = 2
        self.del1 = del1 = 524880
        self.deci = deci = 220

        ##################################################
        # Blocks
        ##################################################
        self._lo_range = Range(10000000, 6000000000, 100000, 2033000000, 200)
        self._lo_win = RangeWidget(self._lo_range, self.set_lo, 'lo freq', "counter_slider", float)
        self.top_layout.addWidget(self._lo_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=deci,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)



        self._q_range = Range(10000, 10000000, 1, 10000, 200)
        self._q_win = RangeWidget(self._q_range, self.set_q, 'Q', "counter_slider", int)
        self.top_layout.addWidget(self._q_win)
        self.pluto_source_0 = iio.pluto_source('ip:pluto.local', lo, samp_rate, 1 - 1, 1000000, 0x8000, False, False, True, "manual", 60, '', True)
        self.pluto_sink_0 = iio.pluto_sink('ip:pluto.local', lo, samp_rate, 1 - 1, 1000000, 0x8000, False, 0, '', True)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 628318, 1)
        self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_float*1, del1)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, del1)
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex*1, 20000000)
        self.blocks_head_0 = blocks.head(gr.sizeof_float*1, 20000000)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_float*1, '/home/raidfire/gpr/data/test_multi.bin', False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, '/home/raidfire/gpr/data/test_saw.bin', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_SAW_WAVE, 3.84615, f_dev, f_c)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_skiphead_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_head_1, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_head_1, 0), (self.pluto_sink_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_1, 0))
        self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_head_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_sink_x_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "NBFM_transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("NBFM_transceiver")
        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", "NBFM_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.rx_freq = rx_freq = 141050000
        self.offset = offset = 5000000
        self.tx_gain = tx_gain = 15
        self.tx_freq = tx_freq = rx_freq - offset
        self.sqch = sqch = -60
        self.sdr_samp_rate = sdr_samp_rate = samp_rate * 12
        self.rx_tx = rx_tx = 0
        self.rx_gain = rx_gain = 10
        self.rx_freq_fine = rx_freq_fine = 0
        self.rx_aud = rx_aud = 0.300

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_range = Range(0, 90, 1, 15, 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, 2, 2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sqch_range = Range(-110, -50, 1, -60, 200)
        self._sqch_win = RangeWidget(self._sqch_range, self.set_sqch,
                                     'rx_sqlch', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sqch_win, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._sdr_samp_rate_range = Range(520833, 61440000, 100000,
                                          samp_rate * 12, 200)
        self._sdr_samp_rate_win = RangeWidget(self._sdr_samp_rate_range,
                                              self.set_sdr_samp_rate,
                                              'sdr_sample_rate',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._sdr_samp_rate_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_tx_options = (
            0,
            1,
        )
        self._rx_tx_labels = (
            'RX',
            'TX',
        )
        self._rx_tx_group_box = Qt.QGroupBox('rx_tx_pushbutton')
        self._rx_tx_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._rx_tx_button_group = variable_chooser_button_group()
        self._rx_tx_group_box.setLayout(self._rx_tx_box)
        for i, label in enumerate(self._rx_tx_labels):
            radio_button = Qt.QRadioButton(label)
            self._rx_tx_box.addWidget(radio_button)
            self._rx_tx_button_group.addButton(radio_button, i)
        self._rx_tx_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._rx_tx_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._rx_tx_options.index(i)))
        self._rx_tx_callback(self.rx_tx)
        self._rx_tx_button_group.buttonClicked[int].connect(
            lambda i: self.set_rx_tx(self._rx_tx_options[i]))
        self.top_grid_layout.addWidget(self._rx_tx_group_box, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_range = Range(0, 50, 1, 10, 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, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_range = Range(88000000, 174000000, 25000, 141050000, 200)
        self._rx_freq_win = RangeWidget(self._rx_freq_range, self.set_rx_freq,
                                        'rx_freq', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_freq_win, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_aud_range = Range(0, 0.5, 0.05, 0.300, 200)
        self._rx_aud_win = RangeWidget(self._rx_aud_range, self.set_rx_aud,
                                       'rx_audio_gain', "counter_slider",
                                       float)
        self.top_grid_layout.addWidget(self._rx_aud_win, 2, 1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_options = (
            5000000,
            600000,
        )
        self._offset_labels = (
            '5Mhz',
            '600kHz',
        )
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('rx_tx_offset' + ": "))
        self._offset_combo_box = Qt.QComboBox()
        self._offset_tool_bar.addWidget(self._offset_combo_box)
        for label in self._offset_labels:
            self._offset_combo_box.addItem(label)
        self._offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._offset_options.index(i)))
        self._offset_callback(self.offset)
        self._offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_offset(self._offset_options[i]))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_freq_tool_bar = Qt.QToolBar(self)

        if None:
            self._tx_freq_formatter = None
        else:
            self._tx_freq_formatter = lambda x: eng_notation.num_to_str(x)

        self._tx_freq_tool_bar.addWidget(Qt.QLabel('tx_freq' + ": "))
        self._tx_freq_label = Qt.QLabel(
            str(self._tx_freq_formatter(self.tx_freq)))
        self._tx_freq_tool_bar.addWidget(self._tx_freq_label)
        self.top_grid_layout.addWidget(self._tx_freq_tool_bar, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_fine_range = Range(-10000, 10000, 100, 0, 200)
        self._rx_freq_fine_win = RangeWidget(self._rx_freq_fine_range,
                                             self.set_rx_freq_fine,
                                             'rx_freq_fine', "counter_slider",
                                             float)
        self.top_grid_layout.addWidget(self._rx_freq_fine_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0_1 = filter.rational_resampler_ccf(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=samp_rate,
            decimation=sdr_samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=sdr_samp_rate,
            decimation=samp_rate,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            256,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            rx_freq,  #fc
            25000,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win, 4, 0, 6, 3)
        for r in range(4, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 3):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.pluto_source_0 = iio.pluto_source('', rx_freq, sdr_samp_rate,
                                               15000, 0x4000, True, True, True,
                                               "manual",
                                               rx_gain * ((-rx_tx) + 1), '',
                                               True)
        self.pluto_sink_0 = iio.pluto_sink('192.168.2.1', rx_freq - offset,
                                           sdr_samp_rate, 5000, 0x4000, False,
                                           -tx_gain * (rx_tx), '', True)
        self.low_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 20000, 500, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 16000, 200, firdes.WIN_HAMMING,
                            6.76))
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (rx_aud * (-(rx_tx) + 1), ))
        self.audio_sink_0 = audio.sink(48000,
                                       "Speakers (Conexant SmartAudio HD)",
                                       True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(sqch, 1)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            sdr_samp_rate, analog.GR_COS_WAVE, 0, 1, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=samp_rate,
            quad_rate=samp_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=48000,
            quad_rate=48000,
            tau=50e-6,
            max_dev=12.5e3,
        )
        self.Internal_Microphone = audio.source(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Internal_Microphone, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0_1, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_1, 0),
                     (self.qtgui_sink_x_0, 0))
Example #27
0
    def __init__(self, interpolation=2, wav_file='/hispeed/test1.wav'):
        gr.top_block.__init__(self, "Fm Send")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Send")
        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", "fm_send")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.interpolation = interpolation
        self.wav_file = wav_file

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2304000
        self.fm_station = fm_station = 401100000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=8 / interpolation,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.pluto_sink_0 = iio.pluto_sink('193.168.2.1', fm_station,
                                           samp_rate, 20000, 0x8000, False,
                                           10.0, '', True)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(wav_file, True)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=48000,
            quad_rate=samp_rate / 8,
            tau=75e-6,
            max_dev=75e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_sink_x_0, 0))
Example #28
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10000000
        self.freq = freq = 2412000000

        ##################################################
        # Blocks
        ##################################################
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            label='frequency',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_freq_sizer,
            value=self.freq,
            callback=self.set_freq,
            minimum=325000000,
            maximum=3800000000,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.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=False,
            avg_alpha=None,
            title='FFT Plot',
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.pluto_sink_0 = iio.pluto_sink('', freq, samp_rate, 20000000,
                                           0x8000, False, 10.0, '', True)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 4000000, 1000000, firdes.WIN_HAMMING,
                            5))
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_UNIFORM, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
Example #29
0
    def __init__(self,
                 audio_device="dmix:CARD=monitor,DEV=0",
                 decimation=1,
                 fm_station=401100000,
                 hostname='127.0.0.1',
                 interpolation=2,
                 uri='193.168.2.1',
                 wav_file='/home/work/github/gnuradio/grexample/111.wav'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.audio_device = audio_device
        self.decimation = decimation
        self.fm_station = fm_station
        self.hostname = hostname
        self.interpolation = interpolation
        self.uri = uri
        self.wav_file = wav_file

        ##################################################
        # Variables
        ##################################################
        self.sample_rate = sample_rate = 2200000
        self.samp_rate = samp_rate = 2304000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=8 / interpolation,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.pluto_source_0 = iio.pluto_source(uri, fm_station, sample_rate,
                                               20000000, 0x20000, True, True,
                                               True, "manual", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink(uri, fm_station, samp_rate, 20000,
                                           0x8000, False, 10.0, '', True)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            sample_rate / (384000 * decimation),
            firdes.low_pass(1, sample_rate / decimation, 44100, 44100,
                            firdes.WIN_HAMMING, 6.76))
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/work/github/gnuradio/grexample/111.wav', True)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_sink_0 = audio.sink(48000, audio_device, True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=384000,
            audio_decimation=8,
        )
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=48000,
            quad_rate=samp_rate / 8,
            tau=75e-6,
            max_dev=75e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.pluto_source_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.pluto_sink_0, 0))
Example #30
0
    def __init__(self, channel, processor, sdr_device="pluto-sdr"):
        gr.top_block.__init__(self, "Tx Flow")

        ##################################################
        # Variables
        ##################################################
        self.channel = channel
        self.sdr_device = sdr_device
        self.processor = processor

        ##################################################
        # Blocks
        ##################################################
        if self.sdr_device == "hackrf":
            self.sdr_sink = osmosdr.sink(args="numchan=1")
            self.sdr_sink.set_sample_rate(4e6)
            self.sdr_sink.set_center_freq(self.get_center_freq(), 0)
            self.sdr_sink.set_freq_corr(0, 0)
            self.sdr_sink.set_gain(10, 0)
            self.sdr_sink.set_if_gain(20, 0)
            self.sdr_sink.set_bb_gain(20, 0)
            self.sdr_sink.set_antenna('', 0)
            self.sdr_sink.set_bandwidth(0, 0)
        elif self.sdr_device == "pluto-sdr":
            self.sdr_sink = iio.pluto_sink('192.168.2.1',
                                           self.get_center_freq(), int(4e6),
                                           int(4e6), 0x8000, False, 0, '',
                                           True)
            self.sdr_source = iio.pluto_source('192.168.2.1',
                                               self.get_center_freq(),
                                               int(4e6), int(4e6), 0x8000,
                                               True, True, True, "manual", 50,
                                               '', True)

        self.ieee802_15_4_access_code_prefixer_0 = ieee802_15_4.access_code_prefixer(
        )
        self.es_source_0 = es.source(1 * [gr.sizeof_gr_complex], 1, 2, 0)
        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.blocks_vector_source_x_0 = blocks.vector_source_c(
            [0, sin(pi / 4), 1, sin(3 * pi / 4)], True, 1, [])
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, 'pdu_length')
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, 'pdu_length', 128)
        self.blocks_tagged_stream_multiply_length_0.set_min_output_buffer(
            20000)
        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_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)

        self.msg_in_0 = msg_block_source()

        if self.sdr_device == "pluto-sdr":
            self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
            self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex *
                                                       1)

            self.msg_out_0 = msg_sink_block(self.processor)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.es_source_0, 'schedule_event'))
        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.msg_in_0, 'msg_out'),
                         (self.ieee802_15_4_access_code_prefixer_0, '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_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0), (self.sdr_sink, 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_tagged_stream_multiply_length_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.es_source_0, 0),
                     (self.blocks_complex_to_float_0, 0))

        if self.sdr_device == "pluto-sdr":
            self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                             (self.msg_out_0, 'msg_in'))
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         (self.blocks_null_sink_0, 0))
            self.connect((self.sdr_source, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))