Example #1
0
    def __init__(self, rx_callback, options):

	gr.hier_block2.__init__(self, "receive_path",
				gr.io_signature(1, 1, gr.sizeof_gr_complex),
				gr.io_signature(0, 0, 0))


        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose     = options.verbose
        self._log         = options.log
        self._rx_callback = rx_callback      # this callback is fired when there's a packet available
        
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, False)

        # receiver
        self.ofdm_rx = digital.ofdm_demod(options,
                                          callback=self._rx_callback)

        # Carrier Sensing Blocks
        alpha = 0.001
        thresh = 30   # in dB, will have to adjust
        self.probe = analog.probe_avg_mag_sqrd_c(thresh,alpha)

        self.connect(self, self.dc_blocker_xx_0)
        self.connect(self.dc_blocker_xx_0, self.ofdm_rx)
        self.connect(self.ofdm_rx, self.probe)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()
Example #2
0
    def __init__(self, options):
        '''
        See below for what options should hold
        '''

	gr.hier_block2.__init__(self, "transmit_path",
				gr.io_signature(0, 0, 0),
				gr.io_signature(1, 1, gr.sizeof_gr_complex))

        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose      = options.verbose      # turn verbose mode on/off
        self._tx_amplitude = options.tx_amplitude # digital amp sent to radio
        
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, False)

        self.ofdm_tx = digital.ofdm_mod(options,
                                        msgq_limit=10,
                                        pad_for_usrp=False)

        self.amp = blocks.multiply_const_cc(1)
        self.set_tx_amplitude(self._tx_amplitude)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()

        # Create and setup transmit path flow graph
        self.connect(self.ofdm_tx, self.amp, self)
Example #3
0
    def __init__(self, FFT_size, SDR_BW):
        gr.top_block.__init__(self, "Spectrum")

        ##################################################
        # Variables
        ##################################################
        self.tuning = tuning = 0
        self.samp_rate = samp_rate = 200e6
        self.integration_time = integration_time = 100
        self.data_address = data_address = "tcp://127.0.0.1:5555"
        self.SDR_BW = SDR_BW
        self.FFT_size = FFT_size  #take the FFT_size from the input

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex,
                                                   FFT_size, data_address, 100,
                                                   False, -1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec("B:0", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(tuning, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.fft_vxx_0 = fft.fft_vcc(FFT_size, True,
                                     (window.blackmanharris(FFT_size)), True,
                                     1)
        self.dc_blocker_xx_0 = gr_filter.dc_blocker_cc(32, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, FFT_size)
        #self.blocks_integrate_xx_0 = blocks.integrate_cc(1, FFT_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        #self.connect((self.uhd_usrp_source_0,0),(self.blocks_stream_to_vector_0,0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.zeromq_push_sink_0, 0))
Example #4
0
    def __init__(self,
                 rate,
                 threshold,
                 queue,
                 use_pmf=False,
                 use_dcblock=False):
        gr.hier_block2.__init__(self, "modes_rx_path",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0, 0, 0))

        self._rate = int(rate)
        self._threshold = threshold
        self._queue = queue
        self._spc = int(rate / 2e6)

        # Convert incoming I/Q baseband to amplitude
        self._demod = blocks.complex_to_mag_squared()
        if use_dcblock:
            self._dcblock = filter.dc_blocker_cc(100 * self._spc, False)
            self.connect(self, self._dcblock, self._demod)
        else:
            self.connect(self, self._demod)
            self._dcblock = None

        self._bb = self._demod
        # Pulse matched filter for 0.5us pulses
        if use_pmf:
            self._pmf = blocks.moving_average_ff(self._spc, 1.0 /
                                                 self._spc)  #, self._rate)
            self.connect(self._demod, self._pmf)
            self._bb = self._pmf

        # Establish baseline amplitude (noise, interference)
        self._avg = blocks.moving_average_ff(
            48 * self._spc,
            1.0 / (48 * self._spc))  #, self._rate) # 3 preambles

        # Synchronize to Mode-S preamble
        self._sync = air_modes.preamble(self._rate, self._threshold)

        # Slice Mode-S bits and send to message queue
        self._slicer = air_modes.slicer(self._queue)

        # Wire up the flowgraph
        self.connect(self._bb, (self._sync, 0))
        self.connect(self._bb, self._avg, (self._sync, 1))
        self.connect(self._sync, self._slicer)
    def test_002(self):
        ''' Test impulse response - short form, cc '''
        src_data = [1,] + 100*[0,]
        expected_result = ((-0.029296875+0j), (-0.0302734375+0j),
                           (0.96875+0j), (-0.0302734375+0j),
                           (-0.029296875+0j))

        src = blocks.vector_source_c(src_data)
        op = filter.dc_blocker_cc(32, False)
        dst = blocks.vector_sink_c()

        self.tb.connect (src, op, dst)
        self.tb.run()

        # only test samples around D-1
        result_data = dst.data()[29:34]
        self.assertComplexTuplesAlmostEqual (expected_result, result_data)
    def test_001(self):
        ''' Test impulse response - long form, cc '''
        src_data = [1,] + 100*[0,]
        expected_result = ((-0.02072429656982422+0j), (-0.02081298828125+0j),
                           (0.979156494140625+0j), (-0.02081298828125+0j),
                           (-0.02072429656982422+0j))

        src = blocks.vector_source_c(src_data)
        op = filter.dc_blocker_cc(32, True)
        dst = blocks.vector_sink_c()

        self.tb.connect (src, op, dst)
        self.tb.run()

        # only test samples around 2D-2
        result_data = dst.data()[60:65]
        self.assertComplexTuplesAlmostEqual (expected_result, result_data)
Example #7
0
    def __init__(self, rate, threshold, queue, use_pmf=False, use_dcblock=False):
        gr.hier_block2.__init__(self, "modes_rx_path",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(0,0,0))

        self._rate = int(rate)
        self._threshold = threshold
        self._queue = queue
        self._spc = int(rate/2e6)

        # Convert incoming I/Q baseband to amplitude
        self._demod = blocks.complex_to_mag_squared()
        if use_dcblock:
            self._dcblock = filter.dc_blocker_cc(100*self._spc,False)
            self.connect(self, self._dcblock, self._demod)
        else:
            self.connect(self, self._demod)
            self._dcblock = None

        self._bb = self._demod
        # Pulse matched filter for 0.5us pulses
        if use_pmf:
            self._pmf = blocks.moving_average_ff(self._spc, 1.0/self._spc)#, self._rate)
            self.connect(self._demod, self._pmf)
            self._bb = self._pmf

        # Establish baseline amplitude (noise, interference)
        self._avg = blocks.moving_average_ff(48*self._spc, 1.0/(48*self._spc))#, self._rate) # 3 preambles

        # Synchronize to Mode-S preamble
        self._sync = air_modes_swig.preamble(self._rate, self._threshold)

        # Slice Mode-S bits and send to message queue
        self._slicer = air_modes_swig.slicer(self._queue)

        # Wire up the flowgraph
        self.connect(self._bb, (self._sync, 0))
        self.connect(self._bb, self._avg, (self._sync, 1))
        self.connect(self._sync, self._slicer)
Example #8
0
    def __init__(self, set_min_freq=False, set_max_freq=False):
        gr.top_block.__init__(self)

        usage = "usage: %prog [options] min_freq max_freq"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-a", "--args", type="string", default="",
                          help="UHD device device address args [default=%default]")
        parser.add_option("", "--spec", type="string", default=None,
	                  help="Subdevice of UHD device where appropriate")
        parser.add_option("-A", "--antenna", type="string", default='RX2',
                          help="select Rx Antenna where appropriate")
        parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
                          help="set sample rate [default=%default]")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("", "--tune-delay", type="eng_float",
                          default=0.05, metavar="SECS",#change default from
                          #.25 to .05 -GW
                          help="time to delay (in seconds) after changing frequency [default=%default]")
        parser.add_option("", "--dwell-delay", type="eng_float",
                          default=0.05, metavar="SECS",#changed default from
                          #.25 to .05 - GW
                          help="time to dwell (in seconds) at a given frequency [default=%default]")
        parser.add_option("-b", "--channel-bandwidth", type="eng_float",
                          default=6.25e3, metavar="Hz",
                          help="channel bandwidth of fft bins in Hz [default=%default]")
        parser.add_option("-l", "--lo-offset", type="eng_float",
                          default=0, metavar="Hz",
                          help="lo_offset in Hz [default=%default]")
        parser.add_option("-q", "--squelch-threshold", type="eng_float",
                          default=None, metavar="dB",
                          help="squelch threshold in dB [default=%default]")
        parser.add_option("-F", "--fft-size", type="int", default=None,
                          help="specify number of FFT bins [default=samp_rate/channel_bw]")
        parser.add_option("", "--real-time", action="store_true", default=False,
                          help="Attempt to enable real-time scheduling")
        parser.add_option("-G", "--gps", type='int', dest="gps_flag", default=0,
                          help="toggle gps recording : 1 or 0")
        parser.add_option("-r", "--rawstore", type='int',  dest="raw_store",
                          default=0,
                          help="store raw data from channel FFT bins : 1 or 0")
        parser.add_option("-S", "--spstore", type="int", default='0',
                      help="store signal properties in JSON format: 1 or 0")
        parser.add_option("-T", "--training", type="int", dest= "training_scan",
                          default='0',
                          help="set as training scan for data collection: 1 or 0")

        (options, args) = parser.parse_args()
        
        #modded : set freq  to directly passed frequencies for explicit call of class
        #from channel object. Can still use passed args direct from cmd line.GW
        
        if len(args) == 2:
            self.min_freq = eng_notation.str_to_num(args[0])
            self.max_freq = eng_notation.str_to_num(args[1])
        if len(args) !=2 and (not set_min_freq or not set_max_freq):
            parser.print_help()
            sys.exit(1)
        if set_min_freq and set_max_freq:
            self.min_freq = set_min_freq
            self.max_freq = set_max_freq

        self.channel_bandwidth = options.channel_bandwidth


        if self.min_freq > self.max_freq:
            # swap them
            self.min_freq, self.max_freq = self.max_freq, self.min_freq

        if not options.real_time:
            realtime = False
        else:
            # Attempt to enable realtime scheduling
            r = gr.enable_realtime_scheduling()
            if r == gr.RT_OK:
                realtime = True
            else:
                realtime = False
                print "Note: failed to enable realtime scheduling"

        # build graph
        self.u = uhd.usrp_source(device_addr=options.args,
                                 stream_args=uhd.stream_args('fc32'))

        # Set the subdevice spec
        if(options.spec):
            self.u.set_subdev_spec(options.spec, 0)

        # Set the antenna
        if(options.antenna):
            self.u.set_antenna(options.antenna, 0)

        self.u.set_samp_rate(options.samp_rate)
        self.usrp_rate = usrp_rate = self.u.get_samp_rate()

        self.lo_offset = options.lo_offset

        if options.fft_size is None:
            self.fft_size = int(self.usrp_rate/self.channel_bandwidth)
        else:
            self.fft_size = options.fft_size

        self.squelch_threshold = options.squelch_threshold

        s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
        
        #creating DC blocker block to remove DC component - GW
        dc_blocker = filter.dc_blocker_cc(80, True)
	
        mywindow = filter.window.blackmanharris(self.fft_size)
        ffter = fft.fft_vcc(self.fft_size, True, mywindow, True)
        power = 0
        for tap in mywindow:
            power += tap*tap

        c2mag = blocks.complex_to_mag_squared(self.fft_size)

	# print c2mag

        # FIXME the log10 primitive is dog slow
        #log = blocks.nlog10_ff(10, self.fft_size,
        #                       -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))

        # Set the freq_step to 75% of the actual data throughput.
        # This allows us to discard the bins on both ends of the spectrum.

        self.freq_step = self.nearest_freq((0.75 * self.usrp_rate), self.channel_bandwidth)
        self.min_center_freq = self.min_freq + (self.freq_step/2)
        nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
        self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)

        self.next_freq = self.min_center_freq

        tune_delay  = max(0, int(round(options.tune_delay * usrp_rate / self.fft_size)))  # in fft_frames
        dwell_delay = max(1, int(round(options.dwell_delay * usrp_rate / self.fft_size))) # in fft_frames

        self.msgq = gr.msg_queue(1)
        self._tune_callback = tune(self)        # hang on to this to keep it from being GC'd
        stats = blocks.bin_statistics_f(self.fft_size, self.msgq,
                                        self._tune_callback, tune_delay,
                                        dwell_delay)

        # FIXME leave out the log10 until we speed it up
	#self.connect(self.u, s2v, ffter, c2mag, log, stats)
	self.connect(self.u, dc_blocker, s2v, ffter, c2mag, stats)

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.u.get_gain_range()
            options.gain = float(g.start()+g.stop())/2.0

        self.set_gain(options.gain)
        print "gain =", options.gain
Example #9
0
    def __init__(self, input_filename, _samp_rate, bs_format, output_filename):
        gr.top_block.__init__(self, "Noaa Demodulator")

        ##################################################
        # Variables
        ##################################################
        self.decimation = decimation = 1
        self.samp_rate = samp_rate = _samp_rate / decimation
        self.baud = baud = 8320
        self.sps = sps = samp_rate / (baud * 2.0)
        self.nfilts = nfilts = 72
        self.ebw = ebw = 0.25
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), ebw, 64 * nfilts)
        self.lp_taps = lp_taps = firdes.low_pass_2(nfilts, nfilts, 2 / sps,
                                                   0.05, nfilts)
        self.bp_taps = bp_taps = firdes.band_pass_2(nfilts, nfilts,
                                                    0.1 / float(sps),
                                                    1.2 / float(sps), ebw,
                                                    64 * nfilts)

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decimation,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 11000, 6000, firdes.WIN_BLACKMAN,
                            6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, .068 / 1.5, (lp_taps), nfilts, 0, 10, 2)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            6, 1, .0000005, 2)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_cc(16, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * 24, True)
        self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)

        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            0.068 / 12, 6000 * 2 * 3.14159 / samp_rate,
            -6000 * 2 * 3.14159 / samp_rate)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.5, 1, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/xeratec/Projects/NOAA-DSB/recordings/samples/POES_56k250.raw',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)

        if bs_format == 0:
            self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
            self.blocks_file_sink_3_1 = blocks.file_sink(
                gr.sizeof_float * 1, output_filename, False)
            self.blocks_file_sink_3_1.set_unbuffered(False)
        if bs_format == 1:
            self.blocks_file_sink_0 = blocks.file_sink(
                gr.sizeof_gr_complex * 1, output_filename, False)
            self.blocks_file_sink_0.set_unbuffered(False)

        #################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.dc_blocker_xx_0_0, 0))

        if bs_format == 0:
            self.connect((self.blocks_complex_to_imag_0, 0),
                         (self.blocks_file_sink_3_1, 0))
            self.connect((self.digital_cma_equalizer_cc_0, 0),
                         (self.blocks_complex_to_imag_0, 0))
        if bs_format == 1:
            self.connect((self.digital_cma_equalizer_cc_0, 0),
                         (self.blocks_file_sink_0, 0))

        self.connect((self.blocks_file_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 3),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 1),
                     (self.blocks_null_sink_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 2),
                     (self.blocks_null_sink_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
Example #10
0
    def __init__(self, options):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Blocks
        ##################################################

        # Calibrating so do not need a sink (empty calibration)
        if options.mode == 1 or options.mode == 2 or options.mode == 10:
            # addr0 is of sweeper
            # Note that mode 2, 1 and 10 require two time-synced USRPs
            self.usrp_source = uhd.usrp_source(
                ",".join(("addr0=192.168.10.2,addr1=192.168.20.3", "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(2),
                ),
            )
            if options.mode == 2:
                self.usrp_sink = uhd.usrp_sink(
                    ",".join(("addr0=192.168.10.2,addr1=192.168.20.3", "")),
                    uhd.stream_args(
                        cpu_format="fc32",
                        channels=range(2),
                    ),
                )
        elif options.mode == 3 or options.mode == 0 or options.mode == 30:
            # dev_args is of sweeper
            self.usrp_source = uhd.usrp_source(
                ",".join((options.dev_args, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
        else:
            stderr.write("You gave me an option I do not know about\n")
            exit(1)

        # Initialization code for controlling the DAC output
        self.chan = 0
        self.unit = uhd.dboard_iface.UNIT_TX
        self.dac = uhd.dboard_iface.AUX_DAC_A
        self.iface = self.usrp_source.get_dboard_iface(self.chan)
        #self.iface.write_aux_dac_config(32)
        self.iface.write_aux_dac(self.unit, self.dac, 0.2)

        # Configure frequency band registers (depending on daughter board)
        # Channel 1 on MIMO cable is the sweeper USRP
        usrp_info = self.usrp_source.get_usrp_info(0)
        db_name = usrp_info["rx_subdev_name"]
        user_reg_1 = 0
        user_reg_2 = 0
        print("NAME: " + db_name)
        if (db_name.find("SBX") != -1):
            # The following two registers can be configured for frequency band
            # 2.4 GHz comes in 16 and 24
            # for all 37 bands, put 4294967295 in reg 1 and 31 in reg 2
            stderr.write("Detected SBX DB...\n")
            user_reg_1 = 48  # frequncy bit array for first 32 bands  #32-band6#64-band7
            user_reg_2 = 0  # frequency bit array for next 5 bands
        elif (db_name.find("CBX") != -1):
            # 2.4 GHz
            stderr.write("Detected CBX DB...\n")
            user_reg_1 = options.band1  # frequncy bit array for first 32 bands
            user_reg_2 = options.band2  # frequency bit array for next 32 bands
            rf_div = options.rf_div  # RfOut divider for VCO
        else:
            stderr.write("Error: Unknown daughterboard: %s\n" % db_name)
            exit(1)

        # Chirp enable
        self.usrp_source.set_user_register(3, 1, 0)

        self.usrp_source.set_user_register(1, user_reg_1, 0)
        self.usrp_source.set_user_register(2, user_reg_2, 0)
        self.usrp_source.set_user_register(6, rf_div, 0)
        #Address 5 -Clk divider
        self.usrp_source.set_user_register(5, 4, 0)

        #self.usrp_source.set_user_register(6,1,0) # RF divider to give 400-4.4GHz range. Valid values are 1,2,4,8 and 16.
        # The following are the new registers that need to be set
        # for the updated hardware code.
        # register 4 = jump value - 12 bit number
        self.usrp_source.set_user_register(4, options.step, 0)
        # register 7 = start_ramp - 12 bit number
        self.usrp_source.set_user_register(7, 621, 0)
        # register 8 = end_ramp - 12 bit number
        self.usrp_source.set_user_register(8, 3103, 0)

        self.usrp_source.set_user_register(6, options.rf_div, 0)

        if len(options.filename) == 0:
            # No filenames given -- just connect to a null source
            self.null_sink0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
            # Connections
            self.connect((self.usrp_source, 0), (self.null_sink0, 0))
            if options.mode == 1:
                self.null_sink1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
                self.connect((self.usrp_source, 1), (self.null_sink1, 0))

        elif len(options.filename) >= 1:
            if options.mode == 1 or options.mode == 10:
                # Synchronous reception : creates two time synced files
                # options.filename[0] is the string containing the ground truth rx samples
                # options.filename[1] is the string containing the SweepSense rx samples
                # options.filename[2] is the string containing the name of the calibration file

                # Setting params for sweeper
                self.usrp_source.set_gain(options.rgain, 0)
                self.usrp_source.set_antenna("RX2", 0)
                self.usrp_source.set_bandwidth(options.samp, 0)

                # self.usrp_sink.set_gain(options.tgain,0)
                # self.usrp_sink.set_antenna("TX/RX",0)
                # self.usrp_sink.set_center_freq(2212e6,0)
                # self.usrp_sink.set_bandwidth(options.txsamp,0)

                # Setting params for ground truth
                self.usrp_source.set_samp_rate(options.samp)
                self.usrp_source.set_gain(options.rgain, 1)
                self.usrp_source.set_antenna("TX/RX", 1)
                self.usrp_source.set_center_freq(options.txfreq, 1)
                self.usrp_source.set_bandwidth(options.samp, 1)
                self.usrp_source.set_clock_source("mimo", 1)
                self.usrp_source.set_time_source("mimo", 1)

                # Initialize USRP sink
                # self.usrp_sink.set_samp_rate(options.txsamp)
                # self.usrp_sink.set_gain(options.tgain,1)
                # self.usrp_sink.set_antenna("RX2",1)
                # self.usrp_sink.set_center_freq(options.txfreq,1)
                # self.usrp_sink.set_bandwidth(options.txsamp,1)
                # self.usrp_sink.set_clock_source("mimo",1)
                # self.usrp_sink.set_time_source("mimo",1)
                # We are using a MIMO cable 2 USRP setup to transmit (but not sure why we need two transmitters)

                # Null sinks for the slave source
                # self.null_source_2 = blocks.null_source(gr.sizeof_gr_complex*1)
                # self.null_source_3 = blocks.null_source(gr.sizeof_gr_complex*1)

                # Sample blockers
                # to do, add M in N here
                self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)
                self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)
                # self.blocks_head_2 = blocks.head(gr.sizeof_gr_complex*1,options.maxsamp)
                # self.blocks_head_3 = blocks.head(gr.sizeof_gr_complex*1,options.maxsamp)

                # file blocks
                self.blocks_file_sink_0 = blocks.file_sink(
                    gr.sizeof_gr_complex * 1, options.filename[0], False)
                self.blocks_file_sink_1 = blocks.file_sink(
                    gr.sizeof_gr_complex * 1, options.filename[1], False)
                self.blocks_file_sink_0.set_unbuffered(False)
                self.blocks_file_sink_1.set_unbuffered(False)

                if options.mode == 1:
                    # Mode for compensated
                    self.blocks_file_src_cal = blocks.file_source(
                        gr.sizeof_gr_complex * 1, options.filename[2], True)

                if options.mode == 10:
                    # Mode for uncompensated
                    self.blocks_file_src_cal = analog.sig_source_c(
                        0, analog.GR_CONST_WAVE, 0, 0, 1)

                # conjugate multiplier for compensation
                self.blocks_mult_conj = blocks.multiply_conjugate_cc(1)

                # Connections
                self.connect((self.usrp_source, 1), (self.blocks_head_0, 0))
                self.connect((self.usrp_source, 0),
                             (self.blocks_mult_conj, 0))  # sweeper to multiply
                self.connect((self.blocks_file_src_cal, 0),
                             (self.blocks_mult_conj, 1))  # cal to multiply

                self.connect((self.blocks_mult_conj, 0),
                             (self.blocks_head_1, 0))  # multiply to head
                # self.connect((self.null_source_2,0),(self.blocks_head_2,0))
                # self.connect((self.null_source_3,0),(self.blocks_head_3,0))

                self.connect((self.blocks_head_0, 0),
                             (self.blocks_file_sink_0, 0))
                self.connect((self.blocks_head_1, 0),
                             (self.blocks_file_sink_1, 0))
                # self.connect((self.blocks_head_2,0),(self.usrp_sink,0))
                # self.connect((self.blocks_head_3,0),(self.usrp_sink,1))

            elif options.mode == 3 or options.mode == 30:
                # SweepSense standalone reception : creates a single received file
                # options.filename[0] is the string containing the name of the file you want to store to
                # options.filename[1] is the string containing the name of the calibration file
                # Setting params for sweeper
                self.usrp_source.set_gain(options.rgain, 0)
                self.usrp_source.set_antenna("RX2", 0)
                self.usrp_source.set_bandwidth(options.samp, 0)
                self.usrp_source.set_samp_rate(options.samp)

                # Sample blockers
                self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)
                self.blocks_skiphead_0 = blocks.skiphead(
                    gr.sizeof_gr_complex * 1, options.skip)

                # file blocks
                self.blocks_file_sink_0 = blocks.file_sink(
                    gr.sizeof_gr_complex * 1, options.filename[0], False)
                self.blocks_file_sink_0.set_unbuffered(False)

                if options.mode == 3:
                    # compensated signal
                    self.blocks_file_src_cal = blocks.file_source(
                        gr.sizeof_gr_complex * 1, options.filename[1], True)

                if options.mode == 30:
                    # the following is for getting uncompensated stuff
                    self.blocks_file_src_cal = analog.sig_source_c(
                        0, analog.GR_CONST_WAVE, 0, 0, 1)

                # conjugate multiplier for compensation
                self.blocks_mult_conj = blocks.multiply_conjugate_cc(1)

                # DC Blocker
                self.dc_blocker_xx_0 = filter.dc_blocker_cc(256, False)

                # Keep M in N

                self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(
                    gr.sizeof_gr_complex,
                    options.sweep_time * options.num_bands,
                    options.sweep_time * options.num_bands * options.inN, 0)

                # Connections
                self.connect((self.usrp_source, 0),
                             (self.dc_blocker_xx_0, 0))  # sweeper to DC block
                self.connect(
                    (self.dc_blocker_xx_0, 0),
                    (self.blocks_mult_conj, 0))  # DC block to multiply conj
                # self.connect((self.usrp_source,0),(self.blocks_mult_conj,0)) # sweeper to DC block
                self.connect((self.blocks_file_src_cal, 0),
                             (self.blocks_mult_conj, 1))  # cal to multiply

                # no realtime calib - just receive:
                #self.connect((self.dc_blocker_xx_0,0),(self.blocks_head_1,0))

                self.connect((self.blocks_mult_conj, 0),
                             (self.blocks_skiphead_0, 0))  # multiply to head
                #self.connect((self.blocks_skiphead_0,0),(self.blocks_head_1,0))

                self.connect((self.blocks_skiphead_0, 0),
                             (self.blocks_keep_m_in_n_0, 0))
                self.connect((self.blocks_keep_m_in_n_0, 0),
                             (self.blocks_head_1, 0))

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

            elif options.mode == 2:
                # This mode sends pilots on normal USRP & receives through sweeper

                # Setting params for sweeper
                self.usrp_source.set_gain(options.rgain, 0)
                self.usrp_source.set_antenna("RX2", 0)
                self.usrp_source.set_bandwidth(options.samp, 0)

                self.usrp_sink.set_gain(options.tgain, 0)
                self.usrp_sink.set_antenna("TX/RX", 0)
                self.usrp_sink.set_center_freq(
                    options.txfreq - 100e6, 0
                )  # tune to some off band frequency to prevent interference
                self.usrp_sink.set_bandwidth(options.txsamp, 0)

                # Initialize USRP sink - transmitter
                self.usrp_sink.set_samp_rate(options.txsamp)
                self.usrp_sink.set_gain(options.tgain, 1)
                self.usrp_sink.set_antenna("TX/RX", 1)
                self.usrp_sink.set_center_freq(options.txfreq, 1)
                self.usrp_sink.set_bandwidth(options.txsamp, 1)
                self.usrp_sink.set_clock_source("mimo", 1)
                self.usrp_sink.set_time_source("mimo", 1)

                self.usrp_source.set_samp_rate(options.samp)
                self.usrp_source.set_gain(options.rgain, 1)
                self.usrp_source.set_antenna("RX2", 1)
                self.usrp_source.set_center_freq(options.txfreq, 1)
                self.usrp_source.set_bandwidth(options.samp, 1)
                self.usrp_source.set_clock_source("mimo", 1)
                self.usrp_source.set_time_source("mimo", 1)

                # Null sinks for the slave source
                self.null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
                self.null_source_2 = blocks.null_source(gr.sizeof_gr_complex *
                                                        1)

                # Skip heads

                self.blocks_skiphead_0 = blocks.skiphead(
                    gr.sizeof_gr_complex * 1, options.skip)
                self.blocks_skiphead_1 = blocks.skiphead(
                    gr.sizeof_gr_complex * 1, options.skip)

                self.blocks_skiphead_2 = blocks.skiphead(
                    gr.sizeof_gr_complex * 1, options.skip)
                self.blocks_skiphead_3 = blocks.skiphead(
                    gr.sizeof_gr_complex * 1, options.skip)

                # Sample blockers
                self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)
                self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)
                self.blocks_head_2 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)
                self.blocks_head_3 = blocks.head(gr.sizeof_gr_complex * 1,
                                                 options.maxsamp)

                # TODO: add squelch to get only good signals from calibration - we need to get the values of the squelch as well

                # file blocks
                # options.filename[0] is used to store the received calibration tone
                # transmitted tone is 10 kHz offset from the actual centre frequency as below:
                self.blocks_file_source_3 = analog.sig_source_c(
                    options.samp, analog.GR_COS_WAVE, 10000, 1,
                    0)  # using complex cosine
                self.blocks_file_sink_1 = blocks.file_sink(
                    gr.sizeof_gr_complex * 1, options.filename[0], False)
                self.blocks_file_sink_1.set_unbuffered(False)

                # Connections
                self.connect((self.usrp_source, 1),
                             (self.blocks_skiphead_2, 0))
                self.connect((self.usrp_source, 0),
                             (self.blocks_skiphead_0, 0))
                self.connect((self.blocks_file_source_3, 0),
                             (self.blocks_skiphead_1, 0))
                self.connect((self.null_source_2, 0),
                             (self.blocks_skiphead_3, 0))

                self.connect((self.blocks_skiphead_2, 0),
                             (self.blocks_head_0, 0))
                self.connect((self.blocks_skiphead_3, 0),
                             (self.blocks_head_2, 0))

                self.connect((self.blocks_skiphead_0, 0),
                             (self.blocks_head_1, 0))
                self.connect((self.blocks_skiphead_1, 0),
                             (self.blocks_head_3, 0))

                self.connect((self.blocks_head_0, 0), (self.null_sink_0, 0))
                self.connect((self.blocks_head_1, 0),
                             (self.blocks_file_sink_1, 0))
                self.connect((self.blocks_head_3, 0), (self.usrp_sink, 1))
                self.connect((self.blocks_head_2, 0), (self.usrp_sink, 0))
Example #11
0
    def _setup_receiver(self):
        ### receiver blocks ###
        self.osmosdr_source_0 = osmosdr.source(args="numchan=1" + " " +
                                               self.radio_id)
        self.osmosdr_source_0.set_sample_rate(self.radio_sample_rate)
        self.osmosdr_source_0.set_center_freq(
            self.frequency + self.freq_offset, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(int(self.bandwidth * 10), 0)

        # something in the resampler blocks is causing 34 output samples to be lost in each
        # resampler, so adjust the total number in order to compensate for these lost samples,
        # calculating backwards up the path so the number gets scaled up by each decimation amount
        num_adjusted_samples = (34 + self.num_final_samples) * (
            self.int2_sample_rate / self.final_sample_rate)
        num_adjusted_samples = (34 + num_adjusted_samples) * (
            self.int1_sample_rate / self.int2_sample_rate)
        num_adjusted_samples = int(
            (34 + num_adjusted_samples) *
            (self.radio_sample_rate / self.int1_sample_rate))

        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                         num_adjusted_samples)

        self.rational_resampler_recv_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(self.radio_sample_rate / self.int1_sample_rate),
            taps=None,
            fractional_bw=None,
        )

        #self.low_pass_filter_recv_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        #    1, self.int1_sample_rate, self.bandwidth*2, self.transition, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_recv_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, self.int1_sample_rate, self.bandwidth,
                            self.transition, firdes.WIN_HAMMING, 6.76))

        self.rational_resampler_recv_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(self.int1_sample_rate / self.int2_sample_rate),
            taps=None,
            fractional_bw=None,
        )

        self.dc_blocker_0 = filter.dc_blocker_cc(32, True)

        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        self.blocks_moving_average_0 = blocks.moving_average_ff(length=1000,
                                                                scale=1,
                                                                max_iter=1000)

        self.rational_resampler_recv_2 = filter.rational_resampler_fff(
            interpolation=1,
            decimation=int(self.int2_sample_rate / self.final_sample_rate),
            taps=None,
            fractional_bw=None,
        )

        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1,
                                                 "localhost", self.data_port,
                                                 1472, True)
        ### end receiver blocks ###

        ### receiver connections ###
        self.connect((self.osmosdr_source_0, 0), (self.blocks_head_0, 0))
        self.connect((self.blocks_head_0, 0),
                     (self.rational_resampler_recv_0, 0))
        self.connect((self.rational_resampler_recv_0, 0),
                     (self.low_pass_filter_recv_0, 0))
        self.connect((self.low_pass_filter_recv_0, 0),
                     (self.rational_resampler_recv_1, 0))
        #self.connect((self.blocks_head_0, 0), (self.low_pass_filter_recv_0, 0))
        #self.connect((self.low_pass_filter_recv_0, 0), (self.rational_resampler_recv_0, 0))
        #self.connect((self.rational_resampler_recv_0, 0), (self.rational_resampler_recv_1, 0))
        self.connect((self.rational_resampler_recv_1, 0),
                     (self.dc_blocker_0, 0))
        self.connect((self.dc_blocker_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_moving_average_0, 0))
        self.connect((self.blocks_moving_average_0, 0),
                     (self.rational_resampler_recv_2, 0))
        self.connect((self.rational_resampler_recv_2, 0),
                     (self.blocks_udp_sink_0, 0))
        ### end receiver connections ###
        return
Example #12
0
rtl1.set_sample_rate(samp_rate)
rtl1.set_center_freq(cf, 0)
rtl1.set_freq_corr(0, 0)
rtl1.set_dc_offset_mode(2, 0)
rtl1.set_iq_balance_mode(0, 0)
rtl1.set_gain_mode(0, 0)
rtl1.set_gain(rfgain, 0)
rtl1.set_if_gain(ifgain, 0)
rtl1.set_bb_gain(0, 0)
rtl1.set_antenna("", 0)
rtl1.set_bandwidth(1e6, 0)
		  
lpf0 = filter.fir_filter_ccc(dec, (firdes.low_pass_2(1, samp_rate, 50e3, 10e3, 40, firdes.WIN_BLACKMAN_hARRIS)))
lpf1 = filter.fir_filter_ccc(dec, (firdes.low_pass_2(1, samp_rate, 50e3, 10e3, 40, firdes.WIN_BLACKMAN_hARRIS)))

dc0 = filter.dc_blocker_cc(1000, True)
dc1 = filter.dc_blocker_cc(1000, True)

rtl0.set_gain(0.0, 0)
rtl0.set_if_gain(0.0, 0)
rtl1.set_gain(0.0, 0)
rtl1.set_if_gain(0.0, 0)
		
tstamp=time_stamp()
os.makedirs("%s-%s/000"%(op.name,tstamp))
os.makedirs("%s-%s/001"%(op.name,tstamp))
print "Making dir %s-%s/000"%(op.name,tstamp)
print "Making dir %s-%s/001"%(op.name,tstamp)
fsink0 = juha.filesink("%s-%s/000"%(op.name,tstamp),gr.sizeof_gr_complex, int(samp_rate/dec))
fsink1 = juha.filesink("%s-%s/001"%(op.name,tstamp),gr.sizeof_gr_complex, int(samp_rate/dec))
Example #13
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM Transceiver")
        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", "ofdm_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        self._lock = threading.RLock()

        ##################################################
        # Variables
        ##################################################
        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_length_tag_key = packet_length_tag_key = "packet_len"
        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 = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.waterfall_min = waterfall_min = -140
        self.waterfall_max = waterfall_max = -20
        self.tx_gain = tx_gain = 0.01
        self.th = th = 10**(-40/10)
        self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j]
        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.size = size = 256
        self.samp_rate = samp_rate = 2e6
        self.period = period = 10
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1)
        self.nsamples = nsamples = 1000
        self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols)
        self.center_freq = center_freq = 2.412e9

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "Spectrum")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "Settings")
        self.top_layout.addWidget(self.tab)
        self._waterfall_min_range = Range(-200, -50, 1, -140, 200)
        self._waterfall_min_win = RangeWidget(self._waterfall_min_range, self.set_waterfall_min, "Waterfall Min", "counter_slider", float)
        self.tab_layout_1.addWidget(self._waterfall_min_win)
        self._waterfall_max_range = Range(-50, 0, 1, -20, 200)
        self._waterfall_max_win = RangeWidget(self._waterfall_max_range, self.set_waterfall_max, "Waterfall Max", "counter_slider", float)
        self.tab_layout_1.addWidget(self._waterfall_max_win)
        self._samp_rate_options = [1.5e6, 2e6, 4e6, 5e6, 10e6, 20e6 ]
        self._samp_rate_labels = ["1.5 MHz", "2 MHz", "4 MHz", "5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate [MHz]"+": "))
        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.tab_layout_0.addWidget(self._samp_rate_tool_bar)
        self._center_freq_options = [868e6, 2.412e9, 2.417e9, 2.422e9, 2.427e9, 2.432e9, 2.437e9, 2.442e9, 2.447e9, 2.452e9, 2.457e9, 2.462e9, 2.467e9, 2.472e9]
        self._center_freq_labels = ["868M", "1",  "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",  "12", "13"]
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(Qt.QLabel("Channel"+": "))
        self._center_freq_combo_box = Qt.QComboBox()
        self._center_freq_tool_bar.addWidget(self._center_freq_combo_box)
        for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_layout.addWidget(self._center_freq_tool_bar)
        self._tx_gain_range = Range(0, 1, 0.001, 0.01, 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._th_range = Range(10**(-80/10), 10**(-10/10), 0.0001, 10**(-40/10), 200)
        self._th_win = RangeWidget(self._th_range, self.set_th, "Threshold", "counter_slider", float)
        self.tab_layout_0.addWidget(self._th_win)
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	center_freq, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.01)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()
        
        if complex == type(float()):
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [5, 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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(waterfall_min, waterfall_max)
        
        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win)
        self._period_range = Range(1, 10000, 1, 10, 200)
        self._period_win = RangeWidget(self._period_range, self.set_period, "Period", "counter_slider", float)
        self.tab_layout_1.addWidget(self._period_win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_0.set_iq_balance_mode(1, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)
          
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=64, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+packet_length_tag_key,
        	  packet_length_tag_key=packet_length_tag_key,
        	  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=1,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(128, True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, packet_length_tag_key)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.dc_blocker_xx_0, 0), (self.digital_ofdm_rx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))    
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))    
Example #14
0
    def __init__(self, freq, FFT_size, SDR_BW, receiver_type, gain, portnum,
                 extraargs):
        gr.top_block.__init__(self, 'Spectrum')

        ##################################################
        # Variables
        ##################################################
        self.tuning = tuning = 0
        self.freq = freq
        self.samp_rate = samp_rate = SDR_BW  #needs to be <BW of radio. eg at 200e6 for the x300 U160 spectrum_log.py froze after ~20 O overflows ~30 integrations
        self.data_address = data_address = 'tcp://127.0.0.1:' + str(portnum)
        self.SDR_BW = SDR_BW
        self.FFT_size = FFT_size  #take the FFT_size from the input
        self.receiver_type = receiver_type
        self.gain = gain

        ##################################################
        # Blocks
        ##################################################
        self.fft_vxx_0 = fft.fft_vcc(FFT_size, True,
                                     (window.blackmanharris(FFT_size)), True,
                                     1)
        self.dc_blocker_xx_0 = gr_filter.dc_blocker_cc(1024, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, FFT_size)
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex,
                                                   FFT_size, data_address, 100,
                                                   False, -1)
        #       self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 512)
        #       self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "fifo", True)
        #       self.blocks_file_sink_0.set_unbuffered(False)

        if receiver_type == 'rtl':
            self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) +
                                                   " " + "rtl=0" + extraargs)
            print('Reciever: RTL-SDR')
        elif receiver_type == 'airspy':
            self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) +
                                                   " " + "airspy" + extraargs)
            print('Reciever: Airspy')
        elif receiver_type == 'osmo':
            self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) +
                                                   " " + "" + extraargs[1:])
            print(
                'Receiver: osmo (first gr-osmocom compatible receiver found)')
        elif receiver_type == 'uhd':
            self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) +
                                                   " " + "uhd" + extraargs)
            print('Receiver: UHD')
        elif receiver_type == 'funcube':
            self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) +
                                                   " " + "fcd=0" + extraargs)
            print('Receiver: Funcube Pro/Pro+')

        if receiver_type in ['rtl', 'airspy', 'osmo', 'uhd', 'funcube']:
            self.osmosdr_source_0.set_sample_rate(SDR_BW)
            self.osmosdr_source_0.set_center_freq(
                freq, 0
            )  # first tuning happens here. Later tunings use set_tuning below
            self.osmosdr_source_0.set_dc_offset_mode(2, 0)
            self.osmosdr_source_0.set_gain_mode(True, 0)
            self.osmosdr_source_0.set_gain(gain, 0)
            self.osmosdr_source_0.set_bandwidth(0, 0)
            # Following args and others can be set by the "extraargs" command line option
            #            self.osmosdr_source_0.set_freq_corr(0, 0)
            #            self.osmosdr_source_0.set_if_gain(10, 0)
            #            self.osmosdr_source_0.set_bb_gain(10, 0)
            #            self.osmosdr_source_0.set_antenna("", 0)
            if receiver_type == 'uhd':
                self.osmosdr_source_0.set_bandwidth(1.5 * SDR_BW, 0)
            self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        else:
            print('Receiver type not recognized. Trying gr_osmocom drivers...')
            self.osmosdr_source_0.set_sample_rate(SDR_BW)
            self.osmosdr_source_0.set_center_freq(freq, 0)
            self.osmosdr_source_0.set_dc_offset_mode(2, 0)
            self.osmosdr_source_0.set_iq_balance_mode(0, 0)
            self.osmosdr_source_0.set_gain_mode(True, 0)
            self.osmosdr_source_0.set_gain(gain, 0)
            self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))

        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.zeromq_push_sink_0, 0))
Example #15
0
    def __init__(self):
        gr.top_block.__init__(self, "ELEKTRO-L2/L3 TLM Demodulator")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("ELEKTRO-L2/L3 TLM Demodulator")
        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", "elektro_tlm")

        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.file_rate = file_rate = 1024000
        self.sym_rate = sym_rate = 5000.0
        self.samp_rate = samp_rate = file_rate / 4
        self.sps = sps = samp_rate / sym_rate
        self.offset = offset = 0

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1, decimation=4, taps=None, fractional_bw=None)
        self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_b(
            samp_rate, 100, 1792, [], [], "", 1)

        self.qtgui_time_raster_sink_x_0.set_update_time(0.10)
        self.qtgui_time_raster_sink_x_0.set_intensity_range(-1, 1)
        self.qtgui_time_raster_sink_x_0.enable_grid(False)
        self.qtgui_time_raster_sink_x_0.enable_axis_labels(False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [2, 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_time_raster_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_win, 3,
                                       0, 1, 2)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1)
        self.qtgui_freq_sink_x_0_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-65, -15)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 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.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1)
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-65, 0)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.05)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            256,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.01)
        self.qtgui_const_sink_x_0.set_y_axis(-0.5, 0.5)
        self.qtgui_const_sink_x_0.set_x_axis(-0.5, 0.5)
        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(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(False)

        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 range(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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 1, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 4.5e3, 1e3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(
            1, firdes.low_pass(1, samp_rate, samp_rate / (2 * 1), 1000),
            offset, samp_rate)
        self.freq_xlating_fft_filter_ccc_0.set_nthreads(1)
        self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(3e-3, 2, False)
        self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_cc(
            sps * (1 + 0.0), 0.625e-3, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_wavfile_source_0 = blocks.wavfile_source('', True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 28,
                                                 '127.0.0.1', 52001, 1472,
                                                 True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 file_rate, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_char * 1, 224)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_cc(
            2, 0.5, 4000, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, -5000, 1, 0, 0)
        self.analog_agc_xx_0_0_0 = analog.agc_cc(10e-3, 500e-3, 0.5)
        self.analog_agc_xx_0_0_0.set_max_gain(4e3)
        self.analog_agc_xx_0_0 = analog.agc_cc(10e-3, 500e-3, 0.5)
        self.analog_agc_xx_0_0.set_max_gain(4e3)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_agc_xx_0_0_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_agc_xx_0_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.qtgui_time_raster_sink_x_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_1, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_1, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_clock_recovery_mm_xx_1, 0))
        self.connect((self.freq_xlating_fft_filter_ccc_0, 0),
                     (self.analog_agc_xx_0_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.freq_xlating_fft_filter_ccc_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
Example #16
0
    def __init__(self, outfile=""):
        grc_wxgui.top_block_gui.__init__(self, title="Record Jamming")

        ##################################################
        # Parameters
        ##################################################
        self.outfile = outfile

        ##################################################
        # Variables
        ##################################################
        self.key_freq = key_freq = 433.92e6
        self.samp_rate = samp_rate = 2e6
        self.offset = offset = 220e3
        self.freq = freq = key_freq

        ##################################################
        # 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='freq',
            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=key_freq - 10e6,
            maximum=key_freq + 10e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=freq - offset,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title='Waterfall Plot',
        )
        self.Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=freq - offset,
            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.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq - offset, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(17, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.high_pass_filter_0 = filter.fir_filter_ccf(
            1, firdes.high_pass(1, samp_rate, 220e3, 5e3, firdes.WIN_HANN,
                                6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   outfile, False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.dc_blocker_xx_0, 0), (self.high_pass_filter_0, 0))
        self.connect((self.high_pass_filter_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.high_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.high_pass_filter_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
Example #17
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.var_sample_rate = var_sample_rate = 2500000
        self.var_reverse_fft_size = var_reverse_fft_size = 32
        self.var_freq = var_freq = 433000000
        self.var_fft_size = var_fft_size = 2048

        ##################################################
        # Blocks
        ##################################################
        _var_sample_rate_sizer = wx.BoxSizer(wx.VERTICAL)
        self._var_sample_rate_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_var_sample_rate_sizer,
            value=self.var_sample_rate,
            callback=self.set_var_sample_rate,
            label='var_sample_rate',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._var_sample_rate_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_var_sample_rate_sizer,
            value=self.var_sample_rate,
            callback=self.set_var_sample_rate,
            minimum=1000000,
            maximum=20000000,
            num_steps=40,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_var_sample_rate_sizer)
        self._var_reverse_fft_size_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.var_reverse_fft_size,
            callback=self.set_var_reverse_fft_size,
            label='var_reverse_fft_size',
            converter=forms.int_converter(),
        )
        self.Add(self._var_reverse_fft_size_text_box)
        self._var_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.var_freq,
            callback=self.set_var_freq,
            label='var_freq',
            converter=forms.float_converter(),
        )
        self.Add(self._var_freq_text_box)
        self._var_fft_size_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.var_fft_size,
            callback=self.set_var_fft_size,
            label='var_fft_size',
            converter=forms.int_converter(),
        )
        self.Add(self._var_fft_size_text_box)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(),
                                                        style=wx.NB_RIGHT)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "Before filter")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0),
                                "After filter")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Post-FM")
        self.Add(self.notebook_0)
        self.wxgui_waterfallsink2_1_0_0 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=0,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=var_sample_rate * var_reverse_fft_size / var_fft_size,
            fft_size=512,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="From auto-tune",
        )
        self.Add(self.wxgui_waterfallsink2_1_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.notebook_0.GetPage(0).GetWin(),
            baseband_freq=var_freq,
            dynamic_range=100,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=var_sample_rate,
            fft_size=1024,
            fft_rate=15,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
            win=window.hanning,
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 0,
                                           0, 1, 1)
        self.wxgui_scopesink2_1_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="After C2M2",
            sample_rate=var_sample_rate * var_reverse_fft_size / var_fft_size,
            v_scale=20,
            v_offset=0,
            t_scale=1,
            ac_couple=True,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_NORM,
            y_axis_label="Amplitude",
        )
        self.Add(self.wxgui_scopesink2_1_0.win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "hackrf=0")
        self.osmosdr_source_0.set_sample_rate(var_sample_rate)
        self.osmosdr_source_0.set_center_freq(var_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_vxx_1_0 = fft.fft_vcc(var_reverse_fft_size, False, (), True,
                                       4)
        self.fft_vxx_0 = fft.fft_vcc(var_fft_size, True, (), False, 4)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_vector_to_stream_1_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, var_reverse_fft_size)
        self.blocks_stream_to_vector_2 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, var_reverse_fft_size)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, var_fft_size)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/mike/source/gr-autotune/examples/to-grc.fifo", False)
        self.blocks_file_sink_2 = blocks.file_sink(
            gr.sizeof_gr_complex * var_fft_size,
            "/home/mike/source/gr-autotune/examples/from-grc.fifo", True)
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.wxgui_scopesink2_1_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_vector_2, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_2, 0),
                     (self.fft_vxx_1_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_vector_to_stream_1_0, 0),
                     (self.wxgui_waterfallsink2_1_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_2, 0))
        self.connect((self.fft_vxx_1_0, 0),
                     (self.blocks_vector_to_stream_1_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
Example #18
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.decimation = decimation = 1
        self.samp_rate = samp_rate = 50e3 / decimation
        self.baud = baud = 8320
        self.sps = sps = samp_rate / (baud * 2.0)
        self.nfilts = nfilts = 72
        self.ebw = ebw = 0.25
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), ebw, 64 * nfilts)
        self.lp_taps = lp_taps = firdes.low_pass_2(nfilts, nfilts, 2 / sps,
                                                   0.05, nfilts)
        self.bp_taps = bp_taps = firdes.band_pass_2(nfilts, nfilts,
                                                    0.1 / float(sps),
                                                    1.2 / float(sps), ebw,
                                                    64 * nfilts)

        self.NOAA_DSB_Constellation = NOAA_DSB_Constellation = digital.constellation_bpsk(
        ).base()

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decimation,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'QT GUI Plot',  #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(-80, -20)

        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.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       1)
        self.qtgui_number_sink_0_1.set_update_time(0.25)
        self.qtgui_number_sink_0_1.set_title('Bitrate')

        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_1.set_min(i, -1)
            self.qtgui_number_sink_0_1.set_max(i, 1)
            self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0_1.set_label(i, labels[i])
            self.qtgui_number_sink_0_1.set_unit(i, units[i])
            self.qtgui_number_sink_0_1.set_factor(i, factor[i])

        self.qtgui_number_sink_0_1.enable_autoscale(True)
        self._qtgui_number_sink_0_1_win = sip.wrapinstance(
            self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_win)
        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.25)
        self.qtgui_number_sink_0.set_title('Error')

        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(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            'QT GUI Plot',  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.05)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 11000, 6000, firdes.WIN_BLACKMAN,
                            6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, .068 / 1.5, (lp_taps), nfilts, 0, 10, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            NOAA_DSB_Constellation)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            6, 1, .0000005, 2)
        self.dc_blocker_xx_0_0 = filter.dc_blocker_cc(16, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * 24, True)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            'C:\\Users\\Sevy\\Desktop\\School\\ETH\\SDR\\POES_56k250.raw',
            False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1,
            'C:\\Users\\Sevy\\Desktop\\School\\ETH\\SDR\\NotMinePackedOut.txt',
            False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(
            0.068 / 12, 6000 * 2 * 3.14159 / samp_rate,
            -6000 * 2 * 3.14159 / samp_rate)
        self.analog_agc2_xx_0 = analog.agc2_cc(0.5, 1, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0),
                     (self.dc_blocker_xx_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 3),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 1),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 2),
                     (self.qtgui_number_sink_0_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
Example #19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.snr_vary = snr_vary = 1e-2
        self.samp_rate_0 = samp_rate_0 = 10e5
        self.samp_rate = samp_rate = 1e6
        self.channel_width = channel_width = 200e3
        self.center_freq = center_freq = 800e6

        ##################################################
        # Blocks
        ##################################################
        _center_freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._center_freq_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_center_freq_sizer,
            value=self.center_freq,
            callback=self.set_center_freq,
            label='center_freq',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._center_freq_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_center_freq_sizer,
            value=self.center_freq,
            callback=self.set_center_freq,
            minimum=750e6,
            maximum=900e6,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_center_freq_sizer)
        self.wxgui_numbersink2_0_0_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Units",
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=2,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="energy2",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0_0_0.win)
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit="Units",
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=2,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="energy_my",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0_0.win)
        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)
        _snr_vary_sizer = wx.BoxSizer(wx.VERTICAL)
        self._snr_vary_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_snr_vary_sizer,
            value=self.snr_vary,
            callback=self.set_snr_vary,
            label='snr_vary',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._snr_vary_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_snr_vary_sizer,
            value=self.snr_vary,
            callback=self.set_snr_vary,
            minimum=0,
            maximum=1,
            num_steps=1000,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_snr_vary_sizer)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            50000, 20e-6, 4000)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_float * 1,
            "/home/nitr/Dropbox/Sagnik_project/grc_files/bladeRF_data/signal_data_cyclo_50db_2.dat",
            False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_float * 1,
            "/home/nitr/Dropbox/Sagnik_project/grc_files/bladeRF_data/signal_data_ED_50db.dat",
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.wxgui_numbersink2_0_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.wxgui_numbersink2_0_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
Example #20
0
    def __init__(self):
        gr.top_block.__init__(self, "qtrfiq.py")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("qtrfiq.py")
        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", "qtrfiq")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.rig_freq = rig_freq = float(subprocess.check_output(['/usr/bin/rigctl', '-m', '2', 'f']).strip())
        self.samp_rate = samp_rate = 96000
        self.freq = freq = rig_freq
        self.SetSampleRateProbe = SetSampleRateProbe = 1
        self.SetRigFreqProbe = SetRigFreqProbe = 0

        ##################################################
        # Blocks
        ##################################################
        self.iqbalance_optimize_c_0 = iqbalance.optimize_c(1024)
        self.iqbalance_fix_cc_0 = iqbalance.fix_cc(0, 0)
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("Frequency"+": "))
        self._freq_line_edit = Qt.QLineEdit(str(self.freq))
        self._freq_tool_bar.addWidget(self._freq_line_edit)
        self._freq_line_edit.returnPressed.connect(
        	lambda: self.set_freq(eng_notation.str_to_num(self._freq_line_edit.text().toAscii())))
        self.top_grid_layout.addWidget(self._freq_tool_bar, 0,0,1,1)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(rig_freq, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win)
        self.dc_blocker_xx_1 = filter.dc_blocker_cc(1024, True)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.audio_source_0 = audio.source(samp_rate, "hw:4,1", True)
        def _SetSampleRateProbe_probe():
            while True:
                val = self.set_samp_rate(self.samp_rate)
                try:
                    self.set_SetSampleRateProbe(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (20))
        _SetSampleRateProbe_thread = threading.Thread(target=_SetSampleRateProbe_probe)
        _SetSampleRateProbe_thread.daemon = True
        _SetSampleRateProbe_thread.start()
        def _SetRigFreqProbe_probe():
            while True:
                val = self.set_rig_freq(float(subprocess.check_output(['/usr/bin/rigctl','-m','2','f']).strip()))
                try:
                    self.set_SetRigFreqProbe(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (5))
        _SetRigFreqProbe_thread = threading.Thread(target=_SetRigFreqProbe_probe)
        _SetRigFreqProbe_thread.daemon = True
        _SetRigFreqProbe_thread.start()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_complex_0, 0), (self.iqbalance_optimize_c_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.iqbalance_fix_cc_0, 0))
        self.connect((self.iqbalance_fix_cc_0, 0), (self.dc_blocker_xx_1, 0))
        self.connect((self.dc_blocker_xx_1, 0), (self.fosphor_qt_sink_c_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.iqbalance_optimize_c_0, "iqbal_corr", self.iqbalance_fix_cc_0, "iqbal_corr")
Example #21
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="gr-kx3")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
        ##################################################
        # Variables
        ##################################################
        self.rig_freq = rig_freq = float(pexpect.run("rigctl -m 2 f"))
        self.rigctl = pexpect.spawn("rigctl -m 2")
        self.rigctl.timeout = 2.5
        self.prefix = prefix = "~/grdata"
        self.sync_freq = sync_freq = 3
        self.samp_rate = samp_rate
        self.recfile = recfile = prefix + datetime.now().strftime(
            "%Y.%m.%d.%H.%M.%S") + ".dat"
        self.freq = freq = rig_freq
        self.click_freq = click_freq = 0
        self.step_up = step_up = 1
        self.dwell_up = dwell_up = 1
        self.step_down = step_down = 1
        self.dwell_down = dwell_down = 1
        self.step_size = step_size = 250
        self.ctq_step = self.step_size

        # calculate the number of FFT bins based on the width of the charts
        log_width = math.log(gui_scale * plot_width, 2)
        if (0 != (log_width - int(log_width))):
            log_width = log_width + 1
        num_bins = pow(2, int(log_width))
        print "Setting number of FFT bins to:" + str(num_bins)

        ##################################################
        # Blocks
        ##################################################
        self.nb0 = self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Waterfall")
        self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "FFT")
        self.GridAdd(self.nb0, 2, 0, 5, 8)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.nb0.GetPage(0).GetWin(),
            baseband_freq=rig_freq,
            dynamic_range=20,
            ref_level=-80,
            ref_scale=1.0,
            sample_rate=samp_rate,
            fft_size=num_bins,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="Waterfall Plot",
            win=window.hamming,
            size=(plot_width * gui_scale, plot_height * gui_scale),
        )
        self.nb0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)

        def wxgui_waterfallsink2_0_callback(x, y):
            self.set_click_freq(x)

        self.wxgui_waterfallsink2_0.set_callback(
            wxgui_waterfallsink2_0_callback)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.nb0.GetPage(1).GetWin(),
            baseband_freq=rig_freq,
            y_per_div=10,
            y_divs=12,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=num_bins,
            fft_rate=10,
            average=True,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=True,
            win=window.flattop,
            size=(plot_width * gui_scale, plot_height * gui_scale),
        )
        self.nb0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
        self.gr_float_to_complex_0 = blocks.float_to_complex(1)
        self._freq_text_box = forms.text_box(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_text_freq,
            label="  Frequency (Hz)",
            converter=forms.int_converter(),
        )
        self.GridAdd(self._freq_text_box, 1, 0, 1, 1)
        self._sync_freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.sync_freq,
            callback=self.set_sync_freq,
            label="",
            choices=[1, 2, 3],
            labels=["Entry", "Track", "Track & Click"],
        )
        self.GridAdd(self._sync_freq_chooser, 1, 1, 1, 1)

        self._dwell_down_chooser = forms.button(
            parent=self.GetWin(),
            value=self.dwell_down,
            callback=self.set_dwell_down,
            label="",
            choices=[1],
            labels=["FFT Down"],
        )
        self.GridAdd(self._dwell_down_chooser, 1, 2, 1, 1)

        self._dwell_up_chooser = forms.button(
            parent=self.GetWin(),
            value=self.dwell_up,
            callback=self.set_dwell_up,
            label="",
            choices=[1],
            labels=["FFT Up"],
        )
        self.GridAdd(self._dwell_up_chooser, 1, 3, 1, 1)

        self._step_size_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.step_size,
            callback=self.set_step_size,
            label="\tStep",
            choices=[1000000, 100000, 10000, 1000, 500, 250, 125, 100, 10],
            labels=[
                "1MHz", "100kHz", "10kHz", "1kHz", "500Hz", "250Hz", "125Hz",
                "100Hz", "10Hz"
            ],
        )
        self.GridAdd(self._step_size_chooser, 1, 4, 1, 1)

        self._step_down_chooser = forms.button(
            parent=self.GetWin(),
            value=self.step_down,
            callback=self.set_step_down,
            label="",
            choices=[1],
            labels=["Step Down"],
        )
        self.GridAdd(self._step_down_chooser, 1, 5, 1, 1)

        self._step_up_chooser = forms.button(
            parent=self.GetWin(),
            value=self.step_up,
            callback=self.set_step_up,
            label="",
            choices=[1],
            labels=["Step Up"],
        )
        self.GridAdd(self._step_up_chooser, 1, 6, 1, 1)

        self.audio_source_0 = audio.source(samp_rate, iq_device, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(dc_correction_length, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.audio_source_0, 1), (self.gr_float_to_complex_0, 0))
        self.connect((self.audio_source_0, 0), (self.gr_float_to_complex_0, 1))
        self.connect((self.gr_float_to_complex_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0))

        self.lock = RLock()
        self.vfo_poll_skip = 0
        self.set_rig_vfo = False
        self.quit = False
        _poll_vfo_thread = Thread(target=self._poll_vfo_probe)
        _poll_vfo_thread.daemon = True
        _poll_vfo_thread.start()
Example #22
0
    def __init__(self):
        gr.top_block.__init__(self, "Am Decoder 0")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Am Decoder 0")
        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", "am_decoder_0")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.trans_width = trans_width = 1000
        self.sound_filter_transwidth = sound_filter_transwidth = 20
        self.sound_filter_cutoff = sound_filter_cutoff = 2000
        self.samp_rate = samp_rate = 2000000
        self.cutoff = cutoff = 10000
        self.channel_freq = channel_freq = 127740000

        ##################################################
        # Blocks
        ##################################################
        self._trans_width_range = Range(0, 200000, 100, 1000, 200)
        self._trans_width_win = RangeWidget(self._trans_width_range, self.set_trans_width, "trans_width", "counter_slider", float)
        self.top_layout.addWidget(self._trans_width_win)
        self._sound_filter_transwidth_range = Range(1, 5000, 20, 20, 2005000)
        self._sound_filter_transwidth_win = RangeWidget(self._sound_filter_transwidth_range, self.set_sound_filter_transwidth, 'sound_filter_transwidth', "counter_slider", float)
        self.top_layout.addWidget(self._sound_filter_transwidth_win)
        self._sound_filter_cutoff_range = Range(1000, 5000, 20, 2000, 200)
        self._sound_filter_cutoff_win = RangeWidget(self._sound_filter_cutoff_range, self.set_sound_filter_cutoff, 'sound_filter_cutoff', "counter_slider", float)
        self.top_layout.addWidget(self._sound_filter_cutoff_win)
        self._cutoff_range = Range(0, 200000, 100, 10000, 200)
        self._cutoff_win = RangeWidget(self._cutoff_range, self.set_cutoff, "cutoff", "counter_slider", float)
        self.top_layout.addWidget(self._cutoff_win)
        self._channel_freq_range = Range(0, 140000000, 20000, 127740000, 200)
        self._channel_freq_win = RangeWidget(self._channel_freq_range, self.set_channel_freq, 'channel_freq', "counter_slider", float)
        self.top_layout.addWidget(self._channel_freq_win)
        self.rtl_source = baz.rtl_source_c(defer_creation=True, output_size=gr.sizeof_gr_complex)
        self.rtl_source.set_verbose(True)
        self.rtl_source.set_vid(0x0)
        self.rtl_source.set_pid(0x0)
        self.rtl_source.set_tuner_name('r820t')
        self.rtl_source.set_default_timeout(0)
        self.rtl_source.set_use_buffer(True)
        self.rtl_source.set_fir_coefficients(([]))
        
        self.rtl_source.set_read_length(0)
        
        
        
        
        if self.rtl_source.create() == False: raise Exception("Failed to create RTL2832 Source: rtl_source")
        
        self.rtl_source.set_bandwidth(100000)
        
        self.rtl_source.set_sample_rate(samp_rate)
        
        self.rtl_source.set_frequency(channel_freq)
        
        
        
        self.rtl_source.set_auto_gain_mode(True)
        self.rtl_source.set_relative_gain(True)
        self.rtl_source.set_gain(200)
          
        self.resampler = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.multiply_const_0 = blocks.multiply_const_vff((1, ))
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(1, firdes.low_pass(
        	1, 96000, sound_filter_cutoff, sound_filter_transwidth, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(256, True)
        self.auto_gain_low_pass_filter_0 = eewls.auto_gain_low_pass_filter(filter.fir_filter_ccf, 1, 0.5, samp_rate, cutoff, trans_width, firdes.WIN_HAMMING, 6.76, str(complex))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.am_demod = analog.am_demod_cf(
        	channel_rate=50000,
        	audio_decim=5,
        	audio_pass=5000,
        	audio_stop=5500,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.am_demod, 0), (self.resampler, 0))    
        self.connect((self.auto_gain_low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.am_demod, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.multiply_const_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.resampler, 0), (self.multiply_const_0, 0))    
        self.connect((self.rtl_source, 0), (self.auto_gain_low_pass_filter_0, 0))    
Example #23
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.var_sample_rate = var_sample_rate = 2500000
        self.var_reverse_fft_size = var_reverse_fft_size = 32
        self.var_freq = var_freq = 433000000
        self.var_fft_size = var_fft_size = 2048

        ##################################################
        # Blocks
        ##################################################
        _var_sample_rate_sizer = wx.BoxSizer(wx.VERTICAL)
        self._var_sample_rate_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_var_sample_rate_sizer,
        	value=self.var_sample_rate,
        	callback=self.set_var_sample_rate,
        	label='var_sample_rate',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._var_sample_rate_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_var_sample_rate_sizer,
        	value=self.var_sample_rate,
        	callback=self.set_var_sample_rate,
        	minimum=1000000,
        	maximum=20000000,
        	num_steps=40,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_var_sample_rate_sizer)
        self._var_reverse_fft_size_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.var_reverse_fft_size,
        	callback=self.set_var_reverse_fft_size,
        	label='var_reverse_fft_size',
        	converter=forms.int_converter(),
        )
        self.Add(self._var_reverse_fft_size_text_box)
        self._var_freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.var_freq,
        	callback=self.set_var_freq,
        	label='var_freq',
        	converter=forms.float_converter(),
        )
        self.Add(self._var_freq_text_box)
        self._var_fft_size_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.var_fft_size,
        	callback=self.set_var_fft_size,
        	label='var_fft_size',
        	converter=forms.int_converter(),
        )
        self.Add(self._var_fft_size_text_box)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_RIGHT)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Before filter")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "After filter")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Post-FM")
        self.Add(self.notebook_0)
        self.wxgui_waterfallsink2_1_0_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=var_sample_rate*var_reverse_fft_size/var_fft_size,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="From auto-tune",
        )
        self.Add(self.wxgui_waterfallsink2_1_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=var_freq,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=var_sample_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	win=window.hanning,
        )
        self.notebook_0.GetPage(0).GridAdd(self.wxgui_waterfallsink2_0.win, 0, 0, 1, 1)
        self.wxgui_scopesink2_1_0 = scopesink2.scope_sink_f(
        	self.GetWin(),
        	title="After C2M2",
        	sample_rate=var_sample_rate*var_reverse_fft_size/var_fft_size,
        	v_scale=20,
        	v_offset=0,
        	t_scale=1,
        	ac_couple=True,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_NORM,
        	y_axis_label="Amplitude",
        )
        self.Add(self.wxgui_scopesink2_1_0.win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0" )
        self.osmosdr_source_0.set_sample_rate(var_sample_rate)
        self.osmosdr_source_0.set_center_freq(var_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.fft_vxx_1_0 = fft.fft_vcc(var_reverse_fft_size, False, (), True, 4)
        self.fft_vxx_0 = fft.fft_vcc(var_fft_size, True, (), False, 4)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_vector_to_stream_1_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, var_reverse_fft_size)
        self.blocks_stream_to_vector_2 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, var_reverse_fft_size)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, var_fft_size)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/mike/source/gr-autotune/examples/to-grc.fifo", False)
        self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_gr_complex*var_fft_size, "/home/mike/source/gr-autotune/examples/from-grc.fifo", True)
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.wxgui_scopesink2_1_0, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_vector_2, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_2, 0), (self.fft_vxx_1_0, 0))    
        self.connect((self.blocks_vector_to_stream_1_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.blocks_vector_to_stream_1_0, 0), (self.wxgui_waterfallsink2_1_0_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_file_sink_2, 0))    
        self.connect((self.fft_vxx_1_0, 0), (self.blocks_vector_to_stream_1_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))    
Example #24
0
        def __init__(self):
                grc_wxgui.top_block_gui.__init__(self, title="gr-kx3")
                _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
                self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
                ##################################################
                # Variables
                ##################################################
                self.rig_freq = rig_freq = float(pexpect.run("rigctl -m 2 f"))
                self.rigctl = pexpect.spawn("rigctl -m 2")
                self.rigctl.timeout = 2.5
                self.prefix = prefix = "~/grdata"
                self.sync_freq = sync_freq = 3
                self.samp_rate = samp_rate
                self.recfile = recfile = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
                self.freq = freq = rig_freq
                self.click_freq = click_freq = 0
                self.step_up = step_up = 1
                self.dwell_up = dwell_up = 1
                self.step_down = step_down = 1
                self.dwell_down = dwell_down = 1
                self.step_size = step_size = 250
                self.ctq_step = self.step_size
                
                # calculate the number of FFT bins based on the width of the charts
                log_width = math.log(gui_scale * plot_width,2)
                if(0 != (log_width - int(log_width))):
                	log_width = log_width + 1
                num_bins = pow(2, int(log_width))
                print  "Setting number of FFT bins to:" + str(num_bins)
                
                ##################################################
                # Blocks
                ##################################################
                self.nb0 = self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
                self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Waterfall")
                self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "FFT")
                self.GridAdd(self.nb0, 2, 0, 5, 8)
                self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
                        self.nb0.GetPage(0).GetWin(),
                        baseband_freq=rig_freq,
                        dynamic_range=20,
                        ref_level=-80,
                        ref_scale=1.0,
                        sample_rate=samp_rate,
                        fft_size=num_bins,
                        fft_rate=30,
                        average=False,
                        avg_alpha=None,
                        title="Waterfall Plot",
                        win=window.hamming,
                        size=(plot_width*gui_scale,plot_height*gui_scale),
                )
                self.nb0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
                def wxgui_waterfallsink2_0_callback(x, y):
                        self.set_click_freq(x)
                
                self.wxgui_waterfallsink2_0.set_callback(wxgui_waterfallsink2_0_callback)
                self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
                        self.nb0.GetPage(1).GetWin(),
                        baseband_freq=rig_freq,
                        y_per_div=10,
                        y_divs=12,
                        ref_level=0,
                        ref_scale=2.0,
                        sample_rate=samp_rate,
                        fft_size=num_bins,
                        fft_rate=10,
                        average=True,
                        avg_alpha=None,
                        title="FFT Plot",
                        peak_hold=True,
                        win=window.flattop,
                        size=(plot_width*gui_scale,plot_height*gui_scale),
                )
                self.nb0.GetPage(1).Add(self.wxgui_fftsink2_0.win)
                self.gr_float_to_complex_0 = blocks.float_to_complex(1)
                self._freq_text_box = forms.text_box(
                        parent=self.GetWin(),
                        value=self.freq,
                        callback=self.set_text_freq,
                        label="  Frequency (Hz)",
                        converter=forms.int_converter(),
                )
                self.GridAdd(self._freq_text_box, 1, 0, 1, 1)
                self._sync_freq_chooser = forms.drop_down(
                        parent=self.GetWin(),
                        value=self.sync_freq,
                        callback=self.set_sync_freq,
                        label="",
                        choices=[1,2,3],
                        labels=["Entry","Track","Track & Click"],
                )
                self.GridAdd(self._sync_freq_chooser, 1, 1, 1, 1)
                        
                self._dwell_down_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.dwell_down,
                        callback=self.set_dwell_down,
                        label="",
                        choices=[1],
                        labels=["FFT Down"],
                )
                self.GridAdd(self._dwell_down_chooser, 1, 2, 1, 1)		
                
                self._dwell_up_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.dwell_up,
                        callback=self.set_dwell_up,
                        label="",
                        choices=[1],
                        labels=["FFT Up"],
                )
                self.GridAdd(self._dwell_up_chooser, 1, 3, 1, 1)                
                
                self._step_size_chooser = forms.drop_down(
                        parent=self.GetWin(),
                        value=self.step_size,
                        callback=self.set_step_size,
                        label="\tStep",
                        choices=[1000000,100000,10000,1000,500,250,125,100,10],
                        labels=["1MHz","100kHz","10kHz","1kHz","500Hz","250Hz","125Hz","100Hz","10Hz"],
                )
                self.GridAdd(self._step_size_chooser, 1, 4, 1, 1)

                self._step_down_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.step_down,
                        callback=self.set_step_down,
                        label="",
                        choices=[1],
                        labels=["Step Down"],
                )
                self.GridAdd(self._step_down_chooser, 1, 5, 1, 1)		
                
                self._step_up_chooser = forms.button(
                        parent=self.GetWin(),
                        value=self.step_up,
                        callback=self.set_step_up,
                        label="",
                        choices=[1],
                        labels=["Step Up"],
                )
                self.GridAdd(self._step_up_chooser, 1, 6, 1, 1)

                self.audio_source_0 = audio.source(samp_rate, iq_device, True)
                self.dc_blocker_xx_0 = filter.dc_blocker_cc(dc_correction_length, True)
                
                ##################################################
                # Connections
                ##################################################
                self.connect((self.audio_source_0, 1), (self.gr_float_to_complex_0, 0))
                self.connect((self.audio_source_0, 0), (self.gr_float_to_complex_0, 1))
                self.connect((self.gr_float_to_complex_0, 0), (self.dc_blocker_xx_0, 0))
                self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))
                self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_fftsink2_0, 0))  
                             
                self.lock = RLock()
                self.vfo_poll_skip = 0
                self.set_rig_vfo = False
                self.quit = False
                _poll_vfo_thread = Thread(target=self._poll_vfo_probe)
                _poll_vfo_thread.daemon = True
                _poll_vfo_thread.start()
Example #25
0
    def __init__(self):
        gr.top_block.__init__(self, "Spectrum Sensing")

        ##################################################
        # APP CONTROL
        ##################################################
        self.system_run = True

        ##################################################
        # Variables
        ##################################################
        self.center_freq = center_freq = 2.412e9
        self.samp_rate = samp_rate = 5e6
        self.bw = bw = 20e6
        self.time_resolution = time_resolution = 10e-6
        self.nsamples = nsamples = int(samp_rate * time_resolution)
        self.fft_size = fft_size = 256
        self.ch = 1

        ##################################################
        # Blocks
        ##################################################
        self.spec_sensing_fft_average_cc_0 = spec_sensing.fft_average_cc(10, fft_size)
        self.spec_sensing_energy_cf_0 = spec_sensing.energy_cf(nsamples)
        self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" )
        self.osmosdr_source.set_sample_rate(samp_rate)
        self.osmosdr_source.set_center_freq(center_freq, 0)
        self.osmosdr_source.set_freq_corr(0, 0)
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(1, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(0, 0)
        self.osmosdr_source.set_if_gain(0, 0)
        self.osmosdr_source.set_bb_gain(0, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(bw, 0)
          
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), True, 1)
        self.dc_blocker = filter.dc_blocker_cc(fft_size, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_null_sink_energy = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_null_sink_fft_avg = blocks.null_sink(gr.sizeof_float*fft_size)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source, 0), (self.dc_blocker, 0))
        
        self.connect((self.dc_blocker, 0), (self.spec_sensing_energy_cf_0, 0))
        self.connect((self.spec_sensing_energy_cf_0, 0), (self.blocks_null_sink_energy, 0))
        
        self.connect((self.dc_blocker, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.spec_sensing_fft_average_cc_0, 0))
        self.connect((self.spec_sensing_fft_average_cc_0, 0), (self.blocks_null_sink_fft_avg, 0))

        ##################################################
        # MESSAGE PASSING
        ##################################################
        self.message_block = messaging.message_block(self)
        self.msg_connect(self.spec_sensing_energy_cf_0, "out_port", self.message_block, "in_energy")
        self.msg_connect(self.spec_sensing_fft_average_cc_0, "out_port", self.message_block, "in_fft_average")
        self.msg_connect(self.message_block, "out_energy", self.spec_sensing_energy_cf_0, "in_port")
        self.msg_connect(self.message_block, "out_fft_average", self.spec_sensing_fft_average_cc_0, "in_port")

        ##################################################
        # FILE SINKS
        ##################################################
        ##self.energy_file_sink = blocks.file_sink(gr.sizeof_float*1, 'energy.dat', False)
        ##self.connect((self.spec_sensing_energy_cf_0, 0), (self.energy_file_sink, 0))

        ##################################################
        # FLAGS
        ##################################################
        self.energy_finish = False
        self.fft_finish = False

        ##################################################
        # DATA
        ##################################################
        # PKT DATA
        self.energy_data = [[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0]]
        self.rho = [0 for x in range(13)]
        self.delta = [0 for x in range(13)]
        self.pkt = [0 for x in range(13)]
        self.n_pkt = [0 for x in range(13)]
Example #26
0
    def __init__(self):
        gr.top_block.__init__(self, "WBFM Receiver V2- F1ATB - MARCH 2021")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2400e3
        self.Largeur_filtre = Largeur_filtre = 150000
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, Largeur_filtre / 2, 25000)
        self.decim_LP = decim_LP = 16
        self.Squelch = Squelch = -80
        self.Gain_RF = Gain_RF = 0
        self.Gain_IF = Gain_IF = 20
        self.Gain_BB = Gain_BB = 20
        self.FrRX = FrRX = 7000000
        self.F_Fine = F_Fine = 0

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 9003), 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.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(FrRX, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(Gain_RF, 0)
        self.osmosdr_source_0.set_if_gain(Gain_IF, 0)
        self.osmosdr_source_0.set_bb_gain(Gain_BB, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, decim_LP * samp_rate / 200, 5200, 1200,
                            firdes.WIN_HAMMING, 6.76))
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
            sample_rate=samp_rate / 200,
            fft_size=2048,
            ref_scale=0.00001,
            frame_rate=samp_rate / 200 / 2048,
            avg_alpha=1.0,
            average=False,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            15, (xlate_filter_taps), F_Fine, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(
            0, decim_LP)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short * 2048,
                                                 '127.0.0.1', 9002, 4096, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 '127.0.0.1', 9001, 1000, True)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex,
                                                       int(2048 * decim_LP),
                                                       409600, 0)
        self.blocks_float_to_short_1 = blocks.float_to_short(2048, 100)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16000)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=samp_rate / 15,
            audio_decimation=16,
        )
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(Squelch, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_wfm_rcv_0, 0))
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_float_to_short_1, 0),
                     (self.blocks_udp_sink_1, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0),
                     (self.logpwrfft_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.logpwrfft_x_0, 0),
                     (self.blocks_float_to_short_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.fractional_resampler_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
Example #27
0
    def __init__(self):
        gr.top_block.__init__(self, "Wideband Excite")

        ##################################################
        # Variables
        ##################################################
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.tx_freq = tx_freq = 1.3e9
        self.samp_rate = samp_rate = 10e6
        self.rx_freq = rx_freq = 2.6e9
        self.fft_size = fft_size = 2**12

        ##################################################
        # Blocks
        ##################################################
        self.probe_peak = blocks.probe_signal_vf(fft_size)

        def _variable_function_probe_0_probe():
            while True:
                val = self.probe_peak.level()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _variable_function_probe_0_thread = threading.Thread(
            target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.peak_hold = peak_hold.blk()
        self.osmosdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + 'bladerf=0')
        self.osmosdr_source_0_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0_0.set_center_freq(rx_freq, 0)
        self.osmosdr_source_0_0.set_freq_corr(0, 0)
        self.osmosdr_source_0_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0_0.set_gain_mode(False, 0)
        self.osmosdr_source_0_0.set_gain(10, 0)
        self.osmosdr_source_0_0.set_if_gain(20, 0)
        self.osmosdr_source_0_0.set_bb_gain(20, 0)
        self.osmosdr_source_0_0.set_antenna('', 0)
        self.osmosdr_source_0_0.set_bandwidth(0, 0)

        self.osmosdr_sink_0_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                             'bladerf=0')
        self.osmosdr_sink_0_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0_0.set_center_freq(tx_freq, 0)
        self.osmosdr_sink_0_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0_0.set_gain(10, 0)
        self.osmosdr_sink_0_0.set_if_gain(20, 0)
        self.osmosdr_sink_0_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0_0.set_antenna('', 0)
        self.osmosdr_sink_0_0.set_bandwidth(0, 0)

        self.fft_vxx_0 = fft.fft_vcc(fft_size, True,
                                     (window.blackmanharris(fft_size)), True,
                                     2)
        self.divide_by_n = divide_by_n.blk(divisor=4096)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(512, True)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 2 * pi * 5e6, .3)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_size, -30)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SAW_WAVE, .5, 1, -.5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.divide_by_n, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.peak_hold, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.osmosdr_sink_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.divide_by_n, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.peak_hold, 0), (self.probe_peak, 0))
Example #28
0
    def __init__(self):
        gr.top_block.__init__(self, "SSB Receiver V2- F1ATB - MARCH 2021")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2400e3
        self.Largeur_filtre = Largeur_filtre = 3800
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(
            1, samp_rate, Largeur_filtre / 2, 500)
        self.decim_LP = decim_LP = 16
        self.LSB_USB = LSB_USB = 0
        self.Gain_RF = Gain_RF = 0
        self.Gain_IF = Gain_IF = 20
        self.Gain_BB = Gain_BB = 20
        self.FrRX = FrRX = 7000000
        self.F_Fine = F_Fine = 0

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 9003), 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.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(FrRX, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(Gain_RF, 0)
        self.osmosdr_source_0.set_if_gain(Gain_IF, 0)
        self.osmosdr_source_0.set_bb_gain(Gain_BB, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, decim_LP * samp_rate / 200, 5200, 1200,
                            firdes.WIN_HAMMING, 6.76))
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
            sample_rate=samp_rate / 200,
            fft_size=2048,
            ref_scale=0.00001,
            frame_rate=samp_rate / 200 / 2048,
            avg_alpha=1.0,
            average=False,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            240, (xlate_filter_taps), F_Fine - Largeur_filtre / 2 +
            LSB_USB * Largeur_filtre - 100 + LSB_USB * 200, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(
            0, decim_LP)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_short * 2048,
                                                 '127.0.0.1', 9002, 4096, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 '127.0.0.1', 9001, 1000, True)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (1 - 2 * LSB_USB, ))
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex,
                                                       int(2048 * decim_LP),
                                                       409600, 0)
        self.blocks_float_to_short_1 = blocks.float_to_short(2048, 100)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16000)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate / 240, analog.GR_SIN_WAVE, Largeur_filtre / 2 + 100, 1,
            0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate / 240, analog.GR_COS_WAVE, Largeur_filtre / 2 + 100, 1,
            0)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(100)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_float_to_short_1, 0),
                     (self.blocks_udp_sink_1, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0),
                     (self.logpwrfft_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.logpwrfft_x_0, 0),
                     (self.blocks_float_to_short_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.fractional_resampler_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
Example #29
0
    def __init__(self, options, filename):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Blocks
        ##################################################
        self.dc_blocker_xx_0_0 = filter.dc_blocker_cc(32, True)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)

        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 20000000, True)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1,
                                                 options.skip)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_magphase_to_complex_0 = blocks.magphase_to_complex(1)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1,
                                         options.maxsamp)
        self.blocks_file_source_0_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, filename[0], True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, filename[1], True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   filename[2], False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_magphase_0 = blocks.complex_to_magphase(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        #self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1)

        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.01, 0.04, 0)

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

        self.connect((self.blocks_file_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_file_source_0_0, 0),
                     (self.dc_blocker_xx_0_0, 0))

        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.dc_blocker_xx_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))

        self.connect((self.blocks_throttle_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_0, 0))

        self.connect((self.blocks_head_0, 0),
                     (self.blocks_complex_to_magphase_0, 0))

        # tap for power analysis
        self.connect((self.blocks_head_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_threshold_ff_0, 0))

        self.connect((self.blocks_complex_to_magphase_0, 1),
                     (self.blocks_magphase_to_complex_0, 1))
        self.connect((self.blocks_complex_to_magphase_0, 0),
                     (self.blocks_null_sink_0, 0))

        #self.connect((self.analog_const_source_x_0, 0), (self.blocks_magphase_to_complex_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_magphase_to_complex_0, 0))

        # in case you want to just add
        #self.connect((self.blocks_complex_to_magphase_0, 0), (self.blocks_magphase_to_complex_0, 0))

        self.connect((self.blocks_magphase_to_complex_0, 0),
                     (self.blocks_file_sink_0, 0))
Example #30
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")

        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.sym_rate = sym_rate = 4800
        self.samp_rate = samp_rate = 48000
        self.decimation = decimation = 1
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(1.0, samp_rate/decimation,sym_rate, 0.35, 35)
        self.psk_obj = psk_obj = digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024, #size
            4800, #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(-2, 2)

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

        self.qtgui_time_sink_x_0.enable_tags(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(True)
        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)


        labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10']
        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]
        styles = [1, 1, 1, 1, 1,
            1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
            -1, -1, -1, -1, -1]


        for i in range(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.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024, #size
            "", #name
            1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-3, 3)
        self.qtgui_const_sink_x_0.set_x_axis(-3, 3)
        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(True)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)


        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 range(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_grid_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(
                1,
                samp_rate,
                2.5e3,
                100,
                firdes.WIN_HAMMING,
                6.76))
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(psk_obj)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc((samp_rate/decimation/sym_rate)*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*4800, '127.0.0.1', 10000, 1472, True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_char*1, 4800)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, 'D:\\Nextcloud\\Programming\\Orbcomm\\symbolsfm10.bin', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.audio_source_0 = audio.source(samp_rate, 'Output 0 (VB-Audio Virtual Cable)', True)
        self.analog_agc_xx_0 = analog.agc_cc(10e-3, 1.0, 0.5)
        self.analog_agc_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "IEEE 802.15.4 to Wireshark")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("IEEE 802.15.4 to Wireshark")
        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", "IEEE_802_15_4_Wireshark")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.ComFreqStruct = ComFreqStruct = struct({
            'Ch11': 2.405,
            'Ch12': 2.410,
            'Ch13': 2.415,
            'Ch14': 2.420,
            'Ch15': 2.425,
            'Ch16': 2.430,
            'Ch17': 2.435,
            'Ch18': 2.440,
            'Ch19': 2.445,
            'Ch20': 2.450,
            'Ch21': 2.455,
            'Ch22': 2.460,
            'Ch23': 2.465,
            'Ch24': 2.470,
            'Ch25': 2.475,
            'Ch26': 2.480,
        })
        self.CH = CH = "Ch24"
        self.freq = freq = getattr(ComFreqStruct, CH) * 1000000000
        self.samp_rate = samp_rate = 4000000
        self.rx_gain = rx_gain = 25
        self.if_gain = if_gain = 20
        self.comm_freq_label = comm_freq_label = freq
        self.bb_gain = bb_gain = 20

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 50, 1, 25, 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, 96, 0, 1, 1)
        for r in range(96, 97):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._if_gain_range = Range(0, 50, 1, 20, 200)
        self._if_gain_win = RangeWidget(self._if_gain_range, self.set_if_gain,
                                        'if_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._if_gain_win, 97, 0, 1, 1)
        for r in range(97, 98):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._bb_gain_range = Range(0, 50, 1, 20, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain,
                                        'BB', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 98, 0, 1, 1)
        for r in range(98, 99):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(3, -1, 'wpan')
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate / 2,  #bw
            "raw",  #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 = ['Raw', '', '', '', '', '', '', '', '', '']
        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, 7,
                                       0, 1, 4)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Rx",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-0.5, 0.5)

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

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  qtgui.TRIG_SLOPE_POS, 0.2, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(True)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_axis_labels(True)
        self.qtgui_time_sink_x_1.enable_control_panel(True)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = [
            'Raw DC Blocked R', 'Raw DC Blocked I', 'dqpsk R', 'dqpsk I',
            'Sub i', 'Sub q', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "red", "yellow", "blue", "cyan", "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_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 5, 0, 1,
                                       4)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_1_1 = qtgui.const_sink_c(
            1024,  #size
            "Rx",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1_1.set_update_time(0.1)
        self.qtgui_const_sink_x_1_1.set_y_axis(-0.4, 0.4)
        self.qtgui_const_sink_x_1_1.set_x_axis(-0.4, 0.4)
        self.qtgui_const_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                     qtgui.TRIG_SLOPE_POS, 0.4,
                                                     0, "")
        self.qtgui_const_sink_x_1_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1_1.enable_grid(False)
        self.qtgui_const_sink_x_1_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_1_1.disable_legend()

        labels = [
            'Rx raw', 'DQPSK Soft', 'MPSK', 'Unbuf', '', '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "Dark Blue", "red", "yellow", "cyan", "red", "red", "red", "red",
            "red", "red"
        ]
        styles = [1, 0, 4, 5, 0, 0, 0, 0, 0, 0]
        markers = [9, 7, 6, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_1_1_win, 1, 0,
                                       1, 4)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'soapy=0,driver=lime')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(rx_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('LNAH', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2, 0.000225, 0.5, 0.03, 0.0002)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self._comm_freq_label_tool_bar = Qt.QToolBar(self)

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

        self._comm_freq_label_tool_bar.addWidget(Qt.QLabel('Com Freq:' + ": "))
        self._comm_freq_label_label = Qt.QLabel(
            str(self._comm_freq_label_formatter(self.comm_freq_label)))
        self._comm_freq_label_tool_bar.addWidget(self._comm_freq_label_label)
        self.top_grid_layout.addWidget(self._comm_freq_label_tool_bar, 99, 1,
                                       1, 1)
        for r in range(99, 100):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", '127.0.0.1',
                                                     '52006', 10000, False)
        self.blocks_pdu_set_0 = blocks.pdu_set(pmt.to_pmt("nomfreq"),
                                               pmt.to_pmt(freq))
        self.blocks_message_debug_1_0 = blocks.message_debug()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self._CH_options = (
            "Ch24",
            "Ch25",
            "Ch26",
            "Ch11",
            "Ch12",
        )
        self._CH_labels = (
            '24',
            '25',
            '26',
            '11',
            '12',
        )
        self._CH_group_box = Qt.QGroupBox('802.15.4 Channel')
        self._CH_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._CH_button_group = variable_chooser_button_group()
        self._CH_group_box.setLayout(self._CH_box)
        for i, label in enumerate(self._CH_labels):
            radio_button = Qt.QRadioButton(label)
            self._CH_box.addWidget(radio_button)
            self._CH_button_group.addButton(radio_button, i)
        self._CH_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._CH_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._CH_options.index(i)))
        self._CH_callback(self.CH)
        self._CH_button_group.buttonClicked[int].connect(
            lambda i: self.set_CH(self._CH_options[i]))
        self.top_grid_layout.addWidget(self._CH_group_box, 99, 0, 1, 1)
        for r in range(99, 100):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_pdu_set_0, 'pdus'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.epy_block_0, 'out'),
                         (self.blocks_pdu_set_0, 'pdus'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.blocks_message_debug_1_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.epy_block_0, 'in'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.qtgui_const_sink_x_1_1, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.ieee802_15_4_packet_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
Example #32
0
    def __init__(self, num_bins=256, num_integrations=100000):
        gr.top_block.__init__(self, "radio_process")

        ##################################################
        # Parameters
        ##################################################
        self.num_bins = num_bins
        self.num_integrations = num_integrations

        ##################################################
        # Variables
        ##################################################
        self.sinc_sample_locations = sinc_sample_locations = np.arange(
            -np.pi * 4 / 2.0, np.pi * 4 / 2.0, np.pi / num_bins)
        self.sinc_samples = sinc_samples = np.sinc(sinc_sample_locations /
                                                   np.pi)
        self.vslr = vslr = np.nan
        self.tsys = tsys = 171
        self.tcal = tcal = 290
        self.soutrack = soutrack = "at_stow"
        self.samp_rate = samp_rate = 2400000
        self.motor_el = motor_el = np.nan
        self.motor_az = motor_az = np.nan
        self.is_running = is_running = False
        self.glon = glon = np.nan
        self.glat = glat = np.nan
        self.freq = freq = 1420000000
        self.fft_window = fft_window = window.blackmanharris(num_bins)
        self.custom_window = custom_window = sinc_samples * np.hamming(
            4 * num_bins)
        self.cal_values = cal_values = np.repeat(np.nan, num_bins)
        self.cal_pwr = cal_pwr = 1
        self.beam_switch = beam_switch = 0

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pub_sink_2_0 = zeromq.pub_sink(gr.sizeof_float, num_bins,
                                                   'tcp://127.0.0.1:5561', 100,
                                                   False, -1)
        self.zeromq_pub_sink_2 = zeromq.pub_sink(gr.sizeof_float, num_bins,
                                                 'tcp://127.0.0.1:5560', 100,
                                                 True, -1)
        self.zeromq_pub_sink_1_0 = zeromq.pub_sink(gr.sizeof_float, num_bins,
                                                   'tcp://127.0.0.1:5562', 100,
                                                   True, -1)
        self.zeromq_pub_sink_1 = zeromq.pub_sink(gr.sizeof_float, num_bins,
                                                 'tcp://127.0.0.1:5563', 100,
                                                 False, -1)
        self.zeromq_pub_sink_0_0 = zeromq.pub_sink(gr.sizeof_gr_complex, 1,
                                                   'tcp://127.0.0.1:5559', 100,
                                                   False, -1)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_gr_complex, 1,
                                                 'tcp://127.0.0.1:5558', 100,
                                                 True, -1)
        self.xmlrpc_server_0 = xmlrpc.server.SimpleXMLRPCServer(
            ('localhost', 5557), 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.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "soapy=0")
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_gain(49.6, 0)
        self.osmosdr_source_0.set_if_gain(0, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
        self.fft_vxx_0 = fft.fft_vcc(num_bins, True, fft_window, True, 3)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(
            num_bins * num_integrations, False)
        self.blocks_tags_strobe_0_0 = blocks.tags_strobe(
            gr.sizeof_gr_complex * 1,
            pmt.to_pmt({
                "num_bins": num_bins,
                "samp_rate": samp_rate,
                "num_integrations": num_integrations,
                "motor_az": motor_az,
                "motor_el": motor_el,
                "freq": freq,
                "tsys": tsys,
                "tcal": tcal,
                "cal_pwr": cal_pwr,
                "vslr": vslr,
                "glat": glat,
                "glon": glon,
                "soutrack": soutrack,
                "bsw": beam_switch
            }), min(num_bins * 64, num_bins * num_integrations),
            pmt.intern("metadata"))
        self.blocks_tags_strobe_0 = blocks.tags_strobe(
            gr.sizeof_gr_complex * 1, pmt.to_pmt(float(freq)),
            min(num_bins * 64, num_bins * num_integrations),
            pmt.intern("rx_freq"))
        self.blocks_stream_to_vector_0_2 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, num_bins)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, num_bins)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, num_bins)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, num_bins)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1,
                                                 num_bins * num_integrations)
        self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1, 0,
                                                 0)
        self.blocks_selector_0.set_enabled(True)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_ff(
            1.0 / float(num_integrations), num_bins)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff([
            (tsys + tcal) / (value * cal_pwr) for value in cal_values
        ])
        self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vcc(
            custom_window[0:num_bins])
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc(
            custom_window[num_bins:2 * num_bins])
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            custom_window[2 * num_bins:3 * num_bins])
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            custom_window[-num_bins:])
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.to_pmt(is_running), 100)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(
            num_integrations, num_bins)
        self.blocks_delay_0_1 = blocks.delay(gr.sizeof_gr_complex * 1,
                                             num_bins)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                             num_bins * 2)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           num_bins * 3)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            num_bins)
        self.blocks_add_xx_0_0 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(num_bins)
        self.add_clock_tags = add_clock_tags.clk(nsamps=num_bins * 8)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.blocks_selector_0, 'en'))
        self.connect((self.add_clock_tags, 0), (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_selector_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_stream_to_vector_0_2, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_delay_0_1, 0),
                     (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_integrate_xx_0, 0),
                     (self.blocks_multiply_const_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.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.zeromq_pub_sink_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.zeromq_pub_sink_1_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.zeromq_pub_sink_2, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.zeromq_pub_sink_2_0, 0))
        self.connect((self.blocks_selector_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_selector_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_selector_0, 0),
                     (self.zeromq_pub_sink_0_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_delay_0_1, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_2, 0),
                     (self.blocks_multiply_const_vxx_0_0_0_0, 0))
        self.connect((self.blocks_tags_strobe_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_tags_strobe_0_0, 0),
                     (self.blocks_add_xx_0_0, 2))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_skiphead_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.add_clock_tags, 0))
    def __init__(self, path="/captures/radio_jove", signal_type='RADIO-JOVE'):
        gr.top_block.__init__(self, "Radio Jove RTL-SDR Receiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Radio Jove RTL-SDR Receiver")
        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",
                                     "radio_jove_dual_rtlsdr_sigmf")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.path = path
        self.signal_type = signal_type

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%SZ")
        self.fn = fn = "{:s}_{:s}".format(signal_type.upper(), ts_str)
        self.samp_rate = samp_rate = 2000000
        self.rx_freq = rx_freq = 20.1e6
        self.keep_n = keep_n = 20000
        self.fp = fp = "{:s}/{:s}".format(path, fn)
        self.decim = decim = 1
        self.avg_len = avg_len = 20000.0

        ##################################################
        # Blocks
        ##################################################
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('Freq [Hz]' + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 8, 0, 1, 2)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._keep_n_tool_bar = Qt.QToolBar(self)
        self._keep_n_tool_bar.addWidget(Qt.QLabel('1inN' + ": "))
        self._keep_n_line_edit = Qt.QLineEdit(str(self.keep_n))
        self._keep_n_tool_bar.addWidget(self._keep_n_line_edit)
        self._keep_n_line_edit.returnPressed.connect(lambda: self.set_keep_n(
            int(str(self._keep_n_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._keep_n_tool_bar, 5, 5, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._avg_len_tool_bar = Qt.QToolBar(self)
        self._avg_len_tool_bar.addWidget(Qt.QLabel("avg_len" + ": "))
        self._avg_len_line_edit = Qt.QLineEdit(str(self.avg_len))
        self._avg_len_tool_bar.addWidget(self._avg_len_line_edit)
        self._avg_len_line_edit.returnPressed.connect(lambda: self.set_avg_len(
            eng_notation.str_to_num(
                str(self._avg_len_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._avg_len_tool_bar, 5, 4, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        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, 4,
                                       0, 4, 4)
        for r in range(4, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1000,  #size
            samp_rate / keep_n,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.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(True)
        self.qtgui_time_sink_x_0.enable_grid(True)
        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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0, 4, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        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.010)
        self.qtgui_number_sink_0.set_title('')

        labels = ["RSSI", '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("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, -140)
            self.qtgui_number_sink_0.set_max(i, -40)
            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_grid_layout.addWidget(self._qtgui_number_sink_0_win, 4, 4, 1,
                                       4)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4,
                                       4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "rtl=0,direct_samp=2")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(rx_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c()
        self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(256, True)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff(
            (1 / avg_len, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int(avg_len), 1 / avg_len, 4000, 1)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, keep_n)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.fosphor_glfw_sink_c_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
Example #34
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 = 4000000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=12,
            decimation=5,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            102500000,  #fc
            20000,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 5)
        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(True)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'hackrf=0')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(102500000, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            20,
            firdes.low_pass(1, samp_rate, 75000, 25000, firdes.WIN_HAMMING,
                            6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((100, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1,
            'C:\\Users\\patel\\Desktop\\CS 491\\print_test2.dat', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=480000,
            audio_decimation=10,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_deinterleave_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_wfm_rcv_0, 0))
Example #35
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.tx_freq = tx_freq = 1.3e9
        self.samp_rate = samp_rate = 10e6
        self.rx_freq = rx_freq = 2.6e9
        self.fft_size = fft_size = 2**12

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            fft_size,
            0,
            1.0,
            "x-Axis",
            "y-Axis",
            "",
            1  # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(-130, -40)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(False)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

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

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(
            self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win)
        self.peak_hold = peak_hold.blk()
        self.osmosdr_source_0_0 = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + 'bladerf=0')
        self.osmosdr_source_0_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0_0.set_center_freq(rx_freq, 0)
        self.osmosdr_source_0_0.set_freq_corr(0, 0)
        self.osmosdr_source_0_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0_0.set_gain_mode(False, 0)
        self.osmosdr_source_0_0.set_gain(10, 0)
        self.osmosdr_source_0_0.set_if_gain(20, 0)
        self.osmosdr_source_0_0.set_bb_gain(20, 0)
        self.osmosdr_source_0_0.set_antenna('', 0)
        self.osmosdr_source_0_0.set_bandwidth(0, 0)

        self.osmosdr_sink_0_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                             'bladerf=0')
        self.osmosdr_sink_0_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0_0.set_center_freq(tx_freq, 0)
        self.osmosdr_sink_0_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0_0.set_gain(10, 0)
        self.osmosdr_sink_0_0.set_if_gain(20, 0)
        self.osmosdr_sink_0_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0_0.set_antenna('', 0)
        self.osmosdr_sink_0_0.set_bandwidth(0, 0)

        self.fft_vxx_0 = fft.fft_vcc(fft_size, True,
                                     (window.blackmanharris(fft_size)), True,
                                     2)
        self.divide_by_n = divide_by_n.blk(divisor=4096)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(512, True)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 2 * pi * 5e6, .3)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, fft_size, -30)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SAW_WAVE, .1, 1, -.5)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.divide_by_n, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.peak_hold, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.osmosdr_sink_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.divide_by_n, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.osmosdr_source_0_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.peak_hold, 0), (self.qtgui_vector_sink_f_0, 0))
Example #36
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e5
        self.freq = freq = 500e06

        ##################################################
        # 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='freq',
        	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=400e06,
        	maximum=600e06,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=-100,
        	maxval=100,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.fft_vxx_0_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)), True, 1)
        self.facsink_0 = facsink.fac_sink_c(
        	self.GetWin(),
        	title="Fast AutoCorrelation",
        	sample_rate=samp_rate,
        	baseband_freq=freq,
                y_per_div=10,
        	ref_level=50,
        	fac_size=512,
                fac_rate=facsink.default_fac_rate,
                average=False,
        	avg_alpha=0,
        	peak_hold=False,
        )
        self.Add(self.facsink_0.win)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 1024)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "/home/nitr/Sagnik/gnuradio_data/cyclo_2.dat", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_real_1_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.baz_delay_0_0 = baz.delay(gr.sizeof_gr_complex*1, 1)
        self.baz_delay_0 = baz.delay(gr.sizeof_gr_complex*1, -1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.baz_delay_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.baz_delay_0_0, 0), (self.blocks_stream_to_vector_0_0, 0))    
        self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_1_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.blocks_conjugate_cc_0, 0), (self.baz_delay_0_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_complex_to_real_1, 0))    
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_complex_to_real_1_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.baz_delay_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_conjugate_cc_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.facsink_0, 0))    
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))    
Example #37
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_numbersink2_0 = numbersink2.number_sink_c(
            self.GetWin(),
            unit="Units",
            minval=-100,
            maxval=100,
            factor=1.0,
            decimal_places=10,
            ref_level=0,
            sample_rate=samp_rate,
            number_rate=15,
            average=False,
            avg_alpha=None,
            label="Number Plot",
            peak_hold=False,
            show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=400e6,
            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_0.win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               "")
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(400e6, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(2, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.fft_vxx_0_1 = fft.fft_vcc(1024, True,
                                       (window.blackmanharris(1024)), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(1024, False,
                                       (window.blackmanharris(1024)), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(1024, True, (window.blackmanharris(1024)),
                                     True, 1)
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(8192, True)
        self.blocks_vector_to_stream_0_1 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, 1024)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_float * 1,
            "/home/shaggy/Dropbox/Sagnik_project/grc_files/spectrum_data/snr=-24.962/blind_cyclo_alpha_0.dat",
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 0)
        self.blocks_conjugate_cc_0_0 = blocks.conjugate_cc()
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_conjugate_cc_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0),
                     (self.fft_vxx_0_1, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_conjugate_cc_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_vector_to_stream_0_1, 0),
                     (self.wxgui_numbersink2_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.fft_vxx_0_1, 0),
                     (self.blocks_vector_to_stream_0_1, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0_0, 0))
Example #38
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="[FG]MRS Receiver")
        _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 = 1e6
        self.channel_width = channel_width = 25e3
        self.rf_freq_mhz = rf_freq_mhz = 462.5625
        self.decimation = decimation = int(samp_rate/channel_width)
        self.squelch = squelch = -20
        self.spec_size = spec_size = 480,256
        self.rf_freq = rf_freq = rf_freq_mhz*1.0e6
        self.decimated_rate = decimated_rate = samp_rate/decimation
        self.center_freq = center_freq = (int(rf_freq_mhz)+0.5)*1e6
        self.cctss_freq = cctss_freq = 0
        self.audio_rate = audio_rate = int(11025)

        ##################################################
        # Blocks
        ##################################################
        _squelch_sizer = wx.BoxSizer(wx.VERTICAL)
        self._squelch_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	label="Squelch (dBm)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._squelch_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_squelch_sizer,
        	value=self.squelch,
        	callback=self.set_squelch,
        	minimum=-50,
        	maximum=0,
        	num_steps=50,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_squelch_sizer, 3, 3, 1, 2)
        self._cctss_freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.cctss_freq,
        	callback=self.set_cctss_freq,
        	label="Privacy Code",
        	choices=[0,67.0,71.9,74.4,77.0,79.7,82.5,85.4,88.5,91.5,94.8,97.4,100.0,103.5,107.2,110.9,114.8,118.8,123.0,127.3,131.8,136.5,141.3,146.2,151.4,156.7,162.2,167.9,173.8,179.9,186.2,192.8,203.5,210.7,218.1,225.7,233.7,241.8,250.3],
        	labels=['0 (Monitor)',1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],
        )
        self.GridAdd(self._cctss_freq_chooser, 3, 2, 1, 1)
        self.wxgui_waterfallsink2_1_0 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Raw Audio Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_1_0.win, 2, 4, 1, 3)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_f(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=audio_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Squelched Audio Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_1.win, 2, 1, 1, 3)
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=center_freq,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="RF Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_0_0.win, 1, 1, 1, 3)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	dynamic_range=40,
        	ref_level=-25,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Baseband Spectrum",
        	size=(spec_size),
        )
        self.GridAdd(self.wxgui_waterfallsink2_0.win, 1, 4, 1, 3)
        self._rf_freq_mhz_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.rf_freq_mhz,
        	callback=self.set_rf_freq_mhz,
        	label="Channel",
        	choices=[462.5625, 462.5875, 462.6125, 462.6375, 462.6625, 462.6875, 462.7125, 467.5625, 467.5875, 467.6125, 467.6375, 467.6625, 467.6875, 467.7125, 462.550, 462.575, 462.600, 462.625,462.650,462.675,462.700, 462.725],
        	labels=['FRS1 / GMRS 9',2,3,4,5,6,'FRS7 / GMRS15 ','FRS8',9,10,11,12,13,'FRS14','GMRS1',2,3,4,5,6,7,'GMRS8'],
        )
        self.GridAdd(self._rf_freq_mhz_chooser, 3, 1, 1, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(audio_rate),
                decimation=int(decimated_rate),
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, decimated_rate*0.8, decimated_rate*0.2, firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(32, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.audio_sink_0 = audio.sink(audio_rate, "", True)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, rf_freq, 1, 0)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(squelch, 0.0001, 1, False)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
        )
        self.analog_ctcss_squelch_ff_0 = analog.ctcss_squelch_ff(audio_rate, cctss_freq, 0.01, 0, 1, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.wxgui_waterfallsink2_1_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.analog_ctcss_squelch_ff_0, 0))
        self.connect((self.analog_ctcss_squelch_ff_0, 0), (self.analog_pwr_squelch_xx_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.wxgui_waterfallsink2_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_xx_0, 1))
    def __init__(self, samp_rate=2e6):

        grc_wxgui.top_block_gui.__init__(
            self, title="Amplitude calibration tool for USRP, v 0.2")

        ########################################################
        # TODO: See if there's a sensible way to package an icon
        #	   with this program, rather than rely on some
        #	   particular Gnu Radio user's installation.
        #
        # _icon_path = "/home/dave/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        # self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))
        ########################################################

        ##################################################
        # Parameters
        #
        # TODO: Add enough parameters, and the right ones,
        #	   that the program will come up with sliders
        #	set conveniently for the user.
        #	When step-sweep support is implemented, we
        #	want to be able to run even w/o the GUI.
        ##################################################
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.usrp_gain_slider = usrp_gain_slider = 20
        self.usrp_freq_offset_slider = usrp_freq_offset_slider = -100000
        self.input_signal_power = input_signal_power = -50
        self.input_freq_slider = input_freq_slider = 1e9
        self.cal_file = None

        ##################################################
        # Blocks
        ##################################################

        self._input_rowhdr_text_box = wx.StaticText(
            self.GetWin(), label='\nReference Signal:\n')
        font = self._input_rowhdr_text_box.GetFont()
        font.SetWeight(wx.FONTWEIGHT_BOLD)
        self._input_rowhdr_text_box.SetFont(font)
        self.GridAdd(self._input_rowhdr_text_box, 1, 1, 1, 1)

        _input_freq_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._input_freq_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_input_freq_slider_sizer,
            value=self.input_freq_slider,
            callback=self.set_input_freq_slider,
            label='RF input frequency (Hz)',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._input_freq_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_input_freq_slider_sizer,
            value=self.input_freq_slider,
            callback=self.set_input_freq_slider,
            minimum=10e6,
            maximum=6000e6,
            num_steps=20,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_input_freq_slider_sizer, 1, 2, 1, 3)

        _input_signal_power_sizer = wx.BoxSizer(wx.VERTICAL)
        self._input_signal_power_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_input_signal_power_sizer,
            value=self.input_signal_power,
            callback=self.set_input_signal_power,
            label='Input signal power (dBm)',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._input_signal_power_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_input_signal_power_sizer,
            value=self.input_signal_power,
            callback=self.set_input_signal_power,
            minimum=-70,
            maximum=-20,
            num_steps=50,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_input_signal_power_sizer, 1, 5, 1, 2)

        self._row_spacer_1 = wx.StaticText(self.GetWin(), label="\n")
        self.GridAdd(self._row_spacer_1, 2, 1, 1, 6)

        self._sdr_rowhdr_text_box = wx.StaticText(self.GetWin(),
                                                  label='HackRF:')
        font = self._sdr_rowhdr_text_box.GetFont()
        font.SetWeight(wx.FONTWEIGHT_BOLD)
        self._sdr_rowhdr_text_box.SetFont(font)
        self.GridAdd(self._sdr_rowhdr_text_box, 3, 1, 1, 1)

        _usrp_freq_offset_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._usrp_freq_offset_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_usrp_freq_offset_slider_sizer,
            value=self.usrp_freq_offset_slider,
            callback=self.set_usrp_freq_offset_slider,
            label='Freq offset',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._usrp_freq_offset_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_usrp_freq_offset_slider_sizer,
            value=self.usrp_freq_offset_slider,
            callback=self.set_usrp_freq_offset_slider,
            minimum=-200000,
            maximum=200000,
            num_steps=5,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.GridAdd(_usrp_freq_offset_slider_sizer, 3, 2, 1, 3)

        _usrp_gain_slider_sizer = wx.BoxSizer(wx.VERTICAL)
        self._usrp_gain_slider_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_usrp_gain_slider_sizer,
            value=self.usrp_gain_slider,
            callback=self.set_usrp_gain_slider,
            label='Gain (dB) !!!8dB step!!!',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._usrp_gain_slider_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_usrp_gain_slider_sizer,
            value=self.usrp_gain_slider,
            callback=self.set_usrp_gain_slider,
            minimum=0,
            maximum=38,
            num_steps=38,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )

        self.GridAdd(_usrp_gain_slider_sizer, 3, 5, 1, 2)

        self._row_spacer_2 = wx.StaticText(self.GetWin(), label="")
        self.GridAdd(self._row_spacer_2, 4, 1, 1, 6)

        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='dBFS',
            minval=-100,
            maxval=10,
            factor=1.0,
            decimal_places=0,
            ref_level=0,
            sample_rate=samp_rate / 10,
            number_rate=10,
            average=False,
            avg_alpha=None,
            label='Output power (digital)',
            peak_hold=False,
            show_gauge=True,
        )
        self.GridAdd(self.wxgui_numbersink2_0_0.win, 5, 1, 1, 2)

        self.wxgui_numbersink2_0_0_1 = numbersink2.number_sink_f(
            self.GetWin(),
            unit='dB',
            minval=-20,
            maxval=80,
            factor=1.0,
            decimal_places=0,
            ref_level=0,
            sample_rate=samp_rate / 10,
            number_rate=10,
            average=False,
            avg_alpha=None,
            label='Power conversion value\n(output dbFS -> input dBm + gain)',
            peak_hold=False,
            show_gauge=True,
        )
        self.GridAdd(self.wxgui_numbersink2_0_0_1.win, 5, 4, 1, 3)

        self.data_capture_button = forms.single_button(
            parent=self.GetWin(),
            label="Capture this data point",
            callback=self.checkbox_event,
            style=wx.BU_EXACTFIT,
        )
        font = self.data_capture_button._button.GetFont()
        font.SetWeight(wx.FONTWEIGHT_BOLD)
        self.data_capture_button._button.SetFont(font)
        self.GridAdd(self.data_capture_button, 6, 4, 1, 1)

        self._wrapup_text_box_1 = wx.StaticText(
            self.GetWin(),
            label='\n   USRP LO freq:\n',
        )
        font = self._wrapup_text_box_1.GetFont()
        font.SetWeight(wx.FONTWEIGHT_BOLD)
        self._wrapup_text_box_1.SetFont(font)
        self.GridAdd(self._wrapup_text_box_1, 6, 5, 1, 1)

        self._wrapup_text_box_1.SetLabel("\n   USRP LO freq: {0:.0f}\n".format(
            self.input_freq_slider + self.usrp_freq_offset_slider))

        self._wrapup_text_box_2 = wx.StaticText(
            self.GetWin(),
            label='\n\n',
        )
        self.GridAdd(self._wrapup_text_box_2, 6, 6, 1, 1)

        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(
            input_freq_slider + usrp_freq_offset_slider, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(usrp_gain_slider, 0)
        self.osmosdr_source_0.set_bb_gain(0, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)

        self.u = self.osmosdr_source_0

        self.u_mboard_serial = ""
        self.u_dboard_serial = ""
        self.u_dboard_id = ""
        self.u_dboard_id = ""

        self._sdr_rowhdr_text_box.SetLabel(
            "USRP serial # {0:s}  \n{1:s} serial # {2:s}  ".format(
                self.u_mboard_serial, self.u_dboard_id, self.u_dboard_serial))

        self.single_pole_iir_filter_xx_1_0 = filter.single_pole_iir_filter_ff(
            1.0 / ((0.1) * samp_rate), 1)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, samp_rate / 5, samp_rate / 10,
                            firdes.WIN_HAMMING, 6.76))
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1000, True)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1,
                                                   '', "")
        self.blocks_tag_debug_0.set_display(True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 10)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(
            gr.sizeof_float * 1, 10)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0,
            input_signal_power + usrp_gain_slider)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.blocks_keep_one_in_n_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.single_pole_iir_filter_xx_1_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_keep_one_in_n_0, 0),
                     (self.wxgui_numbersink2_0_0, 0))
        self.connect((self.blocks_keep_one_in_n_0_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.wxgui_numbersink2_0_0_1, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_1_0, 0),
                     (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.u, 0), (self.blocks_tag_debug_0, 0))
        self.connect((self.u, 0), (self.dc_blocker_xx_0, 0))
Example #40
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Transceiver")

        self._lock = threading.RLock()

        ##################################################
        # Variables
        ##################################################
        self.sent_pkt = 0
        self.rcv_pkt = 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_length_tag_key = packet_length_tag_key = "packet_len"
        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 = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.waterfall_min = waterfall_min = -80
        self.waterfall_max = waterfall_max = -20
        self.tx_gain = tx_gain = 0.03
        self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j]
        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 = 20e6
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1)
        self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols)
        self.center_freq = center_freq = 2.412e9

        ##################################################
        # Blocks
        ##################################################
        
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_0.set_iq_balance_mode(1, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)
          
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(10, 0)
        self.osmosdr_sink_0.set_gain(20, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(samp_rate, 0)
          
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
        	  fft_len=64, cp_len=fft_len/4,
        	  packet_length_tag_key=packet_length_tag_key,
        	  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=1,
        	  rolloff=0,
        	  debug_log=True,
        	  scramble_bits=False
        	 )
        	 
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=64, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+packet_length_tag_key,
        	  packet_length_tag_key=packet_length_tag_key,
        	  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=1,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, False)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, packet_length_tag_key)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, packet_length_tag_key)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((tx_gain, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.pdu_block = messaging.pdu_block(self)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.pdu_block, 'out_pdu'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))   
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.pdu_block, 'in_pdu'))      
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.digital_ofdm_rx_0, 0))    
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))