Python gnuradio.gr.top_block() Examples

The following are 30 code examples of gnuradio.gr.top_block(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gnuradio.gr , or try the search function .
Example #1
Source File: rp_eclipse.py    From piradar with GNU Affero General Public License v3.0 6 votes vote down vote up
def main(top_block_cls=top_block, options=None):

    from distutils.version import StrictVersion

    if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
        style = gr.prefs().get_string("qtgui", "style", "raster")
        Qt.QApplication.setGraphicsSystem(style)
    qapp = Qt.QApplication(sys.argv)

    tb = top_block_cls()
    tb.start()
    if GUI:
        tb.show()

    def quitting():
        tb.stop()
        tb.wait()

    qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting)
    qapp.exec_() 
Example #2
Source File: main-lastest.py    From python-examples with MIT License 6 votes vote down vote up
def __init__(self, sample_rate=32000):

        gr.top_block.__init__(self, "Top Block 22")        
        ##################################################
        # Variables
        ##################################################
        self.sample_rate = sample_rate
        print('[TopBlock22] __init__: sample_rate:', self.sample_rate)
        
        ##################################################
        # Blocks
        ##################################################
        self.blocks_add_xx = blocks.add_vff(1)
        self.audio_sink = audio.sink(32000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 440, 0.4, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 350, 0.4, 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.005, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx, 2))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx, 1))
        self.connect((self.blocks_add_xx, 0), (self.audio_sink, 0)) 
Example #3
Source File: Radio.py    From PLSDR with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,main):
    self.main = main
    gr.top_block.__init__(self, "Top Block")
    QWidget.__init__(self)    
    self.fir_offset_f = 0
    self.cw_offset = 0
    self.blocks_multiply_const_volume = None
    self.logpwrfft = None
    self.audio_sink = None
    self.osmosdr_source = None
    self.analog_agc_cc = None
    self.analog_pwr_squelch = None
    self.analog_pwr_squelch_ssb = None
    self.freq_xlating_fir_filter = None
    self.low_pass_filter_am = None
    self.low_pass_filter_fm = None
    self.low_pass_filter_wfm = None
    self.low_pass_filter_ssb = None
    self.band_pass_filter_cw = None
    self.cw_base = None
    self.mode = None
    self.sample_rate = None
    self.audio_rate = None
    self.gain_names = None
    self.device_found = False
    self.currently_configured_device = None
    self.error = False
    #self.if_offset_f = 0 
Example #4
Source File: doorbell-receiver.py    From so-you-want-to-hack-radios with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
    gr.top_block.__init__(self, name="Doorbell Top Block")

    # RF Config
    self.threshold_min = -60
    self.threshold_max = -50
    self.samp_rate = samp_rate = 100e3
    self.gain = gain = 30
    self.freq = freq = 315e6
    self.decimation = 10

    # USRP
    self.usrp = uhd.usrp_source("", uhd.stream_args("fc32"))
    self.usrp.set_samp_rate(samp_rate)
    self.usrp.set_center_freq(freq, 0)
    self.usrp.set_gain(gain, 0)
    self.usrp.set_antenna("TX/RX", 0)

    # Low Pass Filter
    self.lpf = filter.fir_filter_ccf(self.decimation,
      firdes.low_pass(1, samp_rate, 50e3, 10e3, firdes.WIN_HAMMING, 6.76))

    # Complex to Power (dB)
    self._10log10 = blocks.nlog10_ff(10, 1, 0)
    self.complex_to_mag_squared = blocks.complex_to_mag_squared(1)

    # Threshold
    self.threshold = blocks.threshold_ff(self.threshold_min, self.threshold_max, 0)

    # Framer
    self.framer = doorbell_framer()

    # Connect the blocks
    self.connect((self.usrp, 0), (self.lpf, 0))
    self.connect((self.lpf, 0), (self.complex_to_mag_squared, 0))
    self.connect((self.complex_to_mag_squared, 0), (self._10log10, 0))
    self.connect((self._10log10, 0), (self.threshold, 0))
    self.connect((self.threshold, 0), (self.framer, 0))


# Doorbell Framer 
Example #5
Source File: usrp_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate 
        self.rf_gain = rf_gain 
        self.port = port 
        self.if_gain = if_gain 
        self.frequency = frequency 
        self.freq_correction = freq_correction 
        self.bb_gain = bb_gain 
        self.bandwidth = bandwidth 

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'uhd'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_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('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex*1, '127.0.0.1', port, False)



        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #6
Source File: usrp_send.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " + 'uhd'
        )
        self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_sink_0.set_sample_rate(sample_rate)
        self.osmosdr_sink_0.set_center_freq(frequency, 0)
        self.osmosdr_sink_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(if_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(bandwidth, 0)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '127.0.0.1', port, 65536, False)

        self.connect((self.blocks_udp_source_0, 0), (self.osmosdr_sink_0, 0)) 
Example #7
Source File: bladerf_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'bladerf'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_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('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #8
Source File: hackrf_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'hackrf'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_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('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #9
Source File: sdrplay_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'sdrplay'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_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('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #10
Source File: funcube_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'fcd'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_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('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #11
Source File: rtl-sdr_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'rtl'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_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('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #12
Source File: hackrf_send.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " + 'hackrf'
        )
        self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_sink_0.set_sample_rate(sample_rate)
        self.osmosdr_sink_0.set_center_freq(frequency, 0)
        self.osmosdr_sink_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(if_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(bandwidth, 0)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '127.0.0.1', port, 65536, False)

        self.connect((self.blocks_udp_source_0, 0), (self.osmosdr_sink_0, 0)) 
Example #13
Source File: bladerf_send.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " + 'bladerf'
        )
        self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_sink_0.set_sample_rate(sample_rate)
        self.osmosdr_sink_0.set_center_freq(frequency, 0)
        self.osmosdr_sink_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_sink_0.set_gain(rf_gain, 0)
        self.osmosdr_sink_0.set_if_gain(if_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(bandwidth, 0)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1, '127.0.0.1', port, 65536, False)

        self.connect((self.blocks_udp_source_0, 0), (self.osmosdr_sink_0, 0)) 
Example #14
Source File: main-many-slicers.py    From python-examples with MIT License 5 votes vote down vote up
def __init__(self, sample_rate=32000, amplitude=0, frequency=0):

        gr.top_block.__init__(self, "Top Block 22")
        ##################################################
        # Variables
        ##################################################
        self.sample_rate = sample_rate
        print('[TopBlock22] __init__: sample_rate:', self.sample_rate)
        
        self.amplitude = amplitude
        print('[TopBlock22] __init__: amplitude:', self.amplitude)

        self.frequency = frequency
        print('[TopBlock22] __init__: frequency:', self.frequency)

        # for mute_on, mute_off
        #self.old_sample_rate = self.sample_rate
        #self.old_ampliture = self.ampliture
        #self.old_frequency = self.frequency

        ##################################################
        # Blocks
        ##################################################
        self.blocks_add_xx = blocks.add_vff(1)
        self.audio_sink = audio.sink(32000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 440,  amplitude, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 350, amplitude, 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN,  amplitude, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx, 2))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx, 1))
        self.connect((self.blocks_add_xx, 0), (self.audio_sink, 0)) 
Example #15
Source File: main-thread.py    From python-examples with MIT License 5 votes vote down vote up
def __init__(self, sample_rate):

        gr.top_block.__init__(self, "Top Block 22")        
        ##################################################
        # Variables
        ##################################################
        self.sample_rate = sample_rate
        print('[TopBlock22] sample_rate:', self.sample_rate)
        
        ##################################################
        # Blocks
        ##################################################
        self.blocks_add_xx = blocks.add_vff(1)
        self.audio_sink = audio.sink(32000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 440, 0.4, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 350, 0.4, 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.005, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx, 2))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx, 1))
        self.connect((self.blocks_add_xx, 0), (self.audio_sink, 0))

# ----------------------------------------------------------------------------- 
Example #16
Source File: top_block_22.py    From python-examples with MIT License 5 votes vote down vote up
def __init__(self, sample_rate):

        gr.top_block.__init__(self, "Top Block 22")        
        
        ##################################################
        # Variables
        ##################################################
        self.sample_rate = sample_rate
        print('[TopBlock22] sample_rate:', self.sample_rate)
        
        ##################################################
        # Blocks
        ##################################################
        self.blocks_add_xx = blocks.add_vff(1)
        self.audio_sink = audio.sink(32000, '', True)
        self.analog_sig_source_x_1 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 440, 0.4, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(sample_rate, analog.GR_COS_WAVE, 350, 0.4, 0)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, 0.005, -42)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx, 2))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_add_xx, 1))
        self.connect((self.blocks_add_xx, 0), (self.audio_sink, 0)) 
Example #17
Source File: rp_eclipse.py    From piradar with GNU Affero General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event):
        if GUI:
            self.settings = Qt.QSettings("GNU Radio", "top_block")
            self.settings.setValue("geometry", self.saveGeometry())
            event.accept() 
Example #18
Source File: receive345.py    From decode345 with MIT License 5 votes vote down vote up
def main(top_block_cls=top_block, options=None):

    tb = top_block_cls()
    tb.start()
    tb.wait() 
Example #19
Source File: qa_burst_verification.py    From gr-uaslink with GNU General Public License v3.0 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #20
Source File: qa_pymavlink_sink_p.py    From gr-uaslink with GNU General Public License v3.0 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #21
Source File: qa_pdu_vector_to_pdu_control.py    From gr-uaslink with GNU General Public License v3.0 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #22
Source File: qa_mavlink_control.py    From gr-uaslink with GNU General Public License v3.0 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #23
Source File: qa_pymavlink_source_p.py    From gr-uaslink with GNU General Public License v3.0 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #24
Source File: qa_pdu_control_to_pdu_vector.py    From gr-uaslink with GNU General Public License v3.0 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #25
Source File: qa_drom_gain_cc.py    From OFDM with MIT License 5 votes vote down vote up
def setUp (self):
        self.tb = gr.top_block () 
Example #26
Source File: test_spectrogram.py    From OpenNFB with GNU General Public License v3.0 5 votes vote down vote up
def quitting():
        top_block.stop()
        #tb.wait() 
Example #27
Source File: top_block.py    From OregonDecoder with GNU General Public License v2.0 5 votes vote down vote up
def closeEvent(self, event):
        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.settings.setValue("geometry", self.saveGeometry())
        event.accept() 
Example #28
Source File: demod_rf.py    From waveconverter with MIT License 4 votes vote down vote up
def __init__(self, samp_rate_in, samp_rate_out, center_freq, 
                 tune_freq, channel_width, transition_width, threshold,
                 iq_filename, dig_out_filename):
        gr.top_block.__init__(self)

        
        ##################################################
        # Variables
        ##################################################
        self.cutoff_freq = channel_width/2
        self.firdes_taps = firdes.low_pass(1, samp_rate_in, 
                                           self.cutoff_freq, 
                                           transition_width)
        
        ##################################################
        # Blocks
        ##################################################
        self.tuning_filter_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_in/samp_rate_out), 
                                                                  (self.firdes_taps), 
                                                                  tune_freq-center_freq, 
                                                                  samp_rate_in)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, iq_filename, False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1*threshold, ))

        # message sink is primary method of getting baseband data into waveconverter        
        self.sink_queue = gr.msg_queue()
        self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*1, self.sink_queue, False)
        
        # if directed, we also dump the baseband data into a file
        if len(dig_out_filename) > 0:
            print "Outputing baseband to waveform to " + dig_out_filename
            self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, dig_out_filename, False)
            self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.tuning_filter_0, 0))
        self.connect((self.tuning_filter_0, 0), (self.blocks_complex_to_mag_0, 0))

        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0))
        if len(dig_out_filename) > 0:
            self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))


##############################################################
# This flowgraph consists of the following blocks:
# - a File Source that 
# - a Frequency Translating FIR filter that tunes to the target signal
# - a quadrature demod block that demodules the FSK signal
# - an Add Const block that shifts the demodulated signal downwards, centering
#   it around zero on the y-axis
# - a Binary Slicer that converts centered signal from floating point to binary
# - a File Sink that outputs 
Example #29
Source File: doorbell-transmitter.py    From so-you-want-to-hack-radios with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, button_id=124, tone=1):
    gr.top_block.__init__(self, "Top Block")

    # RF Config
    samp_rate = 1e6
    gain = 50
    freq = 315e6

    # USRP
    self.usrp = uhd.usrp_sink("", uhd.stream_args("fc32"))
    self.usrp.set_samp_rate(samp_rate)
    self.usrp.set_center_freq(freq, 0)
    self.usrp.set_gain(gain, 0)
    self.usrp.set_antenna("TX/RX", 0)

    # Signal source
    self.tone = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)

    # Generate the bit 1 and bit 0 masks
    b0 = [0]*int(0.00028 * samp_rate) + [1]*int(0.00072 * samp_rate)
    b1 = [0]*int(0.00068 * samp_rate) + [1]*int(0.00032 * samp_rate)

    # Generate the packet mask
    id_bits = "{0:b}".format(button_id).zfill(8)[:8][::-1]
    tone_bits = "{0:b}".format(tone).zfill(4)[:4][::-1]
    packet_bits = '1' + id_bits + tone_bits
    mask = []
    for b in packet_bits:
      if b == '1':
        mask += b1
      else:
        mask += b0

    # Add some 0's to the end of the mask, because
    # the doorbell waits for a transmission to
    # finish before playing the tone
    mask += [0]*15000

    # Vector source w/ packet mask
    self.packet_mask = blocks.vector_source_c(mask, True, 1, [])

    # Multiply (mask * signal)
    self.multiply = blocks.multiply_vcc(1)

    # Connect the blocks
    self.connect((self.tone, 0), (self.multiply, 0))
    self.connect((self.packet_mask, 0), (self.multiply, 1))
    self.connect((self.multiply, 0), (self.usrp, 0)) 
Example #30
Source File: receive345.py    From decode345 with MIT License 4 votes vote down vote up
def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.trans_width = trans_width = 10e3
        self.samp_rate = samp_rate = 1e6
        self.mult_const = mult_const = 100
        self.lowpass_decimation = lowpass_decimation = 10
        self.freq = freq = 344940000
        self.cutoff_freq = cutoff_freq = 50e3

        ##################################################
        # Blocks
        ##################################################
        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(True, 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(lowpass_decimation, firdes.low_pass(
        	1, samp_rate, cutoff_freq, trans_width, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult_const, ))
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/tmp/grcfifo', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))