コード例 #1
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 700e3
        self.fft_bw = fft_bw = 5e3
        self.fc = fc = 1430e6

        ##################################################
        # Blocks
        ##################################################
        self.limesdr_sink_0 = limesdr.sink('', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(fc, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 0)
        self.limesdr_sink_0.set_gain(60, 0)
        self.limesdr_sink_0.set_antenna(255, 0)
        self.limesdr_sink_0.calibrate(5e6, 0)

        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.limesdr_sink_0, 0))
コード例 #2
0
ファイル: radio_if_lms.py プロジェクト: zhufengGNSS/gr-gsm
    def phy_init_sink(self):
        self._phy_sink = limesdr.sink(self.lms_dev_serial,
                                      self.lms_dev_ch_mode, "",
                                      self.lms_len_tag_name)

        self._phy_sink.set_sample_rate(self.sample_rate)
        self._phy_sink.set_gain(self.tx_gain, 0)
コード例 #3
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

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

        ##################################################
        # Blocks
        ##################################################
        self.limesdr_sink_0 = limesdr.sink('', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_oversampling(16)
        self.limesdr_sink_0.set_center_freq(557142857, 0)
        self.limesdr_sink_0.set_gain(40, 0)
        self.limesdr_sink_0.set_antenna(255, 0)
        self.limesdr_sink_0.calibrate(samp_rate, 0)

        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            'C:\\Users\\user\\Documents\\GNU Radio\\gr_isdbt_rf_capture\\capture.dat',
            True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.limesdr_sink_0, 0))
コード例 #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

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

        self.variable_cc_encoder_def_0 = variable_cc_encoder_def_0 = map(
            (lambda a: fec.cc_encoder_make(4096, 7, 2, ([79, 109]), 0, fec.
                                           CC_STREAMING, False)), range(0, 1))

        self.variable_cc_decoder_def_0 = variable_cc_decoder_def_0 = map(
            (lambda a: fec.cc_decoder.make(4096, 7, 2, ([79, 109]), 0, -1, fec.
                                           CC_STREAMING, False)), range(0, 1))
        self.samp_rate = samp_rate = 50000
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

        ##################################################
        # Blocks
        ##################################################
        self.limesdr_sink_0 = limesdr.sink('1D4984C0B2BBE9', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(1.43e9, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 0)
        self.limesdr_sink_0.set_digital_filter(samp_rate, 0)
        self.limesdr_sink_0.set_gain(60, 0)
        self.limesdr_sink_0.set_antenna(255, 0)

        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, 32000,
                                                 True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/pi/Desktop/Despar/Shade/spon.jpg',
            False)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=4,
                bits_per_symbol=1,
                preamble='',
                access_code=code1,
                pad_for_usrp=False,
            ),
            payload_length=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.limesdr_sink_0, 0))
コード例 #5
0
    def __init__(self):
        gr.top_block.__init__(self, "Antenna Sweep module")

        ##################################################
        # Variables
        ##################################################
        self.trans_width = trans_width = 500e3
        self.samp_rate = samp_rate = 32e6
        self.sweep_tone = sweep_tone = 0
        self.step_size = step_size = samp_rate / 2 - trans_width
        self.input_scale = input_scale = 1e-5
        self.gain_tx = gain_tx = int(10)
        self.gain_rx = gain_rx = int(10)
        self.freq = freq = 50e6

        ##################################################
        # Blocks
        ##################################################
        self.zmq_tx_pub = zeromq.pub_sink(gr.sizeof_gr_complex, 1,
                                          'tcp://127.0.0.1:5000', 100, True,
                                          -1)
        self.zmq_rx_pub = zeromq.pub_sink(gr.sizeof_gr_complex, 1,
                                          'tcp://127.0.0.1:5001', 100, True,
                                          -1)
        self.scale_tx = blocks.multiply_vcc(1)
        self.lo_input = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE,
                                            freq + sweep_tone, 1, 0)
        self.limesdr_tx = limesdr.sink('', 0, '', '')
        self.limesdr_tx.set_sample_rate(samp_rate)
        self.limesdr_tx.set_center_freq(freq, 0)
        self.limesdr_tx.set_bandwidth(step_size, 0)
        self.limesdr_tx.set_digital_filter(step_size, 0)
        self.limesdr_tx.set_gain(gain_rx, 0)
        self.limesdr_tx.set_antenna(255, 0)
        self.limesdr_tx.calibrate(step_size, 0)

        self.limesdr_rx = limesdr.source('', 0, '')
        self.limesdr_rx.set_sample_rate(samp_rate)
        self.limesdr_rx.set_center_freq(freq, 0)
        self.limesdr_rx.set_bandwidth(step_size, 0)
        self.limesdr_rx.set_digital_filter(step_size, 0)
        self.limesdr_rx.set_gain(30, 0)
        self.limesdr_rx.set_antenna(255, 0)
        self.limesdr_rx.calibrate(step_size, 0)

        self.input_scale_source = analog.sig_source_c(0, analog.GR_CONST_WAVE,
                                                      0, 0, input_scale)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.input_scale_source, 0), (self.scale_tx, 0))
        self.connect((self.limesdr_rx, 0), (self.zmq_rx_pub, 0))
        self.connect((self.lo_input, 0), (self.limesdr_tx, 0))
        self.connect((self.lo_input, 0), (self.scale_tx, 1))
        self.connect((self.scale_tx, 0), (self.zmq_tx_pub, 0))
コード例 #6
0
    def __init__(self,
                 zmq_address_iq_in='tcp://127.0.0.1:5052',
                 zmq_address_iq_out='tcp://*:5051'):
        gr.top_block.__init__(self, "Zero Mq Split A")

        ##################################################
        # Parameters
        ##################################################
        self.zmq_address_iq_in = zmq_address_iq_in
        self.zmq_address_iq_out = zmq_address_iq_out

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.offset = offset = 0
        self.capture_freq = capture_freq = 868.5e6

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     zmq_address_iq_in, -1,
                                                     False, -1)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_gr_complex, 1,
                                                 zmq_address_iq_out, -1, False,
                                                 -1)
        self.limesdr_source_0 = limesdr.source('0009072C0287211A', 0, '')
        self.limesdr_source_0.set_sample_rate(samp_rate)
        self.limesdr_source_0.set_center_freq(capture_freq, 0)
        self.limesdr_source_0.set_bandwidth(5e6, 0)
        self.limesdr_source_0.set_gain(30, 0)
        self.limesdr_source_0.set_antenna(2, 0)
        self.limesdr_source_0.calibrate(5e6, 0)

        self.limesdr_sink_0 = limesdr.sink('', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(capture_freq, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 0)
        self.limesdr_sink_0.set_gain(50, 0)
        self.limesdr_sink_0.set_antenna(255, 0)
        self.limesdr_sink_0.calibrate(5e6, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.limesdr_source_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.limesdr_sink_0, 0))
コード例 #7
0
ファイル: gnuRadioDriver.py プロジェクト: mfkiwl/ScratchRadio
 def __init__(self, deviceSerialNumber):
   FlowGraphBlock.__init__(self)
   if (RadioSinkBlock.sdrSink == None):
     sdrSnk = limesdr.sink(
       deviceSerialNumber, # device_number
       1,                  # device_type = LimeSDR-Mini
       1,                  # chip_mode = SISO
       0,                  # channel = A (in SISO mode)
       0,                  # file_switch = NO (don't load parameters from file)
       "",                 # filename = unused for no parameter file
       SDR_DEFAULT_FREQ,   # rf_freq (default to 433MHz ISM band)
       SDR_SAMPLE_RATE,    # samp_rate (default set to nominal 400 kHz)
       16,                 # oversample (interpolate by x16)
       0,                  # calibration_ch0 disabled - TODO: get this working
       5e6,                # calibr_bandw_ch0 (default set to minimum 5 MHz)
       0,                  # calibration_ch1 disabled
       0,                  # calibr_bandw_ch1 unused
       2,                  # pa_path_mini = BAND2
       0,                  # pa_path_ch0 unused for LimeSDR-Mini
       0,                  # pa_path_ch1 unused for LimeSDR-Mini
       1,                  # analog_filter_ch0 enabled
       5e6,                # analog_bandw_ch0 (default set to minimum 5 MHz)
       0,                  # analog_filter_ch1 disabled
       1.5e6,              # analog_bandw_ch1 unused
       1,                  # digital_filter_ch0 enabled
       SDR_BANDWIDTH,      # digital_bandw_ch0 (default to nominal 200 kHz)
       0,                  # digital_filter_ch1 disabled
       SDR_BANDWIDTH,      # digital_bandw_ch1 unused
       40,                 # gain_dB_ch0 (default set to nominal 40dB)
       0,                  # gain_dB_ch1 unused
       0,                  # nco_freq_ch0 is unused
       0,                  # nco_freq_ch1 is unused
       0,                  # cmix_mode_ch0 is unused
       0                   # cmix_mode_ch1 is unused
     )
     RadioSinkBlock.sdrSink = sdrSnk
コード例 #8
0
ファイル: sin_TX.py プロジェクト: varvarip/SHADE-TX-System
    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.samp_rate = samp_rate = 700e3
        self.fft_bw = fft_bw = 5e3
        self.fc = fc = 1430e6

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "B/Band Wave at Tx",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        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(True)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        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_freq_sink_x_0_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            fft_bw,  #bw
            "PSD aat Tx",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_1.enable_grid(True)
        self.qtgui_freq_sink_x_0_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_1.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_1_win)
        self.limesdr_sink_0 = limesdr.sink('', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(fc, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 0)
        self.limesdr_sink_0.set_gain(60, 0)
        self.limesdr_sink_0.set_antenna(255, 0)
        self.limesdr_sink_0.calibrate(5e6, 0)

        self.analog_const_source_x_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.limesdr_sink_0, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.qtgui_freq_sink_x_0_1, 0))
        self.connect((self.analog_const_source_x_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
コード例 #9
0
ファイル: img_TX.py プロジェクト: varvarip/SHADE-TX-System
    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_cc_encoder_def_0 = variable_cc_encoder_def_0 = map(
            (lambda a: fec.cc_encoder_make(4096, 7, 2, ([79, 109]), 0, fec.
                                           CC_STREAMING, False)), range(0, 1))

        self.variable_cc_decoder_def_0 = variable_cc_decoder_def_0 = map(
            (lambda a: fec.cc_decoder.make(4096, 7, 2, ([79, 109]), 0, -1, fec.
                                           CC_STREAMING, False)), range(0, 1))
        self.samp_rate = samp_rate = 50000
        self.code1 = code1 = '010110011011101100010101011111101001001110001011010001101010001'

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Transmission",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        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(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 = ['', '', '', '', '', '', '', '', '', '']
        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.limesdr_sink_0 = limesdr.sink('1D4984C0B2BBE9', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(1.43e9, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 0)
        self.limesdr_sink_0.set_digital_filter(samp_rate, 0)
        self.limesdr_sink_0.set_gain(60, 0)
        self.limesdr_sink_0.set_antenna(255, 0)

        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, 32000,
                                                 True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, 'home/pi/Desktop/Despar/Shade/spon.jgp', False)
        self.blks2_packet_encoder_0_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=4,
                bits_per_symbol=1,
                preamble='',
                access_code=code1,
                pad_for_usrp=False,
            ),
            payload_length=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_encoder_0_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.limesdr_sink_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
コード例 #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")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 400000

        ##################################################
        # Blocks
        ##################################################
        self.limesdr_sink_0 = limesdr.sink('0009070602433917', 2, 1, 0, 0, '',
                                           860e6, samp_rate, 0, 0, 10e6, 0,
                                           10e6, 1, 1, 1, 1, 6e6, 1, 5e6, 0, 0,
                                           0, 0, 30, 30, 0, 0, 0, 0)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_float * 1, '/home/doctor/harro.txt', True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f(
            grc_blks2.packet_encoder(
                samples_per_symbol=1,
                bits_per_symbol=1,
                preamble='',
                access_code='1100110011',
                pad_for_usrp=True,
            ),
            payload_length=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.limesdr_sink_0, 0))
コード例 #11
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", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.phase = phase = 1
        self.RF_Freq = RF_Freq = 20e6

        ##################################################
        # Look-up Tables for Phase Shift
        ##################################################
        phi = numpy.arange(0, 361, 1)
        pi = math.pi
        cos_lut = []
        sin_lut = []
        cos_lut = numpy.cos(pi * phi / 180)
        sin_lut = numpy.sin(pi * phi / 180)

        ##################################################
        # Blocks
        ##################################################
        self._phase_range = Range(0, 361, 1, 1, 200)
        self._phase_win = RangeWidget(self._phase_range, self.set_phase,
                                      "phase", "counter_slider", int)
        self.top_grid_layout.addWidget(self._phase_win)
        self.limesdr_source_0 = limesdr.source('0009070602470A0E', 0, '')
        self.limesdr_source_0.set_sample_rate(samp_rate)
        self.limesdr_source_0.set_center_freq(RF_Freq, 0)
        self.limesdr_source_0.set_bandwidth(21e6, 0)
        self.limesdr_source_0.set_digital_filter(5e3, 0)
        self.limesdr_source_0.set_gain(0, 0)
        self.limesdr_source_0.set_antenna(2, 0)
        self.limesdr_source_0.calibrate(5e6, 0)

        (self.limesdr_source_0).set_min_output_buffer(4096)
        (self.limesdr_source_0).set_max_output_buffer(4096)
        self.limesdr_sink_0 = limesdr.sink('0009070602470A0E', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(30e6, 0)
        self.limesdr_sink_0.set_bandwidth(31e6, 0)
        self.limesdr_sink_0.set_digital_filter(5e3, 0)
        self.limesdr_sink_0.set_gain(60, 0)
        self.limesdr_sink_0.set_antenna(1, 0)
        self.limesdr_sink_0.calibrate(5e6, 0)

        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (sin_lut[phase], ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (-cos_lut[phase], ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.limesdr_sink_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_float_to_complex_0, 1))
        self.connect((self.limesdr_source_0, 0),
                     (self.blocks_complex_to_float_0_0, 0))
コード例 #12
0
    def __init__(self):
        parser = OptionParser()
        parser.add_option("--length",
                          type="int",
                          dest="length",
                          help="MAC payload length(1-112)",
                          default="10")
        parser.add_option("--rate",
                          type="float",
                          dest="rate",
                          help="Tx and Rx sample rate",
                          default=4e6)
        parser.add_option("--period",
                          type="int",
                          dest="period",
                          help="Message Source Period",
                          default=500)
        (options, args) = parser.parse_args()

        gr.top_block.__init__(self,
                              "IEEE 802.15.4 Transceiver using OQPSK PHY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 Transceiver using OQPSK PHY")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        self.freq = freq = 2480000000

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

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.foo_rtt_0, 'out'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.output_chain_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'),
                         (self.foo_rtt_0, 'in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.input_chain_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.connect((self.foo_rtt_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.limesdr_source_0_0, 0), (self.input_chain_0, 0))
        #self.connect((self.limesdr_source_0_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.output_chain_0, 0), (self.limesdr_sink_1, 0))
コード例 #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Limetransmitter")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Limetransmitter")
        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", "limeTransmitter")

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

        ##################################################
        # Blocks
        ##################################################
        self.limesdr_sink_0 = limesdr.sink('1D424BDA12AF19', 1, 1, 0, 0, '',
                                           freq, 2e6, 0, 0, 10e6, 0, 10e6, 1,
                                           1, 1, 1, 5e6, 0, 10e6, 0, 0, 0, 0,
                                           60, 60, 0, 100e6, 0, 0)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=4,
            sensitivity=1,
            bt=0.5,
            verbose=True,
            log=False,
        )
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/thomas/Documents/packet.txt', True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=4,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=16,
        )

        ##################################################
        # 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.limesdr_sink_0, 0))
コード例 #14
0
ファイル: ber_test.py プロジェクト: UBNanosatLab/lfr-firmware
def main():
    ########################################
    #              Configuration           #
    ########################################

    port = '/dev/tty.SLAB_USBtoUART'
    baud = 115200

    freq = 434.000e6
    tune_offset = 250e3
    samp_rate = 2e6
    sym_rate = 10e3
    deviation = 5e3
    lfr_modem_cfg = 7

    usrp = True
    lime = False
    lime_serial = '1D3AC9891D2233'

    num_pkts = 100

    hw_gain = 30
    hw_atten = 60
    usrp_chan_power = -36.6

    gain_offset = usrp_chan_power - hw_atten

    lvls = (numpy.linspace(-110.0, -100.0, 11) - gain_offset).tolist()

    ########################################

    sys.stdout = open('/dev/null', 'w')
    logging.basicConfig(format='%(message)s',
                        stream=sys.stderr,
                        level=logging.DEBUG)

    if usrp:
        sink = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        sink.set_samp_rate(samp_rate)
        sink.set_center_freq(freq + tune_offset, 0)
        sink.set_gain(hw_gain, 0)
        sink.set_antenna('TX/RX', 0)
    elif lime:
        sink = limesdr.sink(lime_serial, 1, 1, 0, 0, '', freq + tune_offset,
                            samp_rate, 0, 0, 10e6, 0, 10e6, 1, 1, 1, 1, 5e6, 1,
                            5e6, 0, 0, 0, 0, hw_gain, 30, 0, 0, 0, 0)
    else:
        logging.error("ERROR: Select a radio type!")
        sys.exit(1)

    source = msg_source()

    tb = auto_ber_test(samp_rate,
                       tune_offset,
                       source,
                       sink,
                       0,
                       sym_rate=sym_rate,
                       deviation=deviation)
    tb.start()

    pkt_data = numpy.random.bytes(255)

    lfr = Radio(port, baud)

    cfg = lfr.get_cfg()
    cfg['flags'] &= ~(1)  # CRC_ENABLE
    cfg['modem_config'] = (cfg['modem_config'] & 0xF0) | lfr_modem_cfg
    lfr.set_cfg(cfg)

    # Grr... Python scoping...
    global timer
    timer = None

    global num_bits
    global num_errs
    num_bits = 0
    num_errs = 0

    pkt_delay = 2500 / sym_rate

    def step_pwr_lvl():
        global num_bits
        global num_errs
        logging.info('')
        logging.info('Power: {: >3.1f} dBm  Bits received: {: >8}  Bits Errors: {: >5}  log10(BER)= {:.02f}'\
        .format(lvls[0] + gain_offset, num_bits, num_errs, math.log10(num_errs + 0.001) - math.log10(num_bits + 0.001)))

        lvls[:] = lvls[1:]
        if not lvls:
            tb.stop()
            thread.interrupt_main()
            # Ugly, skips any finally block
            # Essentially crashes
            os._exit(0)

        logging.info('Stepping to power level: {} dBm'.format(lvls[0] +
                                                              gain_offset))
        tb.set_sw_gain(lvls[0])

        num_bits = 0
        num_errs = 0

        for _ in range(num_pkts):
            source.transmit(pkt_data)

        global timer
        timer = Timer(num_pkts * pkt_delay, step_pwr_lvl)
        timer.start()

    timer = Timer(num_pkts * pkt_delay, step_pwr_lvl)

    logging.info('LFR BER Test')
    logging.info(
        'Sym Rate: {:.03f} kbit/s    Deviation: {:.03f} kHz    LFR Modem Config: 0x{:02X}'
        .format(sym_rate / 1000.0, deviation / 1000.0, lfr_modem_cfg))
    logging.info('-' * 80)

    logging.info('Starting at power level: {} dBm'.format(lvls[0] +
                                                          gain_offset))
    tb.set_sw_gain(lvls[0])

    for _ in range(num_pkts):
        source.transmit(pkt_data)

    timer.start()

    while True:
        data = [ord(x) for x in lfr.rx()]

        for x, y in zip(data, pkt_data):
            xor = x ^ ord(y)
            for _ in range(8):
                num_bits += 1
                if (xor & 1):
                    num_errs += 1
                xor >>= 1
コード例 #15
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Tx")
        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", "wifi_tx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 1
        self.samp_rate = samp_rate = 10e6
        self.pdu_length = pdu_length = 50
        self.out_buf_size = out_buf_size = 96000
        self.lo_offset = lo_offset = 0
        self.interval = interval = 100
        self.freq = freq = 2472000000
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._pdu_length_range = Range(0, 1500, 1, 50, 200)
        self._pdu_length_win = RangeWidget(self._pdu_length_range,
                                           self.set_pdu_length, "pdu_length",
                                           "counter_slider", int)
        self.top_layout.addWidget(self._pdu_length_win)
        self._interval_range = Range(10, 1000, 1, 100, 200)
        self._interval_win = RangeWidget(self._interval_range,
                                         self.set_interval, "interval",
                                         "counter_slider", int)
        self.top_layout.addWidget(self._interval_win)
        self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7]
        self._encoding_labels = [
            "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
            "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        ]
        self._encoding_group_box = Qt.QGroupBox("encoding")
        self._encoding_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._encoding_button_group = variable_chooser_button_group()
        self._encoding_group_box.setLayout(self._encoding_box)
        for i, label in enumerate(self._encoding_labels):
            radio_button = Qt.QRadioButton(label)
            self._encoding_box.addWidget(radio_button)
            self._encoding_button_group.addButton(radio_button, i)
        self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._encoding_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._encoding_options.index(i)))
        self._encoding_callback(self.encoding)
        self._encoding_button_group.buttonClicked[int].connect(
            lambda i: self.set_encoding(self._encoding_options[i]))
        self.top_layout.addWidget(self._encoding_group_box)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=20e6,
            chan_est=0,
            encoding=encoding,
            frequency=2.472e9,
            sensitivity=0.56,
        )
        self._tx_gain_range = Range(0, 1, 0.01, 1, 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._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self.limesdr_sink_0 = limesdr.sink("", 1, "", "")
        self.limesdr_sink_0.set_sample_rate(10e6)
        self.limesdr_sink_0.set_center_freq(2.472e9, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 1)
        self.limesdr_sink_0.set_gain(55, 1)
        self.limesdr_sink_0.set_antenna(2, 1)
        self.limesdr_sink_0.calibrate(5e6, 1)

        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]),
            ([0xff, 0xff, 0xff, 0xff, 0xff, 255]))
        self._freq_options = [
            2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0,
            2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0,
            2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0,
            2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0,
            5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0,
            5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0,
            5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0,
            5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0,
            5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0,
            5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0,
            5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0,
            5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0,
            5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0,
            5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0,
            5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0,
            5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0,
            5900000000.0, 5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g',
            '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g',
            '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g',
            ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g',
            ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a',
            ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a',
            ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a',
            ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a',
            ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a',
            ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a',
            '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a',
            '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a',
            '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a',
            '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a',
            '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a',
            '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a',
            '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a',
            '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)',
            '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)',
            '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)',
            '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)',
            '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p',
            '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p',
            '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": "))
        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.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", "52001",
                                                     10000, False)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern("".join("x" for i in range(pdu_length))), interval)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.limesdr_sink_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
コード例 #16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
            self.GetWin(),
            title='Constellation Plot',
            sample_rate=samp_rate,
            frame_rate=5,
            const_size=2048,
            M=4,
            theta=0,
            loop_bw=6.28 / 100.0,
            fmax=0.06,
            mu=0.5,
            gain_mu=0.005,
            symbol_rate=samp_rate / 4.,
            omega_limit=0.005,
        )
        self.Add(self.wxgui_constellationsink2_0.win)
        self.limesdr_source_0 = limesdr.source('0009081C05C10C24', 0, '')
        self.limesdr_source_0.set_sample_rate(samp_rate)
        self.limesdr_source_0.set_center_freq(500e6, 0)
        self.limesdr_source_0.set_bandwidth(5e6, 0)
        self.limesdr_source_0.set_gain(30, 0)
        self.limesdr_source_0.set_antenna(2, 0)
        self.limesdr_source_0.calibrate(5e6, 0)

        self.limesdr_sink_0 = limesdr.sink('0009081C05C10C24', 0, '', '')
        self.limesdr_sink_0.set_sample_rate(samp_rate)
        self.limesdr_sink_0.set_center_freq(520e6, 0)
        self.limesdr_sink_0.set_bandwidth(5e6, 0)
        self.limesdr_sink_0.set_gain(30, 0)
        self.limesdr_sink_0.set_antenna(1, 0)
        self.limesdr_sink_0.calibrate(5e6, 0)

        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        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_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     '192.168.8.100', 10000,
                                                     1472, True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 '192.168.8.100', 10000, 1472,
                                                 True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, ))
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=2,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=30,
        )
        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_udp_sink_1, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.limesdr_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_constellationsink2_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.limesdr_source_0, 0),
                     (self.digital_gmsk_demod_0, 0))
コード例 #17
0
ファイル: qo100.py プロジェクト: df7cb/df7cb-shack
    def __init__(self):
        gr.top_block.__init__(self, "qo100", catch_exceptions=True)
        Qt.QWidget.__init__(self)
        self.setWindowTitle("qo100")
        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", "qo100")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.decim = decim = 11
        self.vfo = vfo = 40e3
        self.tx_vfo = tx_vfo = 40e3
        self.samp_rate = samp_rate = decim * 48e3
        self.rx0_low_cutoff = rx0_low_cutoff = 0
        self.rx0_high_cutoff = rx0_high_cutoff = 3000
        self.mag = mag = 0.9

        self.af_gain = af_gain = 20

        ##################################################
        # Blocks
        ##################################################
        self._vfo_msgdigctl_win = qtgui.MsgDigitalNumberControl(
            lbl='RX',
            min_freq_hz=-10e3,
            max_freq_hz=510e3,
            parent=self,
            thousands_separator=".",
            background_color="black",
            fontColor="white",
            var_callback=self.set_vfo,
            outputmsgname="'freq'".replace("'", ""))
        self._vfo_msgdigctl_win.setValue(40e3)
        self._vfo_msgdigctl_win.setReadOnly(False)
        self.vfo = self._vfo_msgdigctl_win

        self.top_layout.addWidget(self._vfo_msgdigctl_win)
        self._tx_vfo_msgdigctl_win = qtgui.MsgDigitalNumberControl(
            lbl='TX',
            min_freq_hz=-10e3,
            max_freq_hz=510e3,
            parent=self,
            thousands_separator=".",
            background_color="black",
            fontColor="white",
            var_callback=self.set_tx_vfo,
            outputmsgname="'freq'".replace("'", ""))
        self._tx_vfo_msgdigctl_win.setValue(40e3)
        self._tx_vfo_msgdigctl_win.setReadOnly(False)
        self.tx_vfo = self._tx_vfo_msgdigctl_win

        self.top_layout.addWidget(self._tx_vfo_msgdigctl_win)
        self._af_gain_range = Range(0, 200, 5, 20, 200)
        self._af_gain_win = RangeWidget(self._af_gain_range, self.set_af_gain,
                                        "af_gain", "counter_slider", float,
                                        QtCore.Qt.Horizontal)
        self.top_grid_layout.addWidget(self._af_gain_win, 29, 0, 1, 1)
        for r in range(29, 30):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.vfo2_to_float = blocks.complex_to_float(1)
        self.vfo2_signal_source = analog.sig_source_c(samp_rate,
                                                      analog.GR_COS_WAVE,
                                                      250e3 - 40e3, mag, 0, 0)
        self.vfo2_mixer = blocks.multiply_vcc(1)
        self.vfo2_bandpass = filter.fir_filter_ccc(
            decim,
            firdes.complex_band_pass(10, samp_rate, 0, 5000, 1000,
                                     window.WIN_HAMMING, 6.76))
        self.vfo2_audio_sink = audio.sink(48000, 'pulse:rx2', False)
        self.vfo0_waterfall_atten = blocks.multiply_const_cc(0.01)
        self.vfo0_waterfall_add = blocks.add_vcc(1)
        self.vfo0_to_float = blocks.complex_to_float(1)
        self.vfo0_signal_source = analog.sig_source_c(samp_rate,
                                                      analog.GR_COS_WAVE,
                                                      250e3 - vfo, mag, 0, 0)
        self.vfo0_scope_bandpass = filter.fir_filter_ccc(
            2 * decim,
            firdes.complex_band_pass(1, samp_rate, -12e3, 12e3, 1000,
                                     window.WIN_HAMMING, 6.76))
        self.vfo0_scope = qtgui.freq_sink_c(
            1024,  #size
            window.WIN_HAMMING,  #wintype
            0,  #fc
            24e3,  #bw
            '',  #name
            1,
            None  # parent
        )
        self.vfo0_scope.set_update_time(0.01)
        self.vfo0_scope.set_y_axis(-86, -40)
        self.vfo0_scope.set_y_label('Relative Gain', 'dB')
        self.vfo0_scope.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.vfo0_scope.enable_autoscale(False)
        self.vfo0_scope.enable_grid(True)
        self.vfo0_scope.set_fft_average(0.2)
        self.vfo0_scope.enable_axis_labels(True)
        self.vfo0_scope.enable_control_panel(True)
        self.vfo0_scope.set_fft_window_normalized(True)

        self.vfo0_scope.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", "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 range(1):
            if len(labels[i]) == 0:
                self.vfo0_scope.set_line_label(i, "Data {0}".format(i))
            else:
                self.vfo0_scope.set_line_label(i, labels[i])
            self.vfo0_scope.set_line_width(i, widths[i])
            self.vfo0_scope.set_line_color(i, colors[i])
            self.vfo0_scope.set_line_alpha(i, alphas[i])

        self._vfo0_scope_win = sip.wrapinstance(self.vfo0_scope.qwidget(),
                                                Qt.QWidget)
        self.top_grid_layout.addWidget(self._vfo0_scope_win, 15, 0, 14, 1)
        for r in range(15, 29):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.vfo0_mixer = blocks.multiply_vcc(1)
        self.vfo0_bandpass = filter.fir_filter_ccc(
            decim,
            firdes.complex_band_pass(af_gain, samp_rate, rx0_low_cutoff,
                                     rx0_high_cutoff, 1000, window.WIN_HAMMING,
                                     6.76))
        self.vfo0_audio_sink = audio.sink(48000, 'pulse', False)
        self.tx_vfo_signal_source = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, tx_vfo - 250e3, mag, 0, 0)
        self.tx_to_complex = blocks.float_to_complex(1)
        self.tx_mixer = blocks.multiply_vcc(1)
        self.tx_bandpass = filter.interp_fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, 48e3, 0, 3000, 1000,
                                     window.WIN_HAMMING, 6.76))
        self.tx_audio_source = audio.source(48000, 'pulse:tx0.monitor', False)
        self.rx_resampler = filter.rational_resampler_ccc(interpolation=decim,
                                                          decimation=1,
                                                          taps=[],
                                                          fractional_bw=0)
        self.rx0_low_cutoff_setter = blocks.msg_pair_to_var(
            self.set_rx0_low_cutoff)
        self.rx0_high_cutoff_setter = blocks.msg_pair_to_var(
            self.set_rx0_high_cutoff)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            2048,  #size
            window.WIN_BLACKMAN_hARRIS,  #wintype
            250e3,  #fc
            samp_rate,  #bw
            "",  #name
            1,  #number of inputs
            None  # parent
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.05)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(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 range(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(-75, -45)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.qwidget(), Qt.QWidget)

        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,
                                       0, 14, 1)
        for r in range(0, 14):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.midi_block = midi_block.blk(
            midi_port='DJControl Compact:DJControl Compact DJControl Com')
        if "int" == "int":
            isFloat = False
            scaleFactor = 1
        else:
            isFloat = True
            scaleFactor = 1

        _low_cutoff_gauge_lg_win = qtgui.GrLevelGauge('', "default", "default",
                                                      "default", 0, 3000, 100,
                                                      False, 1, isFloat,
                                                      scaleFactor, True, self)
        _low_cutoff_gauge_lg_win.setValue(0)
        self.low_cutoff_gauge = _low_cutoff_gauge_lg_win

        self.top_layout.addWidget(_low_cutoff_gauge_lg_win)
        self.limesdr_source = limesdr.source('', 0, '')
        self.limesdr_source.set_sample_rate(samp_rate)
        self.limesdr_source.set_center_freq(739.75e6, 0)
        self.limesdr_source.set_bandwidth(1.5e6, 0)
        self.limesdr_source.set_gain(30, 0)
        self.limesdr_source.set_antenna(2, 0)
        self.limesdr_source.calibrate(5e6, 0)
        self.limesdr_sink = limesdr.sink('', 0, '', '')
        self.limesdr_sink.set_sample_rate(samp_rate)
        self.limesdr_sink.set_center_freq(2400.250e6, 0)
        self.limesdr_sink.set_bandwidth(5e6, 0)
        self.limesdr_sink.set_gain(73, 0)
        self.limesdr_sink.set_antenna(2, 0)
        self.limesdr_sink.calibrate(2.5e6, 0)
        if "int" == "int":
            isFloat = False
            scaleFactor = 1
        else:
            isFloat = True
            scaleFactor = 1

        _high_cutoff_gauge_lg_win = qtgui.GrLevelGauge('', "default",
                                                       "default", "default", 0,
                                                       3000, 100, False, 1,
                                                       isFloat, scaleFactor,
                                                       True, self)
        _high_cutoff_gauge_lg_win.setValue(3000)
        self.high_cutoff_gauge = _high_cutoff_gauge_lg_win

        self.top_layout.addWidget(_high_cutoff_gauge_lg_win)
        self.control = control.blk()
        self.blocks_swapiq_0 = blocks.swap_iq(1, gr.sizeof_gr_complex)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.control, 'rx0_high_cutoff'),
                         (self.high_cutoff_gauge, 'value'))
        self.msg_connect((self.control, 'rx0_low_cutoff'),
                         (self.low_cutoff_gauge, 'value'))
        self.msg_connect((self.control, 'midi_out'),
                         (self.midi_block, 'midi_in'))
        self.msg_connect((self.control, 'rx0_high_cutoff'),
                         (self.rx0_high_cutoff_setter, 'inpair'))
        self.msg_connect((self.control, 'rx0_low_cutoff'),
                         (self.rx0_low_cutoff_setter, 'inpair'))
        self.msg_connect((self.control, 'tx_freq_out'),
                         (self.tx_vfo, 'valuein'))
        self.msg_connect((self.control, 'rx_freq_out'), (self.vfo, 'valuein'))
        self.msg_connect((self.midi_block, 'midi_out'),
                         (self.control, 'midi_in'))
        self.msg_connect((self.tx_vfo, 'valueout'),
                         (self.control, 'tx_freq_in'))
        self.msg_connect((self.vfo, 'valueout'), (self.control, 'rx_freq_in'))
        self.connect((self.blocks_swapiq_0, 0), (self.vfo0_waterfall_atten, 0))
        self.connect((self.limesdr_source, 0), (self.vfo0_mixer, 0))
        self.connect((self.limesdr_source, 0), (self.vfo0_waterfall_add, 0))
        self.connect((self.limesdr_source, 0), (self.vfo2_mixer, 0))
        self.connect((self.rx_resampler, 0), (self.tx_mixer, 0))
        self.connect((self.tx_audio_source, 0), (self.tx_to_complex, 0))
        self.connect((self.tx_bandpass, 0), (self.rx_resampler, 0))
        self.connect((self.tx_mixer, 0), (self.limesdr_sink, 0))
        self.connect((self.tx_to_complex, 0), (self.tx_bandpass, 0))
        self.connect((self.tx_vfo_signal_source, 0), (self.tx_mixer, 1))
        self.connect((self.vfo0_bandpass, 0), (self.vfo0_to_float, 0))
        self.connect((self.vfo0_mixer, 0), (self.vfo0_bandpass, 0))
        self.connect((self.vfo0_mixer, 0), (self.vfo0_scope_bandpass, 0))
        self.connect((self.vfo0_scope_bandpass, 0), (self.vfo0_scope, 0))
        self.connect((self.vfo0_signal_source, 0), (self.blocks_swapiq_0, 0))
        self.connect((self.vfo0_signal_source, 0), (self.vfo0_mixer, 1))
        self.connect((self.vfo0_to_float, 0), (self.vfo0_audio_sink, 0))
        self.connect((self.vfo0_waterfall_add, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.vfo0_waterfall_atten, 0),
                     (self.vfo0_waterfall_add, 1))
        self.connect((self.vfo2_bandpass, 0), (self.vfo2_to_float, 0))
        self.connect((self.vfo2_mixer, 0), (self.vfo2_bandpass, 0))
        self.connect((self.vfo2_signal_source, 0), (self.vfo2_mixer, 1))
        self.connect((self.vfo2_to_float, 0), (self.vfo2_audio_sink, 0))