def __init__(self, samp_rate):
		gr.hier_block2.__init__(self, "throttled_sink",  gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(0, 0, 0))

		self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.sink = blocks.udp_sink(gr.sizeof_gr_complex*1, "127.0.0.1", 9999, 1472, True) #OK

		self.connect(self, self.throttle, self.sink)
    def test_002(self):
        port = 65520

        n_data = 100
        src_data = [float(x) for x in range(n_data)]
        expected_result = tuple(src_data)
        src = blocks.vector_source_f(src_data, False)
        udp_snd = blocks.udp_sink(gr.sizeof_float, 'localhost', port)
        self.tb_snd.connect(src, udp_snd)

        udp_rcv = blocks.udp_source(gr.sizeof_float, 'localhost', port)
        dst = blocks.vector_sink_f()
        self.tb_rcv.connect(udp_rcv, dst)

        self.tb_rcv.start()
        self.tb_snd.run()
        udp_snd.disconnect()
        self.timeout = False
        q = Timer(2.0,self.stop_rcv)
        q.start()
        self.tb_rcv.wait()
        q.cancel()

        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
        self.assert_(not self.timeout)
    def test_003(self):
        port = 65530

        udp_rcv = blocks.udp_source(gr.sizeof_float, '0.0.0.0', 0, eof=False)
        rcv_port = udp_rcv.get_port()

        udp_snd = blocks.udp_sink(gr.sizeof_float, '127.0.0.1', port)
        udp_snd.connect('127.0.0.1', rcv_port)

        n_data = 16
        src_data = [float(x) for x in range(n_data)]
        expected_result = tuple(src_data)
        src = blocks.vector_source_f(src_data)
        dst = blocks.vector_sink_f()

        self.tb_snd.connect(src, udp_snd)
        self.tb_rcv.connect(udp_rcv, dst)

        self.tb_rcv.start()
        self.tb_snd.run()
        udp_snd.disconnect()
        self.timeout = False
        q = Timer(2.0,self.stop_rcv)
        q.start()
        self.tb_rcv.wait()
        q.cancel()

        result_data = dst.data()
        self.assertEqual(expected_result, result_data)
        self.assert_(self.timeout)  # source ignores EOF?
Example #4
0
    def test_sink_001(self):
        port = 65520

        n_data = 100
        src_data = [float(x) for x in range(n_data)]
        expected_result = tuple(src_data)

        recvsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        recvsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        recvsock.bind(('127.0.0.1', port))

        result = []
        t = Thread(target=recv_data, args=(recvsock, result))
        t.start()

        src = blocks.vector_source_f(src_data, False)
        udp_snd = blocks.udp_sink(gr.sizeof_float, '127.0.0.1', port)
        self.tb_snd.connect(src, udp_snd)


        self.tb_snd.run()
        udp_snd.disconnect()
        t.join()
        recvsock.close()

        self.assertEqual(expected_result, tuple(result))
    def __init__(self):
        gr.top_block.__init__(self, "SQ5BPF Tetra live receiver 1ch UDP HEADLESS")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.first_decim = first_decim = 32
        self.xlate_offset_fine1 = xlate_offset_fine1 = 0
        self.xlate_offset1 = xlate_offset1 = 500e3
        self.udp_packet_size = udp_packet_size = 1472
        self.udp_dest_addr = udp_dest_addr = "127.0.0.1"
        self.telive_receiver_name = telive_receiver_name = 'SQ5BPF 1-channel headless rx for telive'
        self.telive_receiver_channels = telive_receiver_channels = 1
        self.sdr_ifgain = sdr_ifgain = 20
        self.sdr_gain = sdr_gain = 38
        self.ppm_corr = ppm_corr = 56
        self.out_sample_rate = out_sample_rate = 36000
        self.options_low_pass = options_low_pass = 12500
        self.if_samp_rate = if_samp_rate = samp_rate/first_decim
        self.freq = freq = 435e6
        self.first_port = first_port = 42000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0", first_port), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).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(freq, 0)
        self.osmosdr_source_0.set_freq_corr(ppm_corr, 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(sdr_gain, 0)
        self.osmosdr_source_0.set_if_gain(sdr_ifgain, 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.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(first_decim, (firdes.low_pass(1, samp_rate, options_low_pass, options_low_pass*0.2)), xlate_offset1+xlate_offset_fine1, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, float(float(if_samp_rate)/float(out_sample_rate)))
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, udp_dest_addr, first_port+1, udp_packet_size, False)
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.analog_agc3_xx_0, 0), (self.fractional_resampler_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc3_xx_0, 0))
    def __init__(self, n=512):
        gr.top_block.__init__(self, "SDR Spectrum Analyzer Server")

        ##################################################
        # Variables
        ##################################################
        self.port = port = 9999
        self.gan = gan = 10
        self.fc = fc = 99700000
        self.ab = ab = 20000000
        self.N = N = 1024
        self.n = n
        self.IP = IP = "192.168.1.103"
        self.Antena = Antena = "RX2"
        self.ventana = ventana = window.blackmanharris
        self.base = base = "exponencial"

        ##################################################
        # Blocks
        ##################################################
        self.src = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.src.set_samp_rate(ab)
        self.src.set_center_freq(fc, 0)
        self.src.set_gain(gan, 0)
        self.src.set_antenna("RX2", 0)
        self.dbm = RadioGIS.dbm()
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, N)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, N)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_float*1, N*n)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, N)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(N)
        self.udp_sink_0 = blocks.udp_sink(gr.sizeof_float*1, IP, port, 1472, True)
        self.RadioGIS_fft_0 = RadioGIS.fft(N, base, (ventana(N)))
        self.RadioGIS_averager_0 = RadioGIS.averager(N, n)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RadioGIS_averager_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.dbm, 0), (self.udp_sink_0, 0))    
        self.connect((self.RadioGIS_fft_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.RadioGIS_fft_0, 0))    
        self.connect((self.blocks_stream_to_vector_1, 0), (self.RadioGIS_averager_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.dbm, 0))    
        self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_stream_to_vector_1, 0))    
        self.connect((self.src, 0), (self.blocks_stream_to_vector_0, 0))
Example #7
0
    def __init__(self, host, port, pkt_size, sample_rate, eof):
        gr.top_block.__init__(self, "dial_tone_source")

        amplitude = 0.3
        src0 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 350, amplitude)
        src1 = analog.sig_source_f(sample_rate, analog.GR_SIN_WAVE, 440, amplitude)
        add = blocks.add_ff()

        # Throttle needed here to account for the other side's audio card sampling rate
	thr = blocks.throttle(gr.sizeof_float, sample_rate)
	sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
	self.connect(src0, (add, 0))
	self.connect(src1, (add, 1))
	self.connect(add, thr, sink)
Example #8
0
    def __init__(self, gan=10, fi=70000000, ab=32000000, sc=10, t=1, base="exponencial", escala="dBm"):
        gr.top_block.__init__(self, "SDR RNI Meter")

        ##################################################
        # Variables
        ##################################################
        self.port = port = 9999
        self.gan = gan
        self.fi = fi
        self.ab = ab
        self.fc = fc = fi + ab / 2
        self.N = N = 1024
        self.sc = sc
        self.t = t
        self.IP = IP = "192.168.1.108"
        self.Antena = Antena = "RX2"
        self.ventana = ventana = window.blackmanharris
        self.base = base
        self.escala = escala
        self.gps = gps = "n: 0.0 deg 0.0 deg 0.0m lat/lon/al"

        ##################################################
        # Blocks
        ##################################################
        self.src = uhd.usrp_source(",".join(("", "")), uhd.stream_args(cpu_format="fc32", channels=range(1)))
        self.src.set_samp_rate(ab)
        self.src.set_center_freq(fc, 0)
        self.src.set_gain(gan, 0)
        self.src.set_antenna("RX2", 0)
        self.dbm = RadioGIS.dbm()
        self.dbm.set_enabled(escala == "dBm")
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float * 1, N)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, N)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(N)
        self.RadioGIS_time_averager_0 = RadioGIS.time_averager(N, t)
        self.udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, IP, port, 1472, True)
        self.RadioGIS_fft_0 = RadioGIS.fft(N, base, (ventana(N)))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RadioGIS_fft_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.RadioGIS_time_averager_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.RadioGIS_fft_0, 0))
        self.connect((self.RadioGIS_time_averager_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.dbm, 0))
        self.connect((self.dbm, 0), (self.udp_sink_0, 0))
        self.connect((self.src, 0), (self.blocks_stream_to_vector_0, 0))
    def test_001(self):
        # Tests calling disconnect/reconnect.

        port = 65510

        n_data = 16
        src_data = [x for x in range(n_data)]
        expected_result = tuple(src_data)
        src = blocks.vector_source_s(src_data, False)
        udp_snd = blocks.udp_sink(gr.sizeof_short, 'localhost', port)
        self.tb_snd.connect(src, udp_snd)

        self.tb_snd.run()
        udp_snd.disconnect()

        udp_snd.connect('localhost', port+1)
        src.rewind()
        self.tb_snd.run()
Example #10
0
    def __init__(self):
        gr.top_block.__init__(self, "Ofdm")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ofdm")
        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")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Blocks
        ##################################################
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_int*1, "192.168.0.100", 1234, 1472, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_int*1, 0.71e4,True)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_int*1, "/home/juan/Downloads/03 Cye Feat. Kasia Kurzewska.mp3", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_throttle_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver Juan")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 15
        self.samp_rate_0 = samp_rate_0 = 20e6
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 5
        self.oversampling = oversampling = 4
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=.5**.5,
        	frequency_offset=0,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, "192.168.200.2", 1234, 100, True)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 2*4e3 + 0*samp_rate/40/(oversampling*8*2),True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/media/juan/d6aba572-c85c-40cc-9258-ae1538dfb8c5/home/juan/Music/de_mi.mp3", True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.blocks_message_debug_0, 'print'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Perseus Spectrum Sensing")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Perseus Spectrum Sensing")
        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", "perseus_withFPGAdecimation")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 20e6
        self.packet_size = packet_size = 8192
        self.oversampling = oversampling = 4
        self.nfft = nfft = 2**15
        self.decimation = decimation = 40
        self.amplitude = amplitude = 0.125
        self.RF_freq = RF_freq = 943e6
        self.PSD_averaging = PSD_averaging = 600

        ##################################################
        # Blocks
        ##################################################
        self.spectsensing_xs_plot_1 = spectsensing.xs_plot("")
        self._spectsensing_xs_plot_1_win = self.spectsensing_xs_plot_1;
        self.top_layout.addWidget(self._spectsensing_xs_plot_1_win)
        self.spectsensing_ss_pds_plot_0 = spectsensing.ss_pds_plot(nfft, samp_rate, 1024 )
        self.nutaq_rtdex_source_S_S_0 = nutaq.rtdex_source("nutaq_carrier_perseus_TX",gr.sizeof_short,1,0)
        self.nutaq_rtdex_source_S_S_0.set_type(0)
        self.nutaq_rtdex_source_S_S_0.set_packet_size(1300)
        self.nutaq_rtdex_source_S_S_0.set_channels("0")
        self.nutaq_rtdex_source_0_0_0 = nutaq.rtdex_source("nutaq_carrier_perseus_TX",gr.sizeof_short,1,7)
        self.nutaq_rtdex_source_0_0_0.set_type(0)
        self.nutaq_rtdex_source_0_0_0.set_packet_size(packet_size)
        self.nutaq_rtdex_source_0_0_0.set_channels("2")
        (self.nutaq_rtdex_source_0_0_0).set_min_output_buffer(16384)
        self.nutaq_rtdex_sink_0 = nutaq.rtdex_sink("nutaq_carrier_perseus_TX",gr.sizeof_short,1,7)
        self.nutaq_rtdex_sink_0.set_type(0)
        self.nutaq_rtdex_sink_0.set_packet_size(packet_size)
        self.nutaq_rtdex_sink_0.set_channels("1")
        self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_TX", 2, 1)
        self.nutaq_radio420_tx_0_0.set_default_enable(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_freq(RF_freq)
        self.nutaq_radio420_tx_0_0.set_default_reference(1)
        self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0_0.set_default_band(0)
        self.nutaq_radio420_tx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(2)
        self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_tx_0 = nutaq.radio420_tx("nutaq_carrier_perseus_TX", 1, 0)
        self.nutaq_radio420_tx_0.set_default_enable(1)
        self.nutaq_radio420_tx_0.set_default_tx_freq(RF_freq)
        self.nutaq_radio420_tx_0.set_default_reference(0)
        self.nutaq_radio420_tx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0.set_default_band(0)
        self.nutaq_radio420_tx_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0.set_default_tx_vga1_gain(-4)
        self.nutaq_radio420_tx_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0.set_default_tx_gain3(14)
        self.nutaq_radio420_tx_0.set_default_tx_lpf_bandwidth(2)
        self.nutaq_radio420_tx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0_0 = nutaq.radio420_rx("nutaq_carrier_perseus_TX", 2, 3)
        self.nutaq_radio420_rx_0_0.set_default_enable(1)
        self.nutaq_radio420_rx_0_0.set_default_rx_freq(RF_freq)
        self.nutaq_radio420_rx_0_0.set_default_reference(1)
        self.nutaq_radio420_rx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0_0.set_default_band(0)
        self.nutaq_radio420_rx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_vga1_gain(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain2(0)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain3(-8)
        self.nutaq_radio420_rx_0_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_TX", 1, 2)
        self.nutaq_radio420_rx_0.set_default_enable(1)
        self.nutaq_radio420_rx_0.set_default_rx_freq(RF_freq)
        self.nutaq_radio420_rx_0.set_default_reference(0)
        self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0.set_default_band(0)
        self.nutaq_radio420_rx_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_gain2(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain3(-8)
        self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_custom_register_0_1_1 = nutaq.custom_register("nutaq_carrier_perseus_TX",9)
        self.nutaq_custom_register_0_1_1.set_index(6)
        self.nutaq_custom_register_0_1_1.set_default_value(PSD_averaging)
        self.nutaq_custom_register_0_1_1.set_update_rate(1)
          
        self.nutaq_custom_register_0_1_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",7)
        self.nutaq_custom_register_0_1_0.set_index(2)
        self.nutaq_custom_register_0_1_0.set_update_rate(1)
          
        self.nutaq_custom_register_0_1 = nutaq.custom_register("nutaq_carrier_perseus_TX",36)
        self.nutaq_custom_register_0_1.set_index(0)
        self.nutaq_custom_register_0_1.set_update_rate(1)
          
        self.nutaq_custom_register_0_0_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",8)
        self.nutaq_custom_register_0_0_0.set_index(3)
        self.nutaq_custom_register_0_0_0.set_default_value(7)
        self.nutaq_custom_register_0_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",5)
        self.nutaq_custom_register_0_0.set_index(4)
        self.nutaq_custom_register_0_0.set_default_value(1)
        self.nutaq_custom_register_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",4)
        self.nutaq_custom_register_0.set_index(1)
        self.nutaq_custom_register_0.set_default_value(3)
        self.nutaq_custom_register_0.set_update_rate(1)
          
        self.nutaq_carrier_perseus_TX = nutaq.carrier(0,"nutaq_carrier_perseus_TX", "192.168.0.101")
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=oversampling,
        	bt=0.71,
        	verbose=False,
        	log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=oversampling,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, "192.168.0.100", 1234, 1472, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 2*4e3 + 0*samp_rate/40/(oversampling*8*2),True)
        self.blocks_short_to_float_0_1_0 = blocks.short_to_float(1, 2**11)
        self.blocks_short_to_float_0_0_0_0 = blocks.short_to_float(1, 2**11)
        self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vff((2.0**(16*2), ))
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((amplitude, ))
        self.blocks_multiply_const_vxx_0_1_1 = blocks.multiply_const_vff((2.0**(16*0), ))
        self.blocks_multiply_const_vxx_0_1_0_0 = blocks.multiply_const_vff((2.0**(16*1), ))
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_short*1, 1)
        self.blocks_float_to_short_0_0_0 = blocks.float_to_short(1, 2**11-1)
        self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 2**11-1)
        self.blocks_float_to_complex_0_0_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/juan/Music/de_mi.mp3", True)
        self.blocks_deinterleave_0_0_1 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_deinterleave_0_0_0 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=2,
        		bits_per_symbol=8,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=128,
        )
        self.blks2_packet_decoder_1 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_1.recv_pkt(ok, payload),
        	),
        )
        self.DataConversion_reint_short_float_0_3 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_2_0 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_1_0 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_0_0 = DataConversion.reint_short_float()
        self.DataConversion_eaver_resynchronizer_0_0 = DataConversion.eaver_resynchronizer(1024)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.spectsensing_ss_pds_plot_0, 'psd_pdu'), (self.spectsensing_xs_plot_1, 'pdus'))    
        self.connect((self.DataConversion_eaver_resynchronizer_0_0, 0), (self.spectsensing_ss_pds_plot_0, 0))    
        self.connect((self.DataConversion_eaver_resynchronizer_0_0, 1), (self.spectsensing_ss_pds_plot_0, 1))    
        self.connect((self.DataConversion_reint_short_float_0_0_0, 0), (self.blocks_multiply_const_vxx_0_3, 0))    
        self.connect((self.DataConversion_reint_short_float_0_1_0, 0), (self.blocks_multiply_const_vxx_0_1_0_0, 0))    
        self.connect((self.DataConversion_reint_short_float_0_2_0, 0), (self.blocks_multiply_const_vxx_0_1_1, 0))    
        self.connect((self.DataConversion_reint_short_float_0_3, 0), (self.DataConversion_eaver_resynchronizer_0_0, 0))    
        self.connect((self.blks2_packet_decoder_1, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0))    
        self.connect((self.blocks_add_xx_0_0, 0), (self.DataConversion_eaver_resynchronizer_0_0, 1))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_short_0_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_float_to_short_0_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_0, 1), (self.blocks_short_to_float_0_0_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_0, 0), (self.blocks_short_to_float_0_1_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 1), (self.DataConversion_reint_short_float_0_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 3), (self.DataConversion_reint_short_float_0_1_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 2), (self.DataConversion_reint_short_float_0_2_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 0), (self.DataConversion_reint_short_float_0_3, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_float_to_complex_0_0_0, 0), (self.digital_gmsk_demod_0, 0))    
        self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_interleave_0, 0))    
        self.connect((self.blocks_float_to_short_0_0_0, 0), (self.blocks_interleave_0, 1))    
        self.connect((self.blocks_interleave_0, 0), (self.nutaq_rtdex_sink_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0_0, 0), (self.blocks_add_xx_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_1_1, 0), (self.blocks_add_xx_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0_0, 0))    
        self.connect((self.blocks_short_to_float_0_0_0_0, 0), (self.blocks_float_to_complex_0_0_0, 1))    
        self.connect((self.blocks_short_to_float_0_1_0, 0), (self.blocks_float_to_complex_0_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blks2_packet_encoder_0, 0))    
        self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_1, 0))    
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))    
        self.connect((self.nutaq_rtdex_source_0_0_0, 0), (self.blocks_deinterleave_0_0_0, 0))    
        self.connect((self.nutaq_rtdex_source_S_S_0, 0), (self.blocks_deinterleave_0_0_1, 0))    
Example #13
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Dectrx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.channel = channel = 1
        self.samp_rate = samp_rate = 2.4e6
        self.rf_gain = rf_gain = 10
        self.ppm = ppm = 0
        self.if_gain = if_gain = 20
        self.freq = freq = 1897.344e6 - (channel * 1.728e6)
        self.dect_rate = dect_rate = 1.152e6
        self.bb_gain = bb_gain = 20

        ##################################################
        # Blocks
        ##################################################
        _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rf_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            label='rf_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rf_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rf_gain_sizer,
            value=self.rf_gain,
            callback=self.set_rf_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rf_gain_sizer)
        _ppm_sizer = wx.BoxSizer(wx.VERTICAL)
        self._ppm_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_ppm_sizer,
            value=self.ppm,
            callback=self.set_ppm,
            label="ppm",
            converter=forms.int_converter(),
            proportion=0,
        )
        self._ppm_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_ppm_sizer,
            value=self.ppm,
            callback=self.set_ppm,
            minimum=-70,
            maximum=+70,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=int,
            proportion=1,
        )
        self.Add(_ppm_sizer)
        _if_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._if_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_if_gain_sizer,
            value=self.if_gain,
            callback=self.set_if_gain,
            label='if_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._if_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_if_gain_sizer,
            value=self.if_gain,
            callback=self.set_if_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_if_gain_sizer)
        _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._bb_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_bb_gain_sizer,
            value=self.bb_gain,
            callback=self.set_bb_gain,
            label='bb_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._bb_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_bb_gain_sizer,
            value=self.bb_gain,
            callback=self.set_bb_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_bb_gain_sizer)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
            self.GetWin(),
            baseband_freq=freq,
            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.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=24,
            decimation=25,
            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(freq, 0)
        self.osmosdr_source_0.set_freq_corr(ppm, 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(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(dect_rate, 0)

        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, dect_rate, 10e3, firdes.WIN_HAMMING,
                            6.76))
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0,
            verbose=False,
            log=False,
        )
        self._channel_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.channel,
            callback=self.set_channel,
            label="channel",
            major_dimension=10,
            choices=[
                0,
                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,
            ],
            labels=[],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._channel_chooser)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "127.0.0.1", 2323, 1472, True)
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_pack_k_bits_bb_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.low_pass_filter_0, 0))
Example #14
0
    def __init__(self, antenna="", bb_freq=0.0, bfo_freq=1e3, bw=0.0, dc_removal="False", decoded_data_file_path="/tmp/.satnogs/data/data", dev_args="", doppler_correction_per_sec=20, enable_iq_dump=0, file_path="test.wav", gain=0.0, gain_mode="Overall", iq_file_path="/tmp/iq.dat", lo_offset=100e3, other_settings="", ppm=0, rigctl_port=4532, rx_freq=100e6, samp_rate_rx=0.0, soapy_rx_device="driver=invalid", stream_args="", tune_args="", udp_IP="127.0.0.1", udp_dump_dest='127.0.0.1', udp_dump_port=7355, udp_port=16887, waterfall_file_path="/tmp/waterfall.dat", wpm=20):
        gr.top_block.__init__(self, "CW Decoder")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_freq = bb_freq
        self.bfo_freq = bfo_freq
        self.bw = bw
        self.dc_removal = dc_removal
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.gain = gain
        self.gain_mode = gain_mode
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.other_settings = other_settings
        self.ppm = ppm
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.samp_rate_rx = samp_rate_rx
        self.soapy_rx_device = soapy_rx_device
        self.stream_args = stream_args
        self.tune_args = tune_args
        self.udp_IP = udp_IP
        self.udp_dump_dest = udp_dump_dest
        self.udp_dump_port = udp_dump_port
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path
        self.wpm = wpm

        ##################################################
        # Variables
        ##################################################
        self.audio_samp_rate = audio_samp_rate = 48000
        self.variable_cw_decoder_0 = variable_cw_decoder_0 = satnogs.cw_decoder_make(audio_samp_rate/4, 512, 512-8, wpm, 10, 0.90, 4, 8, 96)
        self.dot_samples = dot_samples = int((1.2 / wpm) / (1.0 / (audio_samp_rate / 10.0)))

        ##################################################
        # Blocks
        ##################################################
        self.soapy_source_0_0 = None
        # Make sure that the gain mode is valid
        if(gain_mode not in ['Overall', 'Specific', 'Settings Field']):
            raise ValueError("Wrong gain mode on channel 0. Allowed gain modes: "
                  "['Overall', 'Specific', 'Settings Field']")

        dev = soapy_rx_device

        # Stream arguments for every activated stream
        tune_args = [tune_args]
        settings = [other_settings]

        # Setup the device arguments
        dev_args = dev_args

        self.soapy_source_0_0 = soapy.source(1, dev, dev_args, stream_args,
                                  tune_args, settings, samp_rate_rx, "fc32")



        self.soapy_source_0_0.set_dc_removal(0,bool(distutils.util.strtobool(dc_removal)))

        # Set up DC offset. If set to (0, 0) internally the source block
        # will handle the case if no DC offset correction is supported
        self.soapy_source_0_0.set_dc_offset(0,0)

        # Setup IQ Balance. If set to (0, 0) internally the source block
        # will handle the case if no IQ balance correction is supported
        self.soapy_source_0_0.set_iq_balance(0,0)

        self.soapy_source_0_0.set_agc(0,False)

        # generic frequency setting should be specified first
        self.soapy_source_0_0.set_frequency(0, rx_freq - lo_offset)

        self.soapy_source_0_0.set_frequency(0,"BB",bb_freq)

        # Setup Frequency correction. If set to 0 internally the source block
        # will handle the case if no frequency correction is supported
        self.soapy_source_0_0.set_frequency_correction(0,ppm)

        self.soapy_source_0_0.set_antenna(0,antenna)

        self.soapy_source_0_0.set_bandwidth(0,bw)

        if(gain_mode != 'Settings Field'):
            # pass is needed, in case the template does not evaluare anything
            pass
            self.soapy_source_0_0.set_gain(0,gain)
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(audio_samp_rate, rx_freq, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, int(1000.0/doppler_correction_per_sec) + 1, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0)
        self.satnogs_json_converter_0 = satnogs.json_converter()
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump)
        self.satnogs_frame_file_sink_0_0 = satnogs.frame_file_sink(decoded_data_file_path, 0)
        self.satnogs_frame_decoder_0 = satnogs.frame_decoder(variable_cw_decoder_0, 8 * 1)
        self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(samp_rate_rx, rx_freq, lo_offset, audio_samp_rate, 1, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(
                1,
                audio_samp_rate,
                3000,
                1e3,
                firdes.WIN_HAMMING,
                6.76))
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, udp_dump_dest, udp_dump_port+1, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, udp_dump_dest, udp_dump_port, 1472, True)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(2.0 * math.pi * (bfo_freq / audio_samp_rate))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16383.0)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 0.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_frame_decoder_0, 'out'), (self.satnogs_json_converter_0, 'in'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_frame_file_sink_0_0, 'frame'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_doppler_compensation_0, 'doppler'))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.satnogs_frame_decoder_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.blocks_udp_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_iq_sink_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.soapy_source_0_0, 0), (self.satnogs_doppler_compensation_0, 0))
Example #15
0
 def __init__(self, host, port, pkt_size, eof):
     gr.top_block.__init__(self, "vector_source")
     data = [i * 0.01 for i in range(1000)]
     vec = blocks.vector_source_f(data, True)
     udp = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
     self.connect(vec, udp)
Example #16
0
    def __init__(self):
        gr.top_block.__init__(self, "Pfb Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pfb Test")
        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", "pfb_test")

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4.8e6

        self.variable_low_pass_filter_taps_0 = variable_low_pass_filter_taps_0 = firdes.low_pass(
            1.0, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)

        self.Noversample = Noversample = 1
        self.M = M = 192

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / M * Noversample,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0_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_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(-140, 10)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
            M, (variable_low_pass_filter_taps_0), Noversample, 100)
        self.pfb_channelizer_ccf_0.set_channel_map(([1]))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)

        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 'localhost', 7355, 1472, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(-3.14159 * 0.0375 / 2.4)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 127)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, 'dump1.cf32', False)
        self.blocks_endian_swap_0 = blocks.endian_swap(2)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-60, 1)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=25000,
            quad_rate=25000,
            tau=75e-6,
            max_dev=5e3,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_rx_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.blocks_endian_swap_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_endian_swap_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.pfb_channelizer_ccf_0, 0))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_rotator_cc_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        for i in range(M - 1):
            self.connect((self.pfb_channelizer_ccf_0, i + 1),
                         (self.blocks_null_sink_0, i))
        self.connect((self.pfb_channelizer_ccf_0, 0),
                     (self.qtgui_waterfall_sink_x_0_0, 0))
Example #17
0
    def __init__(self):
        gr.top_block.__init__(self, "NBFM Receiver V2- F1ATB - MARCH 2021")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.Largeur_filtre = Largeur_filtre = 10000
        self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate, Largeur_filtre/2, 1500)
        self.decim_LP = decim_LP = 16
        self.Squelch = Squelch = -80
        self.Gain_RF = Gain_RF = 30
        self.Gain_IF = Gain_IF = 20
        self.Gain_BB = Gain_BB = 20
        self.FrRX = FrRX = 145000000
        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.pluto_source_0 = iio.pluto_source('192.168.2.1', 145000000, int(samp_rate), 1000000, 32768, True, True, True, "manual", 50, '', True)
        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/100,
        	fft_size=2048,
        	ref_scale=0.00001,
        	frame_rate=samp_rate/100/2048,
        	avg_alpha=1.0,
        	average=False,
        )
        self.iio_attr_updater_0_0 = iio.attr_updater('hardwaregain', str(int(Gain_RF*1.75)), 1000)
        self.iio_attr_updater_0 = iio.attr_updater('frequency', str(int(FrRX)), 1000)
        self.iio_attr_sink_0_0 = iio.attr_sink("ip:192.168.2.1", "ad9361-phy", "voltage0", 0, False, False)
        self.iio_attr_sink_0 = iio.attr_sink("ip:192.168.2.1", "ad9361-phy", "altvoltage0", 0, True, False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(30, (xlate_filter_taps), F_Fine, samp_rate)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, decim_LP/2)
        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_pdu_remove_0 = blocks.pdu_remove(pmt.intern("key"))
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, int(1024*decim_LP), 204800, 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_simple_squelch_cc_0 = analog.simple_squelch_cc(Squelch, 0.001)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=int(samp_rate/120),
        	quad_rate=int(samp_rate/30),
        	tau=75e-6,
        	max_dev=5e3,
          )



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.iio_attr_updater_0, 'out'), (self.iio_attr_sink_0, 'attr'))
        self.msg_connect((self.iio_attr_updater_0_0, 'out'), (self.iio_attr_sink_0_0, 'attr'))
        self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_float_to_short_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_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.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.pluto_source_0, 0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.pluto_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
Example #18
0
    def __init__(self,
                 hw="usrp",
                 samp_rate=100000,
                 freq=3.2e9,
                 gain=0,
                 ds_mode=False,
                 agc=False):
        gr.enable_realtime_scheduling()
        gr.top_block.__init__(self, "SDR capture device")

        ##################################################
        # Variables
        ##################################################
        self.hw = hw
        self.samp_rate = samp_rate
        self.freq = freq
        self.gain = gain
        self.ds_mode = ds_mode
        logger.info("%s: samp_rate=%d, freq=%f, gain=%d, ds_mode=%s" %
                    (hw, samp_rate, freq, gain, ds_mode))

        ##################################################
        # Blocks
        ##################################################
        if hw == "usrp":
            self.sdr_source = uhd.usrp_source(
                ",".join(("", "recv_frame_size=1024", "num_recv_frames=1024",
                          "spp=1024")),
                # ",".join(("", "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
            self.sdr_source.set_samp_rate(samp_rate)
            self.sdr_source.set_center_freq(freq, 0)
            set_gain(self.sdr_source, gain)
            # self.sdr_source.set_min_output_buffer(16*1024*1024)  # 16 MB output buffer
            self.sdr_source.set_antenna('RX2', 0)
            self.sdr_source.set_bandwidth(samp_rate, 0)
            self.sdr_source.set_recv_timeout(0.001, True)
        else:
            if hw == "hackrf":
                rtl_string = ""
            else:
                rtl_string = "rtl=0,"
            if ds_mode:
                self.sdr_source = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + rtl_string +
                                                 "buflen=1024,direct_samp=2")
            else:
                self.sdr_source = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + rtl_string +
                                                 "buflen=4096")
            self.sdr_source.set_sample_rate(samp_rate)
            self.sdr_source.set_center_freq(freq, 0)
            self.sdr_source.set_freq_corr(0, 0)
            self.sdr_source.set_dc_offset_mode(0, 0)
            self.sdr_source.set_iq_balance_mode(0, 0)
            if agc:
                self.sdr_source.set_gain_mode(True, 0)
            else:
                self.sdr_source.set_gain_mode(False, 0)
                # self.sdr_source.set_if_gain(24, 0)
                # self.sdr_source.set_bb_gain(20, 0)
                set_gain(self.sdr_source, gain)
            self.sdr_source.set_antenna('', 0)
            self.sdr_source.set_bandwidth(samp_rate, 0)

        self.udp_sink = blocks.udp_sink(8,
                                        "127.0.0.1",
                                        3884,
                                        payload_size=1472,
                                        eof=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.sdr_source, 0), (self.udp_sink, 0))
Example #19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Udp Tx Rx Sim")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
        	self.GetWin(),
        	title='Constellation Plot',
        	sample_rate=samp_rate,
        	frame_rate=5,
        	const_size=2048,
        	M=4,
        	theta=0,
        	loop_bw=6.28/100.0,
        	fmax=0.06,
        	mu=0.5,
        	gain_mu=0.005,
        	symbol_rate=samp_rate/4.,
        	omega_limit=0.005,
        )
        self.Add(self.wxgui_constellationsink2_0.win)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=2,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=2,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0.0,
        	frequency_offset=0.0,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, '224.0.0.88', 26363, 1472, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/steve-wang/test.txt', True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/home/steve-wang/rx.txt', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=1,
        		bits_per_symbol=1,
        		preamble='',
        		access_code='',
        		pad_for_usrp=False,
        	),
        	payload_length=1024,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code='',
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
        	),
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.wxgui_constellationsink2_0, 0))
Example #20
0
    def __init__(self,
                 bb_gain=20,
                 destination="localhost",
                 filter_width=20000,
                 freq=145e6,
                 freq_corr=0,
                 gpredict_port=4532,
                 if_gain=20,
                 offset=40e3,
                 port=7355,
                 rf_gain=40):
        gr.top_block.__init__(
            self, "FM/FSK receiver for a FUNcube Dongle Pro+ device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.destination = destination
        self.filter_width = filter_width
        self.freq = freq
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.offset = offset
        self.port = port
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 192e3
        self.doppler_freq = doppler_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq,
                                                   "localhost", 4532, False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            4, (firdes.low_pass(1, samp_rate, filter_width / 2.0,
                                filter_width / 20.0)),
            doppler_freq - freq + offset, samp_rate)
        self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("", 1)
        self.fcdproplus_fcdproplus_0.set_lna(0)
        self.fcdproplus_fcdproplus_0.set_mixer_gain(0)
        self.fcdproplus_fcdproplus_0.set_if_gain(0)
        self.fcdproplus_fcdproplus_0.set_freq_corr(0)
        self.fcdproplus_fcdproplus_0.set_freq(freq - offset)

        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 destination, port, 1472, True)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.2)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_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.fcdproplus_fcdproplus_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
Example #21
0
    def __init__(self):
        gr.top_block.__init__(self, "DVB-S Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DVB-S Simulation")
        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", "dvbs_final")

        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.nfilts = nfilts = 100
        self.SampSymb = SampSymb = 4
        self.samp_rate = samp_rate = 6e6
        self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(SampSymb), 0.35, 45 * nfilts)
        self.qpsk_const = qpsk_const = digital.constellation_rect(
            [-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j], [0, 1, 2, 3], 4, 2, 2, 1,
            1).base()
        self.delay = delay = 0
        self.Noise = Noise = 0
        self.FreqOff = FreqOff = 0

        ##################################################
        # Blocks
        ##################################################
        self._delay_range = Range(0, 100, 1, 0, 200)
        self._delay_win = RangeWidget(self._delay_range, self.set_delay,
                                      'Delay', "counter_slider", float)
        self.top_grid_layout.addWidget(self._delay_win)
        self._Noise_range = Range(0, 1, 0.01, 0, 200)
        self._Noise_win = RangeWidget(self._Noise_range, self.set_Noise,
                                      'Channel Noise', "counter_slider", float)
        self.top_grid_layout.addWidget(self._Noise_win)
        self._FreqOff_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._FreqOff_win = RangeWidget(self._FreqOff_range, self.set_FreqOff,
                                        'Frequency Offset', "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._FreqOff_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        labels = [
            'RX', 'TX', '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:
                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)
        self.dtv_dvbt_viterbi_decoder_0 = dtv.dvbt_viterbi_decoder(
            dtv.MOD_QPSK, dtv.NH, dtv.C5_6, 1512 * 4)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_reed_solomon_dec_0 = dtv.dvbt_reed_solomon_dec(
            2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder(
            1, 1512 * 4, dtv.MOD_QPSK, dtv.NH, dtv.C5_6)
        self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1)
        self.dtv_dvbt_energy_descramble_0 = dtv.dvbt_energy_descramble(8)
        self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver(
            136, 12, 17)
        self.dtv_dvbt_convolutional_deinterleaver_0 = dtv.dvbt_convolutional_deinterleaver(
            136, 12, 17)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            SampSymb, 0.1, rrc_taps_0, nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.1, 4, False)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk_const,
            differential=True,
            samples_per_symbol=SampSymb,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, .01, 2)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=Noise,
            frequency_offset=FreqOff,
            epsilon=1.0,
            taps=[1.0 + 1.0j],
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, 1512 * 4)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 '127.0.0.1', 4321, 1316, True)
        self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, 8)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, delay)
        self.Video_Source = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/quique/Documents/PSK-Simulation/DVB_Codification/DVB_Codification/Test_Video.ts',
            False, 0, 0)
        self.Video_Source.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Video_Source, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.blocks_skiphead_0, 0),
                     (self.dtv_dvbt_viterbi_decoder_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_uchar_to_float_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.dtv_dvbt_energy_dispersal_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_uchar_to_float_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.dtv_dvbt_convolutional_deinterleaver_0, 0),
                     (self.dtv_dvbt_reed_solomon_dec_0, 0))
        self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0),
                     (self.dtv_dvbt_inner_coder_0, 0))
        self.connect((self.dtv_dvbt_energy_descramble_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.dtv_dvbt_energy_descramble_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.dtv_dvbt_energy_dispersal_0, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.dtv_dvbt_inner_coder_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_dec_0, 0),
                     (self.dtv_dvbt_energy_descramble_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.dtv_dvbt_convolutional_interleaver_0, 0))
        self.connect((self.dtv_dvbt_viterbi_decoder_0, 0),
                     (self.dtv_dvbt_convolutional_deinterleaver_0, 0))
Example #22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=570e6,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=-50,
        	ref_scale=2.0,
        	sample_rate=10e6,
        	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.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=64,
                decimation=70,
                taps=None,
                fractional_bw=None,
        )
        self.fft_vxx_0 = fft.fft_vcc(2048, True, (window.rectangular(2048)), True, 1)
        self.dvbt_viterbi_decoder_0 = dvbt.viterbi_decoder(dvbt.QAM16, dvbt.NH, dvbt.C1_2, 768, 0, -1)
        self.dvbt_symbol_inner_interleaver_0 = dvbt.symbol_inner_interleaver(1512, dvbt.T2k, 0)
        self.dvbt_reed_solomon_dec_0 = dvbt.reed_solomon_dec(2, 8, 0x11d, 255, 239, 8, 51, 8)
        self.dvbt_ofdm_sym_acquisition_0 = dvbt.ofdm_sym_acquisition(1, 2048, 1705, 64, 30)
        self.dvbt_energy_descramble_0 = dvbt.energy_descramble(8)
        self.dvbt_dvbt_demap_0 = dvbt.dvbt_demap(1512, dvbt.QAM16, dvbt.NH, dvbt.T2k, 1)
        self.dvbt_demod_reference_signals_0 = dvbt.demod_reference_signals(gr.sizeof_gr_complex, 2048, 1512, dvbt.QAM16, dvbt.NH, dvbt.C1_2, dvbt.C1_2, dvbt.G1_32, dvbt.T2k, 0, 0)
        self.dvbt_convolutional_deinterleaver_0 = dvbt.convolutional_deinterleaver(136, 12, 17)
        self.dvbt_bit_inner_deinterleaver_0 = dvbt.bit_inner_deinterleaver(1512, dvbt.QAM16, dvbt.NH, dvbt.T2k)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_char*1, 1512)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, "192.168.10.201", 5002, 1472, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.0022097087, ))
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "testBB.bin", False)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.000, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.dvbt_demod_reference_signals_0, 0), (self.dvbt_dvbt_demap_0, 0))
        self.connect((self.dvbt_dvbt_demap_0, 0), (self.dvbt_symbol_inner_interleaver_0, 0))
        self.connect((self.dvbt_symbol_inner_interleaver_0, 0), (self.dvbt_bit_inner_deinterleaver_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.dvbt_demod_reference_signals_0, 0))
        self.connect((self.dvbt_ofdm_sym_acquisition_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.dvbt_convolutional_deinterleaver_0, 0), (self.dvbt_reed_solomon_dec_0, 0))
        self.connect((self.dvbt_bit_inner_deinterleaver_0, 0), (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_vector_to_stream_1, 0), (self.dvbt_viterbi_decoder_0, 0))
        self.connect((self.dvbt_viterbi_decoder_0, 0), (self.dvbt_convolutional_deinterleaver_0, 0))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.dvbt_ofdm_sym_acquisition_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.dvbt_reed_solomon_dec_0, 0), (self.dvbt_energy_descramble_0, 0))
        self.connect((self.dvbt_energy_descramble_0, 0), (self.blocks_udp_sink_0, 0))
Example #23
0
    def __init__(self, address="addr=192.168.10.3", port=65500, seed1=108):
        gr.top_block.__init__(self, "Ue")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ue")
        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", "UE")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.address = address
        self.port = port
        self.seed1 = seed1

        ##################################################
        # Variables
        ##################################################
        self.seed2 = seed2 = seed1 + 384
        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.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.seed6 = seed6 = seed1 + 4590
        self.seed5 = seed5 = seed2 + 851
        self.seed4 = seed4 = seed1 + 9027
        self.seed3 = seed3 = seed1 + 2791
        self.samp_rate = samp_rate = 500000
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.packet_len = packet_len = 12
        self.noise_power = noise_power = 0
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        self.h_2 = h_2 = 0
        self.h_1 = h_1 = 0
        self.h_0 = h_0 = 1

        ##################################################
        # Blocks
        ##################################################
        self.s_2 = blocks.probe_signal_c()
        self.s_1 = blocks.probe_signal_c()
        self.s_0 = blocks.probe_signal_c()
        self.noise_variance = blocks.probe_signal_f()

        def _noise_power_probe():
            while True:
                val = self.noise_variance.level()
                try:
                    self.set_noise_power(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _noise_power_thread = threading.Thread(target=_noise_power_probe)
        _noise_power_thread.daemon = True
        _noise_power_thread.start()

        def _h_2_probe():
            while True:
                val = self.s_2.level()
                try:
                    self.set_h_2(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _h_2_thread = threading.Thread(target=_h_2_probe)
        _h_2_thread.daemon = True
        _h_2_thread.start()

        def _h_1_probe():
            while True:
                val = self.s_1.level()
                try:
                    self.set_h_1(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _h_1_thread = threading.Thread(target=_h_1_probe)
        _h_1_thread.daemon = True
        _h_1_thread.start()

        def _h_0_probe():
            while True:
                val = self.s_0.level()
                try:
                    self.set_h_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _h_0_thread = threading.Thread(target=_h_0_probe)
        _h_0_thread.daemon = True
        _h_0_thread.start()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((address, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(450e6, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

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

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

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

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

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)

        if complex == type(float()):
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.projectGT_variance_cc_0 = projectGT.variance_cc(5000)
        self.projectGT_IA_vectors_vcvc_0 = projectGT.IA_vectors_vcvc(
            fft_len, noise_power, 1, 2, (15, 25, 40, 45), length_tag_key)
        self.ofdm_rx_phase_1_0 = ofdm_rx_phase_1(
            pilot_symbols=pilot_symbols,
            header_mod=header_mod,
            payload_mod=payload_mod,
            sync_word2=sync_word2,
            sync_word1=sync_word1,
            fft_len=fft_len,
            packet_len=packet_len,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            samp_rate=samp_rate,
        )
        self.channels_channel_model_4_0 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed6,
            block_tags=False)
        self.channels_channel_model_4 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed4,
            block_tags=False)
        self.channels_channel_model_3_0 = channels.channel_model(
            noise_voltage=0.05,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed5,
            block_tags=False)
        self.channels_channel_model_3 = channels.channel_model(
            noise_voltage=0.1,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed3,
            block_tags=False)
        self.channels_channel_model_2 = channels.channel_model(
            noise_voltage=0.11,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed2,
            block_tags=False)
        self.channels_channel_model_1 = channels.channel_model(
            noise_voltage=0.12,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=seed1,
            block_tags=False)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.000,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=((h_0, h_1, h_2)),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_len)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, fft_len)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 "134.214.146.135", port, 1472,
                                                 True)
        self.blocks_tag_debug_3 = blocks.tag_debug(gr.sizeof_gr_complex * 1,
                                                   "IA", "")
        self.blocks_tag_debug_3.set_display(True)
        self.blocks_tag_debug_1 = blocks.tag_debug(
            gr.sizeof_gr_complex * fft_len, "chnl_intrf", "")
        self.blocks_tag_debug_1.set_display(False)
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1,
                                                   "Payload_intrf", "")
        self.blocks_tag_debug_0.set_display(False)
        self.blocks_null_source_3_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                         1)
        self.blocks_null_source_3 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_source_2_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                         1)
        self.blocks_null_source_2 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_source_1 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex *
                                                       1)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_3_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_3 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_2_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_2 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_const_vxx_1_0 = blocks.add_const_vcc((0.0, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vcc((0.1, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.8, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0), (self.s_0, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.s_1, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.s_2, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_mag_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_complex_to_mag_2, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_complex_to_mag_2_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_complex_to_mag_3, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_complex_to_mag_3_0, 0),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_add_const_vxx_1_0, 0))
        self.connect((self.blocks_null_source_0, 0),
                     (self.channels_channel_model_1, 0))
        self.connect((self.blocks_null_source_1, 0),
                     (self.channels_channel_model_2, 0))
        self.connect((self.blocks_null_source_2, 0),
                     (self.channels_channel_model_3, 0))
        self.connect((self.blocks_null_source_2_0, 0),
                     (self.channels_channel_model_3_0, 0))
        self.connect((self.blocks_null_source_3, 0),
                     (self.channels_channel_model_4, 0))
        self.connect((self.blocks_null_source_3_0, 0),
                     (self.channels_channel_model_4_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_vector_to_stream_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.ofdm_rx_phase_1_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.projectGT_variance_cc_0, 0))
        self.connect((self.channels_channel_model_1, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.channels_channel_model_2, 0),
                     (self.blocks_complex_to_mag_1, 0))
        self.connect((self.channels_channel_model_3, 0),
                     (self.blocks_complex_to_mag_2, 0))
        self.connect((self.channels_channel_model_3_0, 0),
                     (self.blocks_complex_to_mag_2_0, 0))
        self.connect((self.channels_channel_model_4, 0),
                     (self.blocks_complex_to_mag_3, 0))
        self.connect((self.channels_channel_model_4_0, 0),
                     (self.blocks_complex_to_mag_3_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 2), (self.blocks_tag_debug_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 0), (self.blocks_tag_debug_1, 0))
        self.connect((self.ofdm_rx_phase_1_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 1),
                     (self.blocks_vector_to_stream_1, 0))
        self.connect((self.projectGT_IA_vectors_vcvc_0, 0),
                     (self.blocks_tag_debug_3, 0))
        self.connect((self.projectGT_IA_vectors_vcvc_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.projectGT_variance_cc_0, 0),
                     (self.noise_variance, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 1),
                     (self.projectGT_IA_vectors_vcvc_0, 0))
        self.connect((self.ofdm_rx_phase_1_0, 0),
                     (self.projectGT_IA_vectors_vcvc_0, 1))
    def __init__(self):
        gr.top_block.__init__(self, "SIMONES_Occupation")
        
        ##################################################
        # Variables
        ##################################################
        self.fft_size = fft_size = 1024
        self.samp_rate = samp_rate = 20e6
        self.fft_window = fft_window = window.blackmanharris(fft_size)
        self.power = power = sum(x*x for x in fft_window)
        self.center_freq = center_freq = 98e6
        self.bandwidth = bandwidth = samp_rate
        self.stop_freq = stop_freq = center_freq+(bandwidth/2)
        self.start_freq = start_freq = center_freq-(bandwidth/2)
        self.simon_port = simon_port = 65123
        self.simon_ip = simon_ip = '127.0.0.1'
        self.server_port = server_port = 65234
        self.server_ip = server_ip = '127.0.0.1'
        self.n = n = max(1, int(samp_rate/fft_size/15L))
        self.k = k = -20*math.log10(fft_size)-10*math.log10(power/fft_size)-20*math.log10(2.0/2)
        self.device = device = 'bladerf,fpga=/home/i2t/Software/source/bladeRF/pre-built/hostedx115.rbf,xb200=auto'
        self.canalization = canalization = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer((simon_ip, simon_port), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0, fft_size)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + device )
        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(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(bandwidth, 0)
          
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (fft_window), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_size)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float*1, server_ip, server_port, 1472, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        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(20, fft_size, k)
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*fft_size, n)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1024)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_udp_sink_0, 0))
Example #25
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))
Example #26
0
    def __init__(self,
                 bb_gain=20,
                 destination='localhost',
                 freq=145e6,
                 freq_corr=0,
                 gpredict_port=4532,
                 if_gain=20,
                 offset=30e3,
                 port=7355,
                 rf_gain=40):
        gr.top_block.__init__(self,
                              "SSB receiver for a FUNcube Dongle Pro+ device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.destination = destination
        self.freq = freq
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.offset = offset
        self.port = port
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 192e3
        self.doppler_freq = doppler_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.gpredict_doppler_0 = gpredict.doppler('localhost', gpredict_port,
                                                   False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            4, firdes.low_pass(1, samp_rate, 1500, 500),
            doppler_freq - freq + offset, samp_rate)
        self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus('', 1)
        self.fcdproplus_fcdproplus_0.set_lna(0)
        self.fcdproplus_fcdproplus_0.set_mixer_gain(0)
        self.fcdproplus_fcdproplus_0.set_if_gain(0)
        self.fcdproplus_fcdproplus_0.set_freq_corr(0)
        self.fcdproplus_fcdproplus_0.set_freq(freq - offset)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 destination, port, 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            48000, analog.GR_COS_WAVE, 1500, 1, 0, 0)

        ##################################################
        # Connections
        ##################################################
        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.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_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.fcdproplus_fcdproplus_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 1))
    def __init__(self,
                 bb_gain=20,
                 destination='localhost',
                 freq=0,
                 freq_corr=0,
                 gpredict_port=4532,
                 if_gain=20,
                 offset=50e3,
                 port=7355,
                 rf_gain=40):
        gr.top_block.__init__(self, "Wide SSB receiver for an RTL-SDR device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.destination = destination
        self.freq = freq
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.offset = offset
        self.port = port
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.4e6
        self.doppler_freq = doppler_freq = freq

        ##################################################
        # Blocks
        ##################################################
        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(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq - offset, 0)
        self.osmosdr_source_0.set_freq_corr(freq_corr, 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(0, 0)
        self.gpredict_doppler_0 = gpredict.doppler('localhost', gpredict_port,
                                                   False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            50, firdes.low_pass(1, samp_rate, 12000, 500),
            doppler_freq - freq + offset, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 destination, port, 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            48000, analog.GR_COS_WAVE, 12000, 1, 0, 0)

        ##################################################
        # Connections
        ##################################################
        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.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_multiply_xx_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
Example #28
0
    def __init__(self,
                 baudrate=1200.0,
                 raw_file='',
                 udp_dest_audio='127.0.0.1',
                 udp_dest_iq='127.0.0.1',
                 udp_port_audio=7355,
                 udp_port_iq=7356):
        gr.top_block.__init__(self, "satnogs raw to udp")

        ##################################################
        # Parameters
        ##################################################
        self.baudrate = baudrate
        self.raw_file = raw_file
        self.udp_dest_audio = udp_dest_audio
        self.udp_dest_iq = udp_dest_iq
        self.udp_port_audio = udp_port_audio
        self.udp_port_iq = udp_port_iq

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.audio_samp_rate = audio_samp_rate = 48000
        self.if_freq = if_freq = 12000
        self.decimation = decimation = satnogs.find_decimation(
            baudrate, 2, audio_samp_rate, sps)

        ##################################################
        # Blocks
        ##################################################
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            audio_samp_rate / (baudrate * decimation), taps=None, flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, audio_samp_rate, 0.42 * audio_samp_rate / 2.0,
                            0.05 * audio_samp_rate, firdes.WIN_HAMMING, 6.76))
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                   udp_dest_iq, udp_port_iq,
                                                   1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 udp_dest_audio,
                                                 udp_port_audio, 1472, True)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 baudrate * decimation, True)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            2.0 * math.pi * (if_freq / audio_samp_rate))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(16383)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(1 / 16768)
        self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex(
            False, False)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16383.0)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short * 1,
                                                       raw_file, False, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_interleaved_short_0 = blocks.complex_to_interleaved_short(
            False)
        self.analog_agc2_xx_0_1 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0)
        self.analog_agc2_xx_0_1.set_max_gain(65536)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-2, 1e-3, 1.5e-2, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.analog_agc2_xx_0_1, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_complex_to_interleaved_short_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_interleaved_short_to_complex_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_interleaved_short_to_complex_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_complex_to_interleaved_short_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_throttle_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_throttle_1, 0), (self.analog_agc2_xx_0_1, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
Example #29
0
    def __init__(self, antenna="", bb_freq=0.0, bw=0.0, dc_removal="False", decoded_data_file_path="/tmp/.satnogs/data/data", dev_args="", doppler_correction_per_sec=20, enable_iq_dump=0, file_path="test.wav", gain=0.0, gain_mode="Overall", iq_file_path="/tmp/iq.dat", lo_offset=100e3, other_settings="", ppm=0, rigctl_port=4532, rx_freq=100e6, samp_rate_rx=0.0, soapy_rx_device="driver=invalid", stream_args="", tune_args="", udp_IP="127.0.0.1", udp_dump_dest='127.0.0.1', udp_dump_port=7355, udp_port=16887, waterfall_file_path="/tmp/waterfall.dat"):
        gr.top_block.__init__(self, "AMSAT FOX DUV Decoder")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.bb_freq = bb_freq
        self.bw = bw
        self.dc_removal = dc_removal
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.file_path = file_path
        self.gain = gain
        self.gain_mode = gain_mode
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.other_settings = other_settings
        self.ppm = ppm
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.samp_rate_rx = samp_rate_rx
        self.soapy_rx_device = soapy_rx_device
        self.stream_args = stream_args
        self.tune_args = tune_args
        self.udp_IP = udp_IP
        self.udp_dump_dest = udp_dump_dest
        self.udp_dump_port = udp_dump_port
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.variable_amsat_duv_decoder_0 = variable_amsat_duv_decoder_0 = satnogs.amsat_duv_decoder_make('0011111010', 96)
        self.max_modulation_freq = max_modulation_freq = 3000
        self.deviation = deviation = 5000
        self.audio_samp_rate = audio_samp_rate = 48000

        ##################################################
        # Blocks
        ##################################################
        self.soapy_source_0_0 = None
        # Make sure that the gain mode is valid
        if(gain_mode not in ['Overall', 'Specific', 'Settings Field']):
            raise ValueError("Wrong gain mode on channel 0. Allowed gain modes: "
                  "['Overall', 'Specific', 'Settings Field']")

        dev = soapy_rx_device

        # Stream arguments for every activated stream
        tune_args = [tune_args]
        settings = [other_settings]

        # Setup the device arguments
        dev_args = dev_args

        self.soapy_source_0_0 = soapy.source(1, dev, dev_args, stream_args,
                                  tune_args, settings, samp_rate_rx, "fc32")



        self.soapy_source_0_0.set_dc_removal(0,bool(distutils.util.strtobool(dc_removal)))

        # Set up DC offset. If set to (0, 0) internally the source block
        # will handle the case if no DC offset correction is supported
        self.soapy_source_0_0.set_dc_offset(0,0)

        # Setup IQ Balance. If set to (0, 0) internally the source block
        # will handle the case if no IQ balance correction is supported
        self.soapy_source_0_0.set_iq_balance(0,0)

        self.soapy_source_0_0.set_agc(0,False)

        # generic frequency setting should be specified first
        self.soapy_source_0_0.set_frequency(0, rx_freq - lo_offset)

        self.soapy_source_0_0.set_frequency(0,"BB",bb_freq)

        # Setup Frequency correction. If set to 0 internally the source block
        # will handle the case if no frequency correction is supported
        self.soapy_source_0_0.set_frequency_correction(0,ppm)

        self.soapy_source_0_0.set_antenna(0,antenna)

        self.soapy_source_0_0.set_bandwidth(0,bw)

        if(gain_mode != 'Settings Field'):
            # pass is needed, in case the template does not evaluare anything
            pass
            self.soapy_source_0_0.set_gain(0,gain)
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(audio_samp_rate, rx_freq, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, int(1000.0/doppler_correction_per_sec) + 1, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, audio_samp_rate, 1.0)
        self.satnogs_json_converter_0 = satnogs.json_converter()
        self.satnogs_iq_sink_0 = satnogs.iq_sink(16768, iq_file_path, False, enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(decoded_data_file_path, 0)
        self.satnogs_frame_decoder_0 = satnogs.frame_decoder(variable_amsat_duv_decoder_0, 1 * 1)
        self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(samp_rate_rx, rx_freq, lo_offset, audio_samp_rate, 1, 0)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(
            1,
            firdes.root_raised_cosine(
                1,
                1,
                2.4,
                0.5,
                512))
        self.low_pass_filter_1 = filter.fir_filter_fff(
            100,
            firdes.low_pass(
                1,
                audio_samp_rate,
                195,
                10,
                firdes.WIN_HAMMING,
                6.76))
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(
                1,
                audio_samp_rate,
                max_modulation_freq,
                1000,
                firdes.WIN_HAMMING,
                6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(
                1,
                audio_samp_rate,
                max_modulation_freq,
                1000,
                firdes.WIN_HAMMING,
                6.76))
        self.digital_clock_recovery_mm_xx_0_0_0 = digital.clock_recovery_mm_ff((audio_samp_rate/100.0) / 200, 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True)
        self.blocks_vco_c_0 = blocks.vco_c(audio_samp_rate, -audio_samp_rate, 1.0)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, udp_dump_dest, udp_dump_port+1, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, udp_dump_dest, udp_dump_port, 1472, True)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(1024, 1.0/1024.0, 4096, 1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16383.0)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(1024/2))
        self.analog_quadrature_demod_cf_0_0_0_0 = analog.quadrature_demod_cf(1.0)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1.2)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.9)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_frame_decoder_0, 'out'), (self.satnogs_json_converter_0, 'in'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'), (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'), (self.satnogs_doppler_compensation_0, 'doppler'))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_float_to_short_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0_0_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (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_moving_average_xx_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.dc_blocker_xx_0, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.satnogs_frame_decoder_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0_0, 0), (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0_0_0_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_clock_recovery_mm_xx_0_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.blocks_udp_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_iq_sink_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0), (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.soapy_source_0_0, 0), (self.satnogs_doppler_compensation_0, 0))
    def __init__(self, args):
        gr.top_block.__init__(self, "E310 Rx remote")

        ##################################################
        # Parameters
        ##################################################
        self.args = args

        self.verbose = args.verbose
        self.prefix = args.prefix = None
        self.sample_rate = args.samp_rate

        #    UHD Radio Receiver Parameters
        self.antenna = args.antenna
        self.freq = args.freq
        self.gain = args.gain
        self.gain_type = args.gain_type
        self.spec = args.spec
        self.stream_args = args.stream_args
        self.wire_format = args.otw_format
        self.dc_offset_auto = args.dc_offset_auto
        self.dc_offset = args.dc_offset

        #    Network Connections Parameters
        self.UDP_data_port = args.UDP_data_port
        self.TCP_ctrl_port = args.TCP_ctrl_port
        self.ip_address = args.ip_address
        if args.network:
            self.ip_address = args.ip_address
        elif args.loopback:
            self.ip_address = IP_loopback

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

        self.usrp_device_info = "[No USRP Device Info Found!]"
        self.uhd_version_info = uhd.get_version_string()

        ##################################################
        # Blocks
        ##################################################
        self.setup_usrp(uhd.usrp_source, args)
        self._ant_options = self.usrp.get_antennas(self.channels[0])

        #self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.usrp.set_subdev_spec('A:A', 0)
        self.usrp.set_samp_rate(self.samp_rate)
        self.usrp.set_center_freq(self.freq, 0)
        self.usrp.set_gain(self.gain, 0)
        self.usrp.set_antenna('TX/RX', 0)
        self.usrp_device_info = self.get_usrp_info_string(compact=True,
                                                          tx_or_rx='rx')
        self.bandwidth = self.usrp.get_bandwidth(0)

        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 self.ip_address,
                                                 self.UDP_data_port, 1472,
                                                 True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.usrp, 0), (self.blocks_udp_sink_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Lab 7 Task 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Lab 7 Task 1")
        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", "lab7_task1")

        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.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.45
        self.tx_taps = tx_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate = samp_rate = 320000
        self.rx_taps = rx_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, 0.4, ntaps)
        self.const_points = const_points = 4

        ##################################################
        # 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, 'QPSK Signal with Frequency Offset')
        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, 'QPSK Carrier Phase Detector')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'UDP Source Output')
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, 'Output of Costas Loop')
        self.top_grid_layout.addWidget(self.tab)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #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(-1, 1)

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

        self.qtgui_time_sink_x_1.enable_tags(True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        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(False)
        self.qtgui_time_sink_x_1.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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            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.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            2000,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        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(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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_3.addWidget(self._qtgui_const_sink_x_0_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(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=tx_taps,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1.0001, -1], [-1, 1],
                                                        True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd([0.01], [-1, 0.99], True)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            4, timing_bw, rx_taps, 32, 16, 1.5, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            4, timing_bw, rx_taps, 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ((1 - 1j), (1 + 1j), (-1 + 1j), (-1 - 1j)), 1)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1,
                                                     '127.0.0.1', 12345, 1472,
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1,
                                                 '127.0.0.1', 12345, 1472,
                                                 True)
        self.blocks_throttle_1_0 = blocks.throttle(gr.sizeof_float * 1,
                                                   samp_rate, True)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.2)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 10)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(-0.5)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 0.1, 1, 0, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            list(map(int, numpy.random.randint(0, 4, 1000))), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_complex_to_imag_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_throttle_1_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_complex_to_imag_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.blocks_throttle_1, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_1_0, 0),
                     (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_throttle_1_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_throttle_1, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
Example #32
0
    def __init__(self, bb_gain=20, destination="localhost", freq=0, freq_corr=0, gpredict_port=4532, if_gain=20, offset=50e3, port=7355, rf_gain=40):
        gr.top_block.__init__(self, "Wide SSB receiver for an Airspy device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.destination = destination
        self.freq = freq
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.offset = offset
        self.port = port
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e6
        self.doppler_freq = doppler_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=24,
                decimation=25,
                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(freq-offset, 0)
        self.osmosdr_source_0.set_freq_corr(freq_corr, 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(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(0, 0)
          
        self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, False)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1, samp_rate, 12000, 500)), doppler_freq-freq+offset, samp_rate)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, destination, port, 1472, True)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(48000, analog.GR_COS_WAVE, 12000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        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.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_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 1))    
Example #33
0
    def __init__(self, ampl=0.7, args='', mtu=255, port="12345", rate=1e6, rx_antenna="TX/RX", rx_freq=420e6, rx_gain=0, rx_lo_offset=0, samps_per_sym=4, tx_freq=440e6, tx_gain=20, tx_lo_offset=0):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.ampl = ampl
        self.args = args
        self.mtu = mtu
        self.port = port
        self.rate = rate
        self.rx_antenna = rx_antenna
        self.rx_freq = rx_freq
        self.rx_gain = rx_gain
        self.rx_lo_offset = rx_lo_offset
        self.samps_per_sym = samps_per_sym
        self.tx_freq = tx_freq
        self.tx_gain = tx_gain
        self.tx_lo_offset = tx_lo_offset

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 500000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", args)),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0.set_bandwidth(2*samp_rate, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", args)),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(2*samp_rate, 0)
        self.ofdm_radio_0 = ofdm_radio(
            rate=1e6,
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, "127.0.0.1", 12346, 1470, True)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", port, mtu, False)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "length")
        self.blocks_message_debug_0_0_1 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ofdm_radio_0, 'msg_in'))    
        self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_message_debug_0_0_1, 'print_pdu'))    
        self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.ofdm_radio_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.ofdm_radio_0, 0))    
Example #34
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 #35
0
    def __init__(self,
                 antenna="",
                 baudrate=9600.0,
                 bb_freq=0.0,
                 bw=0.0,
                 dc_removal="False",
                 decoded_data_file_path="/tmp/.satnogs/data/data",
                 dev_args="",
                 doppler_correction_per_sec=20,
                 enable_iq_dump=0,
                 excess_bw=0.5,
                 file_path="test.wav",
                 framing="ax25",
                 gain=0.0,
                 gain_mode="Overall",
                 iq_file_path="/tmp/iq.dat",
                 lo_offset=100e3,
                 max_cfo=2000.0,
                 other_settings="",
                 ppm=0,
                 rigctl_port=4532,
                 rx_freq=100e6,
                 samp_rate_rx=0.0,
                 soapy_rx_device="driver=invalid",
                 stream_args="",
                 tune_args="",
                 udp_IP="127.0.0.1",
                 udp_dump_dest='127.0.0.1',
                 udp_dump_port=7355,
                 udp_port=16887,
                 waterfall_file_path="/tmp/waterfall.dat"):
        gr.top_block.__init__(self, "satnogs_bpsk")

        ##################################################
        # Parameters
        ##################################################
        self.antenna = antenna
        self.baudrate = baudrate
        self.bb_freq = bb_freq
        self.bw = bw
        self.dc_removal = dc_removal
        self.decoded_data_file_path = decoded_data_file_path
        self.dev_args = dev_args
        self.doppler_correction_per_sec = doppler_correction_per_sec
        self.enable_iq_dump = enable_iq_dump
        self.excess_bw = excess_bw
        self.file_path = file_path
        self.framing = framing
        self.gain = gain
        self.gain_mode = gain_mode
        self.iq_file_path = iq_file_path
        self.lo_offset = lo_offset
        self.max_cfo = max_cfo
        self.other_settings = other_settings
        self.ppm = ppm
        self.rigctl_port = rigctl_port
        self.rx_freq = rx_freq
        self.samp_rate_rx = samp_rate_rx
        self.soapy_rx_device = soapy_rx_device
        self.stream_args = stream_args
        self.tune_args = tune_args
        self.udp_IP = udp_IP
        self.udp_dump_dest = udp_dump_dest
        self.udp_dump_port = udp_dump_port
        self.udp_port = udp_port
        self.waterfall_file_path = waterfall_file_path

        ##################################################
        # Variables
        ##################################################
        self.variable_ax25_decoder_0 = variable_ax25_decoder_0 = satnogs.ax25_decoder_make(
            'GND', 0, True, True, True, 1024)
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.audio_samp_rate = audio_samp_rate = 48000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts)
        self.if_freq = if_freq = 12000
        self.decimation = decimation = satnogs.find_decimation(
            baudrate, 2, audio_samp_rate, sps)
        self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk(
        ).base()
        self.available_framings = available_framings = {
            'ax25': variable_ax25_decoder_0
        }

        ##################################################
        # Blocks
        ##################################################
        self.soapy_source_0 = None
        # Make sure that the gain mode is valid
        if (gain_mode not in ['Overall', 'Specific', 'Settings Field']):
            raise ValueError(
                "Wrong gain mode on channel 0. Allowed gain modes: "
                "['Overall', 'Specific', 'Settings Field']")

        dev = soapy_rx_device

        # Stream arguments for every activated stream
        tune_args = [tune_args]
        settings = [other_settings]

        # Setup the device arguments
        dev_args = dev_args

        self.soapy_source_0 = soapy.source(1, dev, dev_args, stream_args,
                                           tune_args, settings, samp_rate_rx,
                                           "fc32")

        self.soapy_source_0.set_dc_removal(
            0, bool(distutils.util.strtobool(dc_removal)))

        # Set up DC offset. If set to (0, 0) internally the source block
        # will handle the case if no DC offset correction is supported
        self.soapy_source_0.set_dc_offset(0, 0)

        # Setup IQ Balance. If set to (0, 0) internally the source block
        # will handle the case if no IQ balance correction is supported
        self.soapy_source_0.set_iq_balance(0, 0)

        self.soapy_source_0.set_agc(0, False)

        # generic frequency setting should be specified first
        self.soapy_source_0.set_frequency(0, rx_freq - lo_offset)

        self.soapy_source_0.set_frequency(0, "BB", bb_freq)

        # Setup Frequency correction. If set to 0 internally the source block
        # will handle the case if no frequency correction is supported
        self.soapy_source_0.set_frequency_correction(0, ppm)

        self.soapy_source_0.set_antenna(0, antenna)

        self.soapy_source_0.set_bandwidth(0, bw)

        if (gain_mode != 'Settings Field'):
            # pass is needed, in case the template does not evaluare anything
            pass
            self.soapy_source_0.set_gain(0, gain)
        self.satnogs_waterfall_sink_0_0 = satnogs.waterfall_sink(
            baudrate * decimation, rx_freq, 10, 1024, waterfall_file_path, 1)
        self.satnogs_udp_msg_sink_0_0 = satnogs.udp_msg_sink(
            udp_IP, udp_port, 1500)
        self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source(
            "127.0.0.1", rigctl_port, False,
            int(1000.0 / doppler_correction_per_sec) + 1, 1500)
        self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(
            file_path, audio_samp_rate, 1.0)
        self.satnogs_json_converter_0 = satnogs.json_converter()
        self.satnogs_iq_sink_0_0 = satnogs.iq_sink(16768, iq_file_path, False,
                                                   enable_iq_dump)
        self.satnogs_frame_file_sink_0_1_0 = satnogs.frame_file_sink(
            decoded_data_file_path, 0)
        self.satnogs_frame_decoder_0_0 = satnogs.frame_decoder(
            available_framings[framing], 1 * 1)
        self.satnogs_doppler_compensation_0 = satnogs.doppler_compensation(
            samp_rate_rx, rx_freq, lo_offset, baudrate * decimation, 1, 0)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            audio_samp_rate / (baudrate * decimation), taps=None, flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, audio_samp_rate, 0.42 * audio_samp_rate / 2.0,
                            0.05 * audio_samp_rate, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            decimation // sps,
            firdes.low_pass(
                1, baudrate * decimation,
                baudrate / 2 + excess_bw * baudrate / 2 + abs(max_cfo),
                baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 2.0 * math.pi / 100.0, rrc_taps, nfilts, nfilts / 2, 1.5, 1)
        self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(
            bpsk_constellation, 2.0 * math.pi / 100.0, -0.25, 0.25)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dump_dest,
                                                   udp_dump_port + 1, 1472,
                                                   True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short * 1,
                                                 udp_dump_dest, udp_dump_port,
                                                 1472, True)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            2.0 * math.pi * (if_freq / audio_samp_rate))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 16383.0)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_agc2_xx_0_0 = analog.agc2_cc(0.01, 0.001, 0.015, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-3, 1e-3, 0.5, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satnogs_frame_decoder_0_0, 'out'),
                         (self.satnogs_json_converter_0, 'in'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'),
                         (self.satnogs_frame_file_sink_0_1_0, 'frame'))
        self.msg_connect((self.satnogs_json_converter_0, 'out'),
                         (self.satnogs_udp_msg_sink_0_0, 'in'))
        self.msg_connect((self.satnogs_tcp_rigctl_msg_source_0, 'freq'),
                         (self.satnogs_doppler_compensation_0, 'doppler'))
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_agc2_xx_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.satnogs_ogg_encoder_0, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_constellation_receiver_cb_0, 0),
                     (self.satnogs_frame_decoder_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_constellation_receiver_cb_0, 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, 0),
                     (self.blocks_rotator_cc_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_iq_sink_0_0, 0))
        self.connect((self.satnogs_doppler_compensation_0, 0),
                     (self.satnogs_waterfall_sink_0_0, 0))
        self.connect((self.soapy_source_0, 0),
                     (self.satnogs_doppler_compensation_0, 0))
Example #36
0
    def __init__(self):
        gr.top_block.__init__(self, "Tetra Rx Multi")

        options = self.get_options()

        self.src = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/myout1.ch", False)

        ##################################################
        # Variables
        ##################################################
        self.srate_rx = srate_rx = options.sample_rate
        self.channels = srate_rx / 25000
        self.srate_channel = 36000
        self.afc_period = 15
        self.afc_gain = 0.01
        self.afc_channel = options.auto_tune or -1
        self.afc_ppm_step = 100
        self.debug = options.debug
        self.last_pwr = -100000
        self.sig_det_period = 10
        self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx
        if self.sig_det_bw <= 1.:
            self.sig_det_bw *= srate_rx
        self.sig_det_threshold = options.sig_detection_threshold
        self.sig_det_channels = []
        for ch in range(self.channels):
            if ch >= self.channels / 2:
                ch_ = (self.channels - ch - 1)
            else:
                ch_ = ch
            if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx):
                self.sig_det_channels.append(ch)

        self.channels = 10

        ##################################################
        # RPC server
        ##################################################
        self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer(
                ("localhost", options.listen_port), allow_none=True)
        self.xmlrpc_server.register_instance(self)
        threading.Thread(target=self.xmlrpc_server.serve_forever).start()

        ##################################################
        # Rx Blocks and connections
        ##################################################

        out_type, dst_path = options.output.split("://", 1)
        if out_type == "udp":
            dst_ip, dst_port = dst_path.split(':', 1)

        self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1)

        self.squelch = []
        self.digital_mpsk_receiver_cc = []
        self.diff_phasor = []
        self.complex_to_arg = []
        self.multiply_const = []
        self.add_const = []
        self.float_to_uchar = []
        self.map_bits = []
        self.unpack_k_bits = []
        self.blocks_sink = []
        for ch in range(0, self.channels):
            mpsk = digital.mpsk_receiver_cc(
                    4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001)
            diff_phasor = digital.diff_phasor_cc()
            complex_to_arg = blocks.complex_to_arg(1)
            multiply_const = blocks.multiply_const_vff((2./math.pi, ))
            add_const = blocks.add_const_vff((1.5, ))
            float_to_uchar = blocks.float_to_uchar()
            map_bits = digital.map_bb(([3, 2, 0, 1, 3]))
            unpack_k_bits = blocks.unpack_k_bits_bb(2)

            brmchannels = [0,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,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]
            #brmchannels = [11,4,3,64,45,47,53,8,68,6,56,49,17,54,65,5,71,22,48,7,50] # itds kancl
            #brmchannels = [23,13,40,69,59,7,42,54,5,14,4,56,45,46,67,55,66,44,71,49,31,57,0,65,70] # doma - dole
            #brmchannels = [23,13,59,40,69,7,49,60,42,70,4,50,66,67,3,14,57,33,46,22,68,32,39,24,6,12,43,58,48,17,5,56,65,29,54,30,16,52,53,41,47,2,34,44,8] # doma - strecha
            #brmchannels = [67, 7, 23, 70] # doma - strecha - SDS
            #brmchannels = [67, 7, 23, 70,9,71,64,63,62,61,55,51,45,38,37,36,35,31,28,27,26,25,21,20,19,18,15,11,10,1,0] # doma - strecha - komplement


            if out_type == 'udp':
                sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True)
            elif out_type == 'file':
                sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False)
                sink.set_unbuffered(True)
            else:
                raise ValueError("Invalid output URL '%s'" % options.output)

            print "connect %i"%ch

            if ch in brmchannels:
                self.connect((self.blocks_deinterleave_0, ch),
                    #(squelch, 0),
                    (mpsk, 0),
                    (diff_phasor, 0),
                    (complex_to_arg, 0),
                    (multiply_const, 0),
                    (add_const, 0),
                    (float_to_uchar, 0),
                    (map_bits, 0),
                    (unpack_k_bits, 0),
                    (sink, 0))


            self.digital_mpsk_receiver_cc.append(mpsk)
            self.diff_phasor.append(diff_phasor)
            self.complex_to_arg.append(complex_to_arg)
            self.multiply_const.append(multiply_const)
            self.add_const.append(add_const)
            self.float_to_uchar.append(float_to_uchar)
            self.map_bits.append(map_bits)
            self.unpack_k_bits.append(unpack_k_bits)
            self.blocks_sink.append(sink)

        self.connect(
                (self.src, 0),
                (self.blocks_deinterleave_0, 0))

        ##################################################
        # signal strenght identification
        ##################################################
        '''
        self.pwr_probes = []
        for ch in range(self.channels):
            pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel)
            self.pwr_probes.append(pwr_probe)
            print "connect %i"%ch
            self.connect((self.blocks_deinterleave_0, ch), (pwr_probe, 0))
        def _sig_det_probe():
            while True:
                pwr = [self.pwr_probes[ch].level()
                        for ch in range(self.channels)
                        if ch in self.sig_det_channels]
                pwr = [10 * math.log10(p) for p in pwr if p > 0.]
                if not pwr:
                    continue
                pwr = min(pwr) + self.sig_det_threshold
                print "power threshold target %f"%pwr
                if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2):
                    for s in []:
                        s.set_threshold(pwr)
                    self.last_pwr = pwr
                time.sleep(self.sig_det_period)

        if self.sig_det_threshold is not None:
            self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe)
            self._sig_det_probe_thread.daemon = True
            self._sig_det_probe_thread.start()
        '''
        ##################################################
        # AFC blocks and connections
        ##################################################
        self.afc_selector = grc_blks2.selector(
                item_size=gr.sizeof_gr_complex,
                num_inputs=self.channels,
                num_outputs=1,
                input_index=0,
                output_index=0,
                )

        self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi))
        samp_afc = self.srate_channel*self.afc_period / 2
        self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain)
        self.afc_probe = blocks.probe_signal_f()

        def _afc_probe():
            rt = 0.0
            while True:
                time.sleep(self.afc_period)
                if self.afc_channel == -1:
                    continue
                err = self.afc_probe.level()
                freq = err * self.afc_gain
                print "err: %f\tfreq: %f\trt %f" % (err, freq, rt)
                changed = False
                if err < -1:
                    rt += 0.1
                    changed = True
                elif err > 1:
                    rt -= 0.1
                    changed = True

                if changed:
                    os.system("echo \"setrot %f\" | nc localhost 3333"%rt)


        self.afc_channel = 0
        self._afc_err_thread = threading.Thread(target=_afc_probe)
        self._afc_err_thread.daemon = True
        self._afc_err_thread.start()

        for ch in range(self.channels):
            print "connect %i"%ch
            self.connect((self.blocks_deinterleave_0, ch), (self.afc_selector, ch))
        self.connect(
                (self.afc_selector, 0),
                (self.afc_demod, 0),
                (self.afc_avg, 0),
                (self.afc_probe, 0))

        if self.afc_channel != -1:
            self.afc_selector.set_input_index(self.afc_channel)
    def __init__(self):
        gr.top_block.__init__(self, "TJ Cubesat No Gui with IQ streaming")

        ##################################################
        # Variables
        ##################################################
        self.interp = interp = 4
        self.audio_rate = audio_rate = 48000
        self.tx_gain = tx_gain = 10
        self.rx_downsamp_bw = rx_downsamp_bw = 10000
        self.rf_tx_rate = rf_tx_rate = audio_rate*interp
        self.rf_rx_rate = rf_rx_rate = 192000
        self.preamble_len = preamble_len = 300
        self.gain = gain = 40
        self.freq = freq = 144.39e6
        self.cubesat_zmq_port_4 = cubesat_zmq_port_4 = "5504"
        self.cubesat_zmq_port_3 = cubesat_zmq_port_3 = "5503"
        self.cubesat_zmq_port_2 = cubesat_zmq_port_2 = "5502"
        self.cubesat_zmq_port_1 = cubesat_zmq_port_1 = "5501"
        self.cubesat_port_2 = cubesat_port_2 = "5558"
        self.cubesat_port_1 = cubesat_port_1 = "5556"
        self.cubesat_ext_ip_addr = cubesat_ext_ip_addr = "192.168.1.10"
        self.baud_rate = baud_rate = 1200
        self.audio_line_driver = audio_line_driver = .8
        self.Decay = Decay = 0.8
        self.Attack = Attack = 0.8

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_sink_0_0_0_0 = zeromq.push_sink(gr.sizeof_float, 1, "tcp://"+cubesat_ext_ip_addr+":"+cubesat_zmq_port_4, 100, False, -1)
        self.zeromq_push_sink_0_0_0 = zeromq.push_sink(gr.sizeof_float, 1, "tcp://"+cubesat_ext_ip_addr+":"+cubesat_zmq_port_3, 100, False, -1)
        self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://"+cubesat_ext_ip_addr+":"+cubesat_zmq_port_2, 100, False, -1)
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://"+cubesat_ext_ip_addr+":"+cubesat_zmq_port_1, 100, False, -1)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('', 1234), 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.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(rf_rx_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_bandwidth(rf_rx_rate, 0)
        self.uhd_usrp_sink_0_1 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_1.set_samp_rate(rf_tx_rate)
        self.uhd_usrp_sink_0_1.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0_1.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0_1.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0_1.set_bandwidth(rf_tx_rate, 0)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc(
                interpolation=4,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.low_pass_filter_0 = filter.fir_filter_ccf(4, firdes.low_pass(
        	1, rf_rx_rate, rx_downsamp_bw/2, 1000, firdes.WIN_HAMMING, 6.76))
        self.detectMarkSpace_1_0 = detectMarkSpace(
            Frequency=2200,
            attack=Attack,
            decay=Decay,
            samp_rate=audio_rate,
        )
        self.detectMarkSpace_0_0 = detectMarkSpace(
            Frequency=1200,
            attack=Attack,
            decay=Decay,
            samp_rate=audio_rate,
        )
        self.bruninga_str_to_aprs_0_1 = bruninga.str_to_aprs('KN4DTQ', 'KN4DTQ', [])
        self.bruninga_ax25_fsk_mod_0_0 = bruninga.ax25_fsk_mod(audio_rate, preamble_len, 5, 2200, 1200, baud_rate)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char*1, '127.0.0.1', int(cubesat_port_1), 1472, True)
        self.blocks_sub_xx_0_0_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0_0_0_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', cubesat_port_2, 10000, False)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((audio_line_driver, ))
        self.analog_nbfm_tx_0_0 = analog.nbfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1.0,
                )
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate,
        	tau=75e-6,
        	max_dev=5e3,
          )
        self.afsk_ax25decode_1 = afsk.ax25decode(audio_rate, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_0_0_0, 'pdus'), (self.bruninga_str_to_aprs_0_1, 'in'))
        self.msg_connect((self.bruninga_str_to_aprs_0_1, 'out'), (self.bruninga_ax25_fsk_mod_0_0, 'in'))
        self.connect((self.afsk_ax25decode_1, 0), (self.blocks_udp_sink_0_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.detectMarkSpace_0_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.detectMarkSpace_1_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.zeromq_push_sink_0_0_0, 0))
        self.connect((self.analog_nbfm_tx_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.analog_nbfm_tx_0_0, 0))
        self.connect((self.blocks_sub_xx_0_0_0, 0), (self.afsk_ax25decode_1, 0))
        self.connect((self.bruninga_ax25_fsk_mod_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.bruninga_ax25_fsk_mod_0_0, 0), (self.zeromq_push_sink_0_0_0_0, 0))
        self.connect((self.detectMarkSpace_0_0, 0), (self.blocks_sub_xx_0_0_0, 0))
        self.connect((self.detectMarkSpace_1_0, 0), (self.blocks_sub_xx_0_0_0, 1))
        self.connect((self.low_pass_filter_0, 0), (self.analog_nbfm_rx_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.zeromq_push_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.uhd_usrp_sink_0_1, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.zeromq_push_sink_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
Example #38
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.sps = sps = 4
        self.ntaps = ntaps = 1408
        self.nfilts = nfilts = 32
        self.excess_bw = excess_bw = 0.45
        self.timing_bw = timing_bw = 2 * pi / 100
        self.sr2 = sr2 = 300000
        self.samp_rate_0 = samp_rate_0 = 32000
        self.samp_rate = samp_rate = 100000
        self.s = s = 0.01
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.freq_bw = freq_bw = 2 * pi / 100
        self.fll_ntaps = fll_ntaps = 55

        ##################################################
        # Blocks
        ##################################################
        self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab1")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab2")
        self.n.AddPage(grc_wxgui.Panel(self.n), "tab3")
        self.Add(self.n)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_c(
            self.n.GetPage(1).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_f(
            self.n.GetPage(0).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(0).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.n.GetPage(2).GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.n.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        _s_sizer = wx.BoxSizer(wx.VERTICAL)
        self._s_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            label="s",
            converter=forms.float_converter(),
            proportion=0,
        )
        self._s_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_s_sizer,
            value=self.s,
            callback=self.set_s,
            minimum=-5,
            maximum=5,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_s_sizer)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.45, 1408)), flt_size=32
        )
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_0_0 = filter.iir_filter_ffd(([1.0001, -1]), ([-1, 1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01,), ([-1, 0.99]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(4, 2 * pi / 100, (rx_taps), 32, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (((1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j))), 1
        )
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1,))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.413,))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.413,))
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1000)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5,))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5,))
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.iir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.blocks_vco_c_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_imag_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
Example #39
0
 def __init__(self, host, port, pkt_size, eof):
     gr.top_block.__init__(self, "vector_source")
     data = [i*0.01 for i in range(1000)]
     vec = blocks.vector_source_f(data, True)
     udp = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
     self.connect(vec, udp)
Example #40
0
    def __init__(self):
        gr.top_block.__init__(self,
                              "SQ5BPF Tetra live receiver 6ch UDP HEADLESS")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.first_decim = first_decim = 32
        self.xlate_offset_fine6 = xlate_offset_fine6 = 0
        self.xlate_offset_fine5 = xlate_offset_fine5 = 0
        self.xlate_offset_fine4 = xlate_offset_fine4 = 0
        self.xlate_offset_fine3 = xlate_offset_fine3 = 0
        self.xlate_offset_fine2 = xlate_offset_fine2 = 0
        self.xlate_offset_fine1 = xlate_offset_fine1 = 0
        self.xlate_offset6 = xlate_offset6 = 500e3
        self.xlate_offset5 = xlate_offset5 = 500e3
        self.xlate_offset4 = xlate_offset4 = 500e3
        self.xlate_offset3 = xlate_offset3 = 500e3
        self.xlate_offset2 = xlate_offset2 = 500e3
        self.xlate_offset1 = xlate_offset1 = 500e3
        self.udp_packet_size = udp_packet_size = 1472
        self.udp_dest_addr = udp_dest_addr = "127.0.0.1"
        self.telive_receiver_name = telive_receiver_name = 'SQ5BPF 6-channel headless rx for telive'
        self.telive_receiver_channels = telive_receiver_channels = 6
        self.sdr_ifgain = sdr_ifgain = 20
        self.sdr_gain = sdr_gain = 38
        self.ppm_corr = ppm_corr = 56
        self.out_sample_rate = out_sample_rate = 36000
        self.options_low_pass = options_low_pass = 12500
        self.if_samp_rate = if_samp_rate = samp_rate / first_decim
        self.freq = freq = 435e6
        self.first_port = first_port = 42000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer(('0.0.0.0', first_port),
                                                  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_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(ppm_corr, 0)
        self.osmosdr_source_0.set_gain(sdr_gain, 0)
        self.osmosdr_source_0.set_if_gain(sdr_ifgain, 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.mmse_resampler_xx_5 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.mmse_resampler_xx_4 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.mmse_resampler_xx_3 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.mmse_resampler_xx_2 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.mmse_resampler_xx_1 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.mmse_resampler_xx_0 = filter.mmse_resampler_cc(
            0, float(float(if_samp_rate) / float(out_sample_rate)))
        self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset6 + xlate_offset_fine6, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset5 + xlate_offset_fine5, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_0_0_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset4 + xlate_offset_fine4, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset3 + xlate_offset_fine3, samp_rate)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset2 + xlate_offset_fine2, samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            first_decim,
            firdes.low_pass(1, samp_rate, options_low_pass,
                            options_low_pass * 0.2),
            xlate_offset1 + xlate_offset_fine1, samp_rate)
        self.blocks_udp_sink_0_4 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dest_addr,
                                                   first_port + 5,
                                                   udp_packet_size, False)
        self.blocks_udp_sink_0_3 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dest_addr,
                                                   first_port + 6,
                                                   udp_packet_size, False)
        self.blocks_udp_sink_0_2 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dest_addr,
                                                   first_port + 4,
                                                   udp_packet_size, False)
        self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dest_addr,
                                                   first_port + 3,
                                                   udp_packet_size, False)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                   udp_dest_addr,
                                                   first_port + 2,
                                                   udp_packet_size, False)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 udp_dest_addr, first_port + 1,
                                                 udp_packet_size, False)
        self.analog_agc3_xx_0_0_0_0_0_0 = analog.agc3_cc(
            1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0_0_0_0_0_0.set_max_gain(65536)
        self.analog_agc3_xx_0_0_0_0_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0_0_0_0_0.set_max_gain(65536)
        self.analog_agc3_xx_0_0_0_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0_0_0_0.set_max_gain(65536)
        self.analog_agc3_xx_0_0_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0_0_0.set_max_gain(65536)
        self.analog_agc3_xx_0_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0_0.set_max_gain(65536)
        self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1)
        self.analog_agc3_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc3_xx_0, 0), (self.mmse_resampler_xx_5, 0))
        self.connect((self.analog_agc3_xx_0_0, 0),
                     (self.mmse_resampler_xx_4, 0))
        self.connect((self.analog_agc3_xx_0_0_0, 0),
                     (self.mmse_resampler_xx_3, 0))
        self.connect((self.analog_agc3_xx_0_0_0_0, 0),
                     (self.mmse_resampler_xx_2, 0))
        self.connect((self.analog_agc3_xx_0_0_0_0_0, 0),
                     (self.mmse_resampler_xx_0, 0))
        self.connect((self.analog_agc3_xx_0_0_0_0_0_0, 0),
                     (self.mmse_resampler_xx_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_agc3_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.analog_agc3_xx_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0),
                     (self.analog_agc3_xx_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0, 0),
                     (self.analog_agc3_xx_0_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0),
                     (self.analog_agc3_xx_0_0_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0),
                     (self.analog_agc3_xx_0_0_0_0_0_0, 0))
        self.connect((self.mmse_resampler_xx_0, 0),
                     (self.blocks_udp_sink_0_4, 0))
        self.connect((self.mmse_resampler_xx_1, 0),
                     (self.blocks_udp_sink_0_3, 0))
        self.connect((self.mmse_resampler_xx_2, 0),
                     (self.blocks_udp_sink_0_2, 0))
        self.connect((self.mmse_resampler_xx_3, 0),
                     (self.blocks_udp_sink_0_1, 0))
        self.connect((self.mmse_resampler_xx_4, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.mmse_resampler_xx_5, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0_0_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0_0_0_0_0, 0))
Example #41
0
    def __init__(self):
        gr.top_block.__init__(self, "Frontend RX UHD")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Frontend RX UHD")
        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", "frontend_rx_uhd_VLBI_Ver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.rx_gain = rx_gain = 35

        ##################################################
        # 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, 'Waterfall')
        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, 'Spectrum')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Scope')
        self.top_grid_layout.addWidget(self.tab, 3,0)
        self._rx_gain_range = Range(0, 73, 1, 35, 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, 0,0)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)

        # GPSDO-USRP Sync
        ##################################################
        INFO = "[\033[32mINFO\033[0m]"
        ERROR = "[\033[31mERROR\033[0m]"
        SUCCESS = "[\033[32mSUEECSS\033[0m]"
        WARNING = "[\033[33mWARNING\033[0m]"
        GPS_debug = False

        print 
        print "##################################################"
        print "#                GPSDO Time Sync                 #"
        print "##################################################"

        #Set the sources
        self.uhd_usrp_source_0.set_clock_source('gpsdo', 0)
        self.uhd_usrp_source_0.set_time_source('gpsdo', 0)
        print INFO,"the default 10 MHz Reference and 1 PPS signals are now from the GPSDO."

        #Wait for Reference locked
        time.sleep(1)

        #Check Reference status
        if (self.uhd_usrp_source_0.get_mboard_sensor("ref_locked",0).value == "true"):
            print INFO,"Reference Locked."
        else:
            print ERROR,"Reference Unlocked."
            exit()

        #Check GPS status
        if (self.uhd_usrp_source_0.get_mboard_sensor("gps_locked",0).value == "true"):
            print INFO,"GPS Locked."
        else:
            print ERROR,"GPS Unlocked."
            if not GPS_debug :
                exit()

        #Print GPS info
        print INFO,"GPS INFO"
        print "       Time:",self.uhd_usrp_source_0.get_mboard_sensor("gps_time",0).value
        print "       GPGGA:",self.uhd_usrp_source_0.get_mboard_sensor("gps_gpgga",0).value 
        print "       GPRMC:",self.uhd_usrp_source_0.get_mboard_sensor("gps_gprmc",0).value

        #GPSDO-USRP Sync
        gps_time = int(self.uhd_usrp_source_0.get_mboard_sensor("gps_time",0))
        self.uhd_usrp_source_0.set_time_next_pps(uhd.time_spec(gps_time + 1))
        
        #Wait for it to apply
        #The wait is 2 seconds because USRP has a issue where
        #the time at the last PPS does not properly update at the PPS edge
        #when the time is actually set.
        print INFO,"Synchronizing the time"
        time.sleep (2)


        #Check the time
        gps_time = uhd.time_spec(int(self.uhd_usrp_source_0.get_mboard_sensor("gps_time",0)))
        usrp_time =  self.uhd_usrp_source_0.get_time_last_pps()
        print INFO,"Time INFO"
        print "       GPS time:     ","%.09f"%gps_time.get_real_secs()
        print "       USRP time:    ","%.09f"%usrp_time.get_real_secs()
        print "       Computer time:","%.09f"%time.time()
        if (gps_time.get_real_secs() == usrp_time.get_real_secs()):
            print SUCCESS,"USRP time synchronized to GPS time."
        else:
            print ERROR,"Failed to synchronize USRP time to GPS time."
        ##################################################
        
        self.uhd_usrp_source_0.set_center_freq(437.275e6, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=24,
                decimation=125,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=24,
                decimation=125,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	437.275e6, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [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.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(-120, -20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	437.275e6, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win)
        self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7225, 1472, True)
        self.blocks_udp_sink_0_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7226, 1472, True)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7201, 1472, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7200, 1472, True)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, './Data/meta.raw', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False)
        self.blocks_file_meta_sink_0.set_unbuffered(False)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 50e3, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 75e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_meta_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
Example #42
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.Nt = Nt = 2
        self.dft_coef = dft_coef = np.exp(-2*np.pi*1j/Nt)
        self.A = A = np.arange(Nt)[np.newaxis]
        self.tlen = tlen = 4000
        self.samp_rate = samp_rate = 100000
        self.dft_matrix = dft_matrix = np.power(dft_coef, np.dot(A.transpose(),A))
        self.scramble_2 = scramble_2 = 2*np.random.random_integers(0,1,size=(tlen,Nt))-1
        self.scramble_1 = scramble_1 = 2*np.random.random_integers(0,1,size=(tlen,Nt))-1
        self.prefix = prefix = '/home/zhe/gr-PWF/examples'
        self.noise = noise = [np.identity(Nt), np.identity(Nt)]
        self.max_iteration = max_iteration = 20
        self.interpo = interpo = samp_rate/1000
        self.dft_pilot_seq = dft_pilot_seq = np.tile(dft_matrix,(tlen/Nt,1))
        self.Q = Q = 4
        self.L = L = 2
        self.sigmagenfile = sigmagenfile = prefix+'/sigmagens/sigmagen_10.bin'
        self.pulse = pulse = filter.firdes.root_raised_cosine(Q,Q,1,0.35,11*Q)
        self.prewhiten1 = prewhiten1 = np.linalg.pinv(noise[1])
        self.prewhiten0 = prewhiten0 = np.linalg.pinv(noise[0])
        self.pilot_seq_2 = pilot_seq_2 = np.multiply(dft_pilot_seq,scramble_2)
        self.pilot_seq_1 = pilot_seq_1 = np.multiply(dft_pilot_seq,scramble_1)
        self.pilot2file = pilot2file = prefix+'/pilots/pilot2_4000.bin'
        self.pilot1file = pilot1file = prefix+'/pilots/pilot1_4000.bin'
        self.payload_size = payload_size = 0
        self.npoints = npoints = max_iteration*interpo
        self.noise_hat = noise_hat = [np.identity(Nt), np.identity(Nt)]
        self.ichn_gain_dB = ichn_gain_dB = 10
        self.channelfile = channelfile = prefix+'/channels/2x2channel_10dB_3.bin'
        self.channel = channel = np.true_divide(np.random.standard_normal(size=(L,L,Nt,Nt))+np.random.standard_normal(size=(L,L,Nt,Nt))*1j,np.sqrt(2))
        self.Pt = Pt = 100

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	npoints, #size
        	samp_rate, #samp_rate
        	"Strong Interference (ichn_gain = 10dB)", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0.set_y_axis(0, 20)
        
        self.qtgui_time_sink_x_0.set_y_label("Weighted Sum-Rate (bits/s/Hz)", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, 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_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["Dual Link", "Identity Sigma", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.phase_corrector_0_2 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,0],
        )
        self.phase_corrector_0_1_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,0],
        )
        self.phase_corrector_0_1 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,0],
        )
        self.phase_corrector_0_0_1 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,1],
        )
        self.phase_corrector_0_0_0_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,1],
        )
        self.phase_corrector_0_0_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,1],
        )
        self.phase_corrector_0_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,1],
        )
        self.phase_corrector_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,0],
        )
        self.interp_fir_filter_xxx_0_1_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0_1_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0_1.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_1 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_vector_to_streams_1_2 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1_0_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_0_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*4, 2)
        self.blocks_udp_source_1 = blocks.udp_source(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True)
        self.blocks_udp_sink_1_0 = blocks.udp_sink(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True)
        self.blocks_streams_to_vector_1_2 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*4, 2)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*4, 2)
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float*1, interpo)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, interpo)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*8, "/home/zhe/Dropbox/gnuradio_trunk/gnufiles/udp", False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.PWF_weighted_sum_rate_0 = PWF.weighted_sum_rate(L, Nt, Pt, channel, ichn_gain_dB, [1,1],[prewhiten0 ,prewhiten1], False, channelfile)
        self.PWF_sigmagen_0 = PWF.sigmagen(L, Nt, Pt, True, sigmagenfile)
        self.PWF_power_adjust_1_0 = PWF.power_adjust(Nt, Pt, L)
        self.PWF_power_adjust_1 = PWF.power_adjust(Nt, Pt, L)
        self.PWF_pilot_receive_tx_0_0 = PWF.pilot_receive_tx(True, pilot1file, pilot_seq_1, Nt, tlen,noise_hat[0], tlen, 1)
        self.PWF_pilot_receive_tx_0 = PWF.pilot_receive_tx(True, pilot2file, pilot_seq_2, Nt, tlen,noise_hat[1], tlen, 1)
        self.PWF_pilot_receive_rx_0_0 = PWF.pilot_receive_rx(True, pilot2file, pilot_seq_2, prewhiten1, Nt, tlen, tlen+payload_size, 1)
        self.PWF_pilot_receive_rx_0 = PWF.pilot_receive_rx(True, pilot1file, pilot_seq_1, prewhiten0, Nt, tlen, tlen+payload_size, 1)
        self.PWF_pilot_gen_tx_0_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_2, True, pilot2file)
        self.PWF_pilot_gen_tx_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_1, True, pilot1file)
        self.PWF_pilot_gen_rx_0_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten0, pilot_seq_1, True, pilot1file)
        self.PWF_pilot_gen_rx_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten1, pilot_seq_2, True, pilot2file)
        self.PWF_debug_printmsg_0 = PWF.debug_printmsg(L, Nt, False, 20)
        self.PWF_channel_1 = PWF.channel(L, Nt, ichn_gain_dB, channel, False,noise_hat, False, channelfile)
        self.PWF_channel_0 = PWF.channel(L, Nt, ichn_gain_dB, channel, True,noise, True, channelfile)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.PWF_channel_0, 0), (self.blocks_vector_to_streams_1_1, 0))    
        self.connect((self.PWF_channel_0, 1), (self.blocks_vector_to_streams_1_1_0, 0))    
        self.connect((self.PWF_channel_1, 1), (self.blocks_vector_to_streams_1_1_0_0, 0))    
        self.connect((self.PWF_channel_1, 0), (self.blocks_vector_to_streams_1_1_1, 0))    
        self.connect((self.PWF_debug_printmsg_0, 0), (self.PWF_pilot_gen_tx_0, 0))    
        self.connect((self.PWF_debug_printmsg_0, 1), (self.PWF_pilot_gen_tx_0_0, 0))    
        self.connect((self.PWF_pilot_gen_rx_0, 0), (self.blocks_vector_to_streams_1_0_0, 0))    
        self.connect((self.PWF_pilot_gen_rx_0_0, 0), (self.blocks_vector_to_streams_1_2, 0))    
        self.connect((self.PWF_pilot_gen_tx_0, 0), (self.blocks_vector_to_streams_1, 0))    
        self.connect((self.PWF_pilot_gen_tx_0_0, 0), (self.blocks_vector_to_streams_1_0, 0))    
        self.connect((self.PWF_pilot_receive_rx_0, 0), (self.PWF_power_adjust_1, 0))    
        self.connect((self.PWF_pilot_receive_rx_0_0, 0), (self.PWF_power_adjust_1, 1))    
        self.connect((self.PWF_pilot_receive_tx_0, 0), (self.PWF_power_adjust_1_0, 1))    
        self.connect((self.PWF_pilot_receive_tx_0_0, 0), (self.PWF_power_adjust_1_0, 0))    
        self.connect((self.PWF_power_adjust_1, 1), (self.PWF_pilot_gen_rx_0, 0))    
        self.connect((self.PWF_power_adjust_1, 0), (self.PWF_pilot_gen_rx_0_0, 0))    
        self.connect((self.PWF_power_adjust_1_0, 0), (self.blocks_streams_to_vector_0_0, 0))    
        self.connect((self.PWF_power_adjust_1_0, 1), (self.blocks_streams_to_vector_0_0, 1))    
        self.connect((self.PWF_sigmagen_0, 0), (self.blocks_streams_to_vector_0, 0))    
        self.connect((self.PWF_sigmagen_0, 1), (self.blocks_streams_to_vector_0, 1))    
        self.connect((self.PWF_weighted_sum_rate_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.PWF_weighted_sum_rate_0, 1), (self.blocks_repeat_0_0, 0))    
        self.connect((self.blocks_repeat_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_repeat_0_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_streams_to_vector_0, 0), (self.blocks_udp_sink_1, 0))    
        self.connect((self.blocks_streams_to_vector_0_0, 0), (self.blocks_udp_sink_1_0, 0))    
        self.connect((self.blocks_streams_to_vector_1, 0), (self.PWF_channel_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_0, 0), (self.PWF_channel_0, 1))    
        self.connect((self.blocks_streams_to_vector_1_0_0, 0), (self.PWF_channel_1, 1))    
        self.connect((self.blocks_streams_to_vector_1_1, 0), (self.PWF_pilot_receive_rx_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_1_0, 0), (self.PWF_pilot_receive_rx_0_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_1_0_0, 0), (self.PWF_pilot_receive_tx_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_1_1, 0), (self.PWF_pilot_receive_tx_0_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_2, 0), (self.PWF_channel_1, 0))    
        self.connect((self.blocks_udp_source_1, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_udp_source_1, 0), (self.blocks_vector_to_streams_0, 0))    
        self.connect((self.blocks_vector_to_streams_0, 0), (self.PWF_debug_printmsg_0, 0))    
        self.connect((self.blocks_vector_to_streams_0, 1), (self.PWF_debug_printmsg_0, 1))    
        self.connect((self.blocks_vector_to_streams_0, 0), (self.PWF_weighted_sum_rate_0, 0))    
        self.connect((self.blocks_vector_to_streams_0, 1), (self.PWF_weighted_sum_rate_0, 1))    
        self.connect((self.blocks_vector_to_streams_1, 0), (self.interp_fir_filter_xxx_0, 0))    
        self.connect((self.blocks_vector_to_streams_1, 1), (self.interp_fir_filter_xxx_0_1, 0))    
        self.connect((self.blocks_vector_to_streams_1_0, 0), (self.interp_fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_0, 1), (self.interp_fir_filter_xxx_0_1_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_0_0, 0), (self.blocks_streams_to_vector_1_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_0_0, 1), (self.blocks_streams_to_vector_1_0_0, 1))    
        self.connect((self.blocks_vector_to_streams_1_1, 0), (self.fir_filter_xxx_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1, 1), (self.fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0, 1), (self.fir_filter_xxx_0_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0, 0), (self.fir_filter_xxx_0_1, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0_0, 1), (self.phase_corrector_0_0_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0_0, 0), (self.phase_corrector_0_1_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_1, 1), (self.phase_corrector_0_0_1, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_1, 0), (self.phase_corrector_0_2, 0))    
        self.connect((self.blocks_vector_to_streams_1_2, 1), (self.blocks_streams_to_vector_1_2, 1))    
        self.connect((self.blocks_vector_to_streams_1_2, 0), (self.blocks_streams_to_vector_1_2, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.phase_corrector_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.phase_corrector_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_0_0, 0), (self.phase_corrector_0_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_1, 0), (self.phase_corrector_0_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_streams_to_vector_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_streams_to_vector_1_0, 0))    
        self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.blocks_streams_to_vector_1, 1))    
        self.connect((self.interp_fir_filter_xxx_0_1_0, 0), (self.blocks_streams_to_vector_1_0, 1))    
        self.connect((self.phase_corrector_0, 0), (self.blocks_streams_to_vector_1_1, 0))    
        self.connect((self.phase_corrector_0_0, 0), (self.blocks_streams_to_vector_1_1, 1))    
        self.connect((self.phase_corrector_0_0_0, 0), (self.blocks_streams_to_vector_1_1_0, 1))    
        self.connect((self.phase_corrector_0_0_0_0, 0), (self.blocks_streams_to_vector_1_1_0_0, 1))    
        self.connect((self.phase_corrector_0_0_1, 0), (self.blocks_streams_to_vector_1_1_1, 1))    
        self.connect((self.phase_corrector_0_1, 0), (self.blocks_streams_to_vector_1_1_0, 0))    
        self.connect((self.phase_corrector_0_1_0, 0), (self.blocks_streams_to_vector_1_1_0_0, 0))    
        self.connect((self.phase_corrector_0_2, 0), (self.blocks_streams_to_vector_1_1_1, 0))    
Example #43
0
    def __init__(self):
        gr.top_block.__init__(self, "Transceiverloopbackuhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Transceiverloopbackuhd")
        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", "transceiverLoopbackUHD")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.txUDPPort = txUDPPort = 9001
        self.txGain = txGain = 10
        self.txFreq = txFreq = 100e6
        self.sps = sps = 4
        self.samp_rate = samp_rate = 320000
        self.rxUDPPort = rxUDPPort = 9002
        self.rxGain = rxGain = 15
        self.rxFreq = rxFreq = 100e6
        self.modemConfiguration = modemConfiguration = {
            'encoder': 'cc',
            'rate': 0.5,
            'arity': 4,
            'excessBW': 0.35,
            'preambleOverhead': 8,
            'MTU': 100
        }

        ##################################################
        # Message Queues
        ##################################################
        SatelliteModem_Deframer_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)
        blocks_message_sink_0_msgq_out = SatelliteModem_Framer_0_msgq_in = gr.msg_queue(
            2)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(rxFreq, 0)
        self.uhd_usrp_source_0.set_gain(rxGain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(txFreq, 0)
        self.uhd_usrp_sink_0.set_gain(txGain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Frame",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, -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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

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

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(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 = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, -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, 2, 0, 1,
                                       1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "RX",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

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

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 1, 1, 1,
                                       2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "TX",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

        labels = ["", "", "", "", "", "", "", "", "", ""]
        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, 1, 0, 1,
                                       1)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     "127.0.0.1", txUDPPort,
                                                     modemConfiguration['MTU'],
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "127.0.0.1", rxUDPPort,
                                                 modemConfiguration['MTU'],
                                                 True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_message_sink_0 = blocks.message_sink(
            gr.sizeof_char * 1, blocks_message_sink_0_msgq_out, False)
        self.SatelliteModem_SyncPreamble_0 = SatelliteModem.SyncPreamble(
            int((modemConfiguration['MTU'] + 6) / modemConfiguration['rate']),
            modemConfiguration['preambleOverhead'])
        self.SatelliteModem_PreambleDetector_0 = SatelliteModem.PreambleDetector(
            int((modemConfiguration['MTU'] + 6) / modemConfiguration['rate']),
            modemConfiguration['preambleOverhead'])
        self.SatelliteModem_Framer_0 = SatelliteModem.Framer(
            SatelliteModem_Framer_0_msgq_in, modemConfiguration['MTU'], 1)
        self.SatelliteModem_FECEncoder_0 = SatelliteModem.FECEncoder(
            modemConfiguration['encoder'], modemConfiguration['MTU'] + 6,
            modemConfiguration['rate'])
        self.SatelliteModem_FECDecoder_0 = SatelliteModem.FECDecoder(
            modemConfiguration['encoder'], modemConfiguration['MTU'] + 6,
            modemConfiguration['rate'])
        self.SatelliteModem_Deframer_0 = SatelliteModem.Deframer(
            SatelliteModem_Deframer_0_msgq_out, modemConfiguration['MTU'])
        self.SatelliteModem_DPSKTransmitter_0 = SatelliteModem.DPSKTransmitter(
            .1, modemConfiguration['excessBW'], sps,
            modemConfiguration['arity'])
        self.SatelliteModem_DPSKReceiver_0 = SatelliteModem.DPSKReceiver(
            modemConfiguration['excessBW'], sps, modemConfiguration['arity'])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.SatelliteModem_DPSKReceiver_0, 0),
                     (self.SatelliteModem_PreambleDetector_0, 0))
        self.connect((self.SatelliteModem_DPSKReceiver_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.SatelliteModem_DPSKTransmitter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.SatelliteModem_DPSKTransmitter_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.SatelliteModem_FECDecoder_0, 0),
                     (self.SatelliteModem_Deframer_0, 0))
        self.connect((self.SatelliteModem_FECEncoder_0, 0),
                     (self.SatelliteModem_SyncPreamble_0, 0))
        self.connect((self.SatelliteModem_Framer_0, 0),
                     (self.SatelliteModem_FECEncoder_0, 0))
        self.connect((self.SatelliteModem_PreambleDetector_0, 0),
                     (self.SatelliteModem_FECDecoder_0, 0))
        self.connect((self.SatelliteModem_PreambleDetector_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.SatelliteModem_SyncPreamble_0, 0),
                     (self.SatelliteModem_DPSKTransmitter_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_message_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.SatelliteModem_DPSKReceiver_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
Example #44
0
    def __init__(self,
                 address="addr=192.168.10.2",
                 freq=2.45e9,
                 gain=0,
                 samp_rate=1e6):
        gr.top_block.__init__(self, "UHD TX DPSK")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("UHD TX DPSK")
        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", "uhd_tx_dpsk")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.address = address
        self.freq = freq
        self.gain = gain
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.tun_gain = tun_gain = 0
        self.tun_freq = tun_freq = 2.45e9
        self.samps_per_sym = samps_per_sym = 4
        self.ampl = ampl = 0.1

        ##################################################
        # Blocks
        ##################################################
        self._tun_freq_range = Range(2.4e9, 2.5e9, 1, 2.45e9, 200)
        self._tun_freq_win = RangeWidget(self._tun_freq_range,
                                         self.set_tun_freq, "UHD Freq (Hz)",
                                         "counter_slider", float)
        self.top_layout.addWidget(self._tun_freq_win)
        self._ampl_range = Range(0, 1, 0.01, 0.1, 200)
        self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl,
                                     "Amplitude", "counter_slider", float)
        self.top_layout.addWidget(self._ampl_win)
        self._tun_gain_range = Range(0, 20, 1, 0, 200)
        self._tun_gain_win = RangeWidget(self._tun_gain_range,
                                         self.set_tun_gain, "UHD Tx Gain",
                                         "counter_slider", float)
        self.top_layout.addWidget(self._tun_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            tun_freq,  #fc
            samp_rate,  #bw
            "Transmit Spectrum",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.digital_dxpsk_mod_0 = digital.dqpsk_mod(
            samples_per_symbol=samps_per_sym,
            excess_bw=0.35,
            mod_code="gray",
            verbose=False,
            log=False)

        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 "127.0.0.1", 1224, 1472, True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, ))
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2**8, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_dxpsk_mod_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_dxpsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Example #45
0
    def __init__(self):
        gr.top_block.__init__(self, "Perseus Spectrum Sensing")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Perseus Spectrum Sensing")
        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", "perseus_s_sensing")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.variable_funcion = variable_funcion = 2.5e6
        self.show_test_statistics = show_test_statistics = False
        self.samp_rate = samp_rate = 20e6
        self.packet_size = packet_size = 8192
        self.oversampling = oversampling = 4
        self.nfft = nfft = 2**15
        self.funcion_prove_showts_edge = funcion_prove_showts_edge = 0
        self.freq_offset = freq_offset = variable_funcion
        self.decimation = decimation = 40
        self.cosenito = cosenito = 20e3
        self.amplitude = amplitude = 0.125
        self.RF_freq = RF_freq = 943e6
        self.PSD_averaging = PSD_averaging = 2000
        self.ENABLE_TX1_variable_check_box = ENABLE_TX1_variable_check_box = True

        ##################################################
        # Blocks
        ##################################################
        _show_test_statistics_check_box = Qt.QCheckBox("Show Test Statistics (ReL and Rs)")
        self._show_test_statistics_choices = {True: True, False: False}
        self._show_test_statistics_choices_inv = dict((v,k) for k,v in self._show_test_statistics_choices.iteritems())
        self._show_test_statistics_callback = lambda i: Qt.QMetaObject.invokeMethod(_show_test_statistics_check_box, "setChecked", Qt.Q_ARG("bool", self._show_test_statistics_choices_inv[i]))
        self._show_test_statistics_callback(self.show_test_statistics)
        _show_test_statistics_check_box.stateChanged.connect(lambda i: self.set_show_test_statistics(self._show_test_statistics_choices[bool(i)]))
        self.top_layout.addWidget(_show_test_statistics_check_box)
        self.probe = blocks.probe_signal_f()
        def _variable_funcion_probe():
            while True:
                val = self.probe.level()
                try:
                    self.set_variable_funcion(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.01))
        _variable_funcion_thread = threading.Thread(target=_variable_funcion_probe)
        _variable_funcion_thread.daemon = True
        _variable_funcion_thread.start()
        self.spectsensing_ss_edge_plot_0 = spectsensing.ss_edge_plot(show_test_statistics, " " )
        self._spectsensing_ss_edge_plot_0_win = self.spectsensing_ss_edge_plot_0;
        self.top_layout.addWidget(self._spectsensing_ss_edge_plot_0_win) 
        
        self.spectsensing_xs_plot_1 = spectsensing.xs_plot("")
        self._spectsensing_xs_plot_1_win = self.spectsensing_xs_plot_1;
        self.top_layout.addWidget(self._spectsensing_xs_plot_1_win)
        self.spectsensing_subband_selector_0 = spectsensing.subband_selector(40, "Selection", 2.5e6 , samp_rate)
        self.spectsensing_ss_pds_plot_0 = spectsensing.ss_pds_plot(nfft, samp_rate, 1024 )
        self.spectsensing_compute_statistics_0 = spectsensing.compute_statistics(nfft, samp_rate, 0.0065, 1e-9, 1e-9, 40, 54)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	1024, #size
        	8E3, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	2**15, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.nutaq_rtdex_source_S_S_0 = nutaq.rtdex_source("nutaq_carrier_perseus_TX",gr.sizeof_short,1,0)
        self.nutaq_rtdex_source_S_S_0.set_type(0)
        self.nutaq_rtdex_source_S_S_0.set_packet_size(1300)
        self.nutaq_rtdex_source_S_S_0.set_channels("0")
        self.nutaq_rtdex_source_S_S = nutaq.rtdex_source("nutaq_carrier_perseus_TX",gr.sizeof_short,1,3)
        self.nutaq_rtdex_source_S_S.set_type(0)
        self.nutaq_rtdex_source_S_S.set_packet_size(1200)
        self.nutaq_rtdex_source_S_S.set_channels("3")
        self.nutaq_rtdex_source_0_0_0 = nutaq.rtdex_source("nutaq_carrier_perseus_TX",gr.sizeof_short,1,7)
        self.nutaq_rtdex_source_0_0_0.set_type(0)
        self.nutaq_rtdex_source_0_0_0.set_packet_size(packet_size)
        self.nutaq_rtdex_source_0_0_0.set_channels("2")
        (self.nutaq_rtdex_source_0_0_0).set_min_output_buffer(16384)
        self.nutaq_rtdex_sink_0 = nutaq.rtdex_sink("nutaq_carrier_perseus_TX",gr.sizeof_short,1,7)
        self.nutaq_rtdex_sink_0.set_type(0)
        self.nutaq_rtdex_sink_0.set_packet_size(packet_size)
        self.nutaq_rtdex_sink_0.set_channels("1")
        self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_TX", 2, 1)
        self.nutaq_radio420_tx_0_0.set_default_enable(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_freq(RF_freq)
        self.nutaq_radio420_tx_0_0.set_default_reference(1)
        self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0_0.set_default_band(0)
        self.nutaq_radio420_tx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(2)
        self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_tx_0 = nutaq.radio420_tx("nutaq_carrier_perseus_TX", 1, 0)
        self.nutaq_radio420_tx_0.set_default_enable(1)
        self.nutaq_radio420_tx_0.set_default_tx_freq(RF_freq )
        self.nutaq_radio420_tx_0.set_default_reference(0)
        self.nutaq_radio420_tx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0.set_default_calibrate(1)
        self.nutaq_radio420_tx_0.set_default_band(0)
        self.nutaq_radio420_tx_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0.set_default_tx_lpf_bandwidth(2)
        self.nutaq_radio420_tx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0_0 = nutaq.radio420_rx("nutaq_carrier_perseus_TX", 2, 3)
        self.nutaq_radio420_rx_0_0.set_default_enable(1)
        self.nutaq_radio420_rx_0_0.set_default_rx_freq(RF_freq)
        self.nutaq_radio420_rx_0_0.set_default_reference(1)
        self.nutaq_radio420_rx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0_0.set_default_band(0)
        self.nutaq_radio420_rx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0_0.set_default_rx_lna_gain(3)
        self.nutaq_radio420_rx_0_0.set_default_rx_vga1_gain(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain2(4)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain3(10)
        self.nutaq_radio420_rx_0_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_TX", 1, 2)
        self.nutaq_radio420_rx_0.set_default_enable(1)
        self.nutaq_radio420_rx_0.set_default_rx_freq(RF_freq)
        self.nutaq_radio420_rx_0.set_default_reference(0)
        self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0.set_default_calibrate(1)
        self.nutaq_radio420_rx_0.set_default_band(0)
        self.nutaq_radio420_rx_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_gain2(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain3(-8)
        self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2)
        self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_custom_register_0_1_1 = nutaq.custom_register("nutaq_carrier_perseus_TX",9)
        self.nutaq_custom_register_0_1_1.set_index(6)
        self.nutaq_custom_register_0_1_1.set_default_value(PSD_averaging)
        self.nutaq_custom_register_0_1_1.set_update_rate(1)
          
        self.nutaq_custom_register_0_1_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",7)
        self.nutaq_custom_register_0_1_0.set_index(2)
        self.nutaq_custom_register_0_1_0.set_update_rate(1)
          
        self.nutaq_custom_register_0_1 = nutaq.custom_register("nutaq_carrier_perseus_TX",36)
        self.nutaq_custom_register_0_1.set_index(0)
        self.nutaq_custom_register_0_1.set_default_value(int((2e6)/samp_rate*(2**32)))
        self.nutaq_custom_register_0_1.set_update_rate(1)
          
        self.nutaq_custom_register_0_0_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",8)
        self.nutaq_custom_register_0_0_0.set_index(3)
        self.nutaq_custom_register_0_0_0.set_default_value(7)
        self.nutaq_custom_register_0_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",5)
        self.nutaq_custom_register_0_0.set_index(4)
        self.nutaq_custom_register_0_0.set_default_value(1)
        self.nutaq_custom_register_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",4)
        self.nutaq_custom_register_0.set_index(1)
        self.nutaq_custom_register_0.set_default_value(3)
        self.nutaq_custom_register_0.set_update_rate(1)
          
        self.nutaq_carrier_perseus_TX = nutaq.carrier(0,"nutaq_carrier_perseus_TX", "192.168.0.101")
        def _funcion_prove_showts_edge_probe():
            while True:
                val = self.spectsensing_ss_edge_plot_0.update_variable_show_Ts(self.show_test_statistics)
                try:
                    self.set_funcion_prove_showts_edge(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.1))
        _funcion_prove_showts_edge_thread = threading.Thread(target=_funcion_prove_showts_edge_probe)
        _funcion_prove_showts_edge_thread.daemon = True
        _funcion_prove_showts_edge_thread.start()
        self._freq_offset_range = Range(-1e7, 1e7, 1e4, variable_funcion, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "freq_offset", "slider")
        self.top_layout.addWidget(self._freq_offset_win)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=oversampling,
        	bt=0.71,
        	verbose=False,
        	log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=oversampling,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self._cosenito_range = Range(-250e3, 250e3, 1e3, 20e3, 200)
        self._cosenito_win = RangeWidget(self._cosenito_range, self.set_cosenito, "cosenito", "counter_slider")
        self.top_layout.addWidget(self._cosenito_win)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, "192.168.0.122", 1234, 1472, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 2*4e3 + 0*samp_rate/40/(oversampling*8*2),True)
        self.blocks_short_to_float_0_1_0 = blocks.short_to_float(1, 2**11)
        self.blocks_short_to_float_0_0_0_0 = blocks.short_to_float(1, 2**11)
        self.blocks_null_sink_1_3 = blocks.null_sink(gr.sizeof_float*40)
        self.blocks_null_sink_1_2 = blocks.null_sink(gr.sizeof_float*40)
        self.blocks_null_sink_1_1_0 = blocks.null_sink(gr.sizeof_float*40)
        self.blocks_null_sink_1_1 = blocks.null_sink(gr.sizeof_float*40)
        self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_float*40)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*40)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1)
        self.blocks_multiply_const_vxx_0_3 = blocks.multiply_const_vff((2.0**(16*2), ))
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((amplitude, ))
        self.blocks_multiply_const_vxx_0_1_1 = blocks.multiply_const_vff((2.0**(16*0), ))
        self.blocks_multiply_const_vxx_0_1_0_0 = blocks.multiply_const_vff((2.0**(16*1), ))
        self.blocks_multiply_const_vxx_0_1_0 = blocks.multiply_const_vff((2.0**(16*1), ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((2.0**(16*0), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2.0**(16*2), ))
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_short*1, 1)
        self.blocks_float_to_short_0_0_0 = blocks.float_to_short(1, 2**11-1)
        self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 2**11-1)
        self.blocks_float_to_complex_0_0_0 = blocks.float_to_complex(1)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/juan/Music/de_mi.mp3", True)
        self.blocks_deinterleave_0_0_1 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_deinterleave_0_0_0 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_deinterleave_0_0 = blocks.deinterleave(gr.sizeof_short*1, 1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=2,
        		bits_per_symbol=8,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=128,
        )
        self.blks2_packet_decoder_1 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
        		access_code="",
        		threshold=-1,
        		callback=lambda ok, payload: self.blks2_packet_decoder_1.recv_pkt(ok, payload),
        	),
        )
        _ENABLE_TX1_variable_check_box_check_box = Qt.QCheckBox("Enable Transmission")
        self._ENABLE_TX1_variable_check_box_choices = {True: True, False: False}
        self._ENABLE_TX1_variable_check_box_choices_inv = dict((v,k) for k,v in self._ENABLE_TX1_variable_check_box_choices.iteritems())
        self._ENABLE_TX1_variable_check_box_callback = lambda i: Qt.QMetaObject.invokeMethod(_ENABLE_TX1_variable_check_box_check_box, "setChecked", Qt.Q_ARG("bool", self._ENABLE_TX1_variable_check_box_choices_inv[i]))
        self._ENABLE_TX1_variable_check_box_callback(self.ENABLE_TX1_variable_check_box)
        _ENABLE_TX1_variable_check_box_check_box.stateChanged.connect(lambda i: self.set_ENABLE_TX1_variable_check_box(self._ENABLE_TX1_variable_check_box_choices[bool(i)]))
        self.top_layout.addWidget(_ENABLE_TX1_variable_check_box_check_box)
        self.DataConversion_reint_short_float_0_3 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_2_0 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_2 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_1_0 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_1 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_0_0 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0_0 = DataConversion.reint_short_float()
        self.DataConversion_reint_short_float_0 = DataConversion.reint_short_float()
        self.DataConversion_eaver_resynchronizer_0_0 = DataConversion.eaver_resynchronizer(1024)
        self.DataConversion_eaver_resynchronizer_0 = DataConversion.eaver_resynchronizer(decimation)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.spectsensing_compute_statistics_0, 'spec_sens_pdus'), (self.spectsensing_ss_edge_plot_0, 'pdus'))    
        self.msg_connect((self.spectsensing_ss_pds_plot_0, 'psd_pdu'), (self.spectsensing_xs_plot_1, 'pdus'))    
        self.connect((self.DataConversion_eaver_resynchronizer_0, 0), (self.spectsensing_compute_statistics_0, 0))    
        self.connect((self.DataConversion_eaver_resynchronizer_0, 1), (self.spectsensing_compute_statistics_0, 1))    
        self.connect((self.DataConversion_eaver_resynchronizer_0_0, 0), (self.spectsensing_ss_pds_plot_0, 0))    
        self.connect((self.DataConversion_eaver_resynchronizer_0_0, 1), (self.spectsensing_ss_pds_plot_0, 1))    
        self.connect((self.DataConversion_reint_short_float_0, 0), (self.DataConversion_eaver_resynchronizer_0, 0))    
        self.connect((self.DataConversion_reint_short_float_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.DataConversion_reint_short_float_0_0_0, 0), (self.blocks_multiply_const_vxx_0_3, 0))    
        self.connect((self.DataConversion_reint_short_float_0_1, 0), (self.blocks_multiply_const_vxx_0_1_0, 0))    
        self.connect((self.DataConversion_reint_short_float_0_1_0, 0), (self.blocks_multiply_const_vxx_0_1_0_0, 0))    
        self.connect((self.DataConversion_reint_short_float_0_2, 0), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.DataConversion_reint_short_float_0_2_0, 0), (self.blocks_multiply_const_vxx_0_1_1, 0))    
        self.connect((self.DataConversion_reint_short_float_0_3, 0), (self.DataConversion_eaver_resynchronizer_0_0, 0))    
        self.connect((self.blks2_packet_decoder_1, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.blks2_packet_decoder_1, 0), (self.blocks_udp_sink_0, 0))    
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.DataConversion_eaver_resynchronizer_0, 1))    
        self.connect((self.blocks_add_xx_0_0, 0), (self.DataConversion_eaver_resynchronizer_0_0, 1))    
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_short_0_0, 0))    
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_float_to_short_0_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0, 0), (self.DataConversion_reint_short_float_0, 0))    
        self.connect((self.blocks_deinterleave_0_0, 1), (self.DataConversion_reint_short_float_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0, 3), (self.DataConversion_reint_short_float_0_1, 0))    
        self.connect((self.blocks_deinterleave_0_0, 2), (self.DataConversion_reint_short_float_0_2, 0))    
        self.connect((self.blocks_deinterleave_0_0_0, 1), (self.blocks_short_to_float_0_0_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_0, 0), (self.blocks_short_to_float_0_1_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 1), (self.DataConversion_reint_short_float_0_0_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 3), (self.DataConversion_reint_short_float_0_1_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 2), (self.DataConversion_reint_short_float_0_2_0, 0))    
        self.connect((self.blocks_deinterleave_0_0_1, 0), (self.DataConversion_reint_short_float_0_3, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_float_to_complex_0_0_0, 0), (self.digital_gmsk_demod_0, 0))    
        self.connect((self.blocks_float_to_complex_0_0_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_interleave_0, 0))    
        self.connect((self.blocks_float_to_short_0_0_0, 0), (self.blocks_interleave_0, 1))    
        self.connect((self.blocks_interleave_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.blocks_interleave_0, 0), (self.nutaq_rtdex_sink_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_1, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0, 0), (self.blocks_add_xx_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_1_0_0, 0), (self.blocks_add_xx_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_1_1, 0), (self.blocks_add_xx_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_complex_to_float_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_3, 0), (self.blocks_add_xx_0_0, 0))    
        self.connect((self.blocks_short_to_float_0_0_0_0, 0), (self.blocks_float_to_complex_0_0_0, 1))    
        self.connect((self.blocks_short_to_float_0_1_0, 0), (self.blocks_float_to_complex_0_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blks2_packet_encoder_0, 0))    
        self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_1, 0))    
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))    
        self.connect((self.nutaq_rtdex_source_0_0_0, 0), (self.blocks_deinterleave_0_0_0, 0))    
        self.connect((self.nutaq_rtdex_source_S_S, 0), (self.blocks_deinterleave_0_0, 0))    
        self.connect((self.nutaq_rtdex_source_S_S_0, 0), (self.blocks_deinterleave_0_0_1, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 0), (self.blocks_null_sink_1, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 5), (self.blocks_null_sink_1_0, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 2), (self.blocks_null_sink_1_1, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 3), (self.blocks_null_sink_1_1_0, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 4), (self.blocks_null_sink_1_2, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 6), (self.blocks_null_sink_1_3, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 3), (self.spectsensing_subband_selector_0, 2))    
        self.connect((self.spectsensing_compute_statistics_0, 7), (self.spectsensing_subband_selector_0, 0))    
        self.connect((self.spectsensing_compute_statistics_0, 1), (self.spectsensing_subband_selector_0, 1))    
        self.connect((self.spectsensing_subband_selector_0, 0), (self.probe, 0))    
Example #46
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Udp Rx Tx Real")
        _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_0 = samp_rate_0 = 2e6
        self.samp_rate = samp_rate = 2E6
        self.RFGain_rx = RFGain_rx = 10
        self.IFGain_tx = IFGain_tx = 30
        self.IFGain_rx = IFGain_rx = 30
        self.CenterFreq_tx = CenterFreq_tx = 500e6
        self.CenterFreq_rx = CenterFreq_rx = 500e6
        self.BBGain_tx = BBGain_tx = 30
        self.BBGain_rx = BBGain_rx = 30

        ##################################################
        # Blocks
        ##################################################
        _RFGain_rx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._RFGain_rx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_RFGain_rx_sizer,
            value=self.RFGain_rx,
            callback=self.set_RFGain_rx,
            label='RFGain_rx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._RFGain_rx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_RFGain_rx_sizer,
            value=self.RFGain_rx,
            callback=self.set_RFGain_rx,
            minimum=1,
            maximum=40,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_RFGain_rx_sizer)
        _IFGain_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._IFGain_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_IFGain_tx_sizer,
            value=self.IFGain_tx,
            callback=self.set_IFGain_tx,
            label='IFGain_tx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._IFGain_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_IFGain_tx_sizer,
            value=self.IFGain_tx,
            callback=self.set_IFGain_tx,
            minimum=1,
            maximum=40,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_IFGain_tx_sizer)
        _IFGain_rx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._IFGain_rx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_IFGain_rx_sizer,
            value=self.IFGain_rx,
            callback=self.set_IFGain_rx,
            label='IFGain_rx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._IFGain_rx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_IFGain_rx_sizer,
            value=self.IFGain_rx,
            callback=self.set_IFGain_rx,
            minimum=1,
            maximum=40,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_IFGain_rx_sizer)
        _CenterFreq_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._CenterFreq_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_CenterFreq_tx_sizer,
            value=self.CenterFreq_tx,
            callback=self.set_CenterFreq_tx,
            label='CenterFreq_tx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._CenterFreq_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_CenterFreq_tx_sizer,
            value=self.CenterFreq_tx,
            callback=self.set_CenterFreq_tx,
            minimum=450e6,
            maximum=600e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_CenterFreq_tx_sizer)
        _CenterFreq_rx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._CenterFreq_rx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_CenterFreq_rx_sizer,
            value=self.CenterFreq_rx,
            callback=self.set_CenterFreq_rx,
            label='CenterFreq_rx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._CenterFreq_rx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_CenterFreq_rx_sizer,
            value=self.CenterFreq_rx,
            callback=self.set_CenterFreq_rx,
            minimum=450e6,
            maximum=600e6,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_CenterFreq_rx_sizer)
        _BBGain_tx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._BBGain_tx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_BBGain_tx_sizer,
            value=self.BBGain_tx,
            callback=self.set_BBGain_tx,
            label='BBGain_tx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._BBGain_tx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_BBGain_tx_sizer,
            value=self.BBGain_tx,
            callback=self.set_BBGain_tx,
            minimum=1,
            maximum=40,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_BBGain_tx_sizer)
        _BBGain_rx_sizer = wx.BoxSizer(wx.VERTICAL)
        self._BBGain_rx_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_BBGain_rx_sizer,
            value=self.BBGain_rx,
            callback=self.set_BBGain_rx,
            label='BBGain_rx',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._BBGain_rx_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_BBGain_rx_sizer,
            value=self.BBGain_rx,
            callback=self.set_BBGain_rx,
            minimum=1,
            maximum=40,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_BBGain_rx_sizer)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title='Scope Plot',
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label='Counts',
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'hackrf=2a8068cd')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(CenterFreq_rx, 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(RFGain_rx, 0)
        self.osmosdr_source_0.set_if_gain(IFGain_rx, 0)
        self.osmosdr_source_0.set_bb_gain(BBGain_rx, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           'hackrf=21650cc3')
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(CenterFreq_tx, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(0, 0)
        self.osmosdr_sink_0.set_if_gain(IFGain_tx, 0)
        self.osmosdr_sink_0.set_bb_gain(BBGain_tx, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 '192.168.1.10', 10000, 1472,
                                                 True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/steve-wang/test.txt', True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=2,
                preamble='',
                access_code='',
                pad_for_usrp=False,
            ),
            payload_length=30,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.wxgui_scopesink2_0_0, 0))
Example #47
0
    def __init__(self, fsk_dev=10000, lpf_cutoff=12.5e3, lpf_trans=1e3):
        gr.top_block.__init__(self, "Fsk Tx Es")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fsk Tx Es")
        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", "fsk_tx_es")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48e3
        self.baud = baud = 9600
        self.samps_per_symb = samps_per_symb = int(samp_rate/baud)
        self.mult = mult = (samp_rate)/2/3.141593
        self.bb_gain = bb_gain = 10
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._bb_gain_range = Range(0, 10, .01, 10, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 6,0,1,4)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"TX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.010)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_1.disable_legend()

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

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

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 2,0,4,4)
        self.pyqt_text_output_0_0 = pyqt.text_output()
        self._pyqt_text_output_0_0_win = self.pyqt_text_output_0_0;
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_0_win, 0,0,2,4)
        self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True)
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=32, postamble_bytes=16)
        self.es_source_0 = es.source(1*[gr.sizeof_gr_complex], 1, 2, 0)
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=samps_per_symb,
        	bt=alpha,
        	verbose=False,
        	log=False,
        )
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '0.0.0.0', 9000, 1472, True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.complex_t, 'packet_len')
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, 4096*3, "packet_len")
        (self.blocks_stream_to_tagged_stream_0).set_min_output_buffer(17000)
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_CLIENT", '0.0.0.0', '8000', 1024, False)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, ))



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.es_source_0, 'schedule_event'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.pyqt_text_output_0_0, 'pdus'))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.es_source_0, 0), (self.blocks_throttle_0_0, 0))
Example #48
0
    def __init__(self):
        gr.top_block.__init__(self, "Tetra Rx Multi")

        options = self.get_options()

        ##################################################
        # Variables
        ##################################################
        self.srate_rx = srate_rx = options.sample_rate
        self.channels = srate_rx / 25000
        self.srate_channel = 36000
        self.afc_period = 5
        self.afc_gain = 1.
        self.afc_channel = options.auto_tune or -1
        self.afc_ppm_step = 100
        self.debug = options.debug
        self.last_pwr = -100000
        self.sig_det_period = 1
        self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx
        if self.sig_det_bw <= 1.:
            self.sig_det_bw *= srate_rx
        self.sig_det_threshold = options.sig_detection_threshold
        self.sig_det_channels = []
        for ch in range(self.channels):
            if ch >= self.channels / 2:
                ch_ = (self.channels - ch - 1)
            else:
                ch_ = ch
            if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx):
                self.sig_det_channels.append(ch)

        ##################################################
        # RPC server
        ##################################################
        self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer(
                ("localhost", options.listen_port), allow_none=True)
        self.xmlrpc_server.register_instance(self)
        threading.Thread(target=self.xmlrpc_server.serve_forever).start()

        ##################################################
        # Rx Blocks and connections
        ##################################################
        self.src = osmosdr.source( args=options.args )
        self.src.set_sample_rate(srate_rx)
        self.src.set_center_freq(options.frequency, 0)
        self.src.set_freq_corr(options.ppm, 0)
        self.src.set_dc_offset_mode(0, 0)
        self.src.set_iq_balance_mode(0, 0)
        if options.gain is not None:
            self.src.set_gain_mode(False, 0)
            self.src.set_gain(36, 0)
        else:
            self.src.set_gain_mode(True, 0)

        out_type, dst_path = options.output.split("://", 1)
        if out_type == "udp":
            dst_ip, dst_port = dst_path.split(':', 1)

        self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx)

        self.channelizer = pfb.channelizer_ccf(
              self.channels,
              (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)),
              36./25.,
              100)

        self.squelch = []
        self.digital_mpsk_receiver_cc = []
        self.diff_phasor = []
        self.complex_to_arg = []
        self.multiply_const = []
        self.add_const = []
        self.float_to_uchar = []
        self.map_bits = []
        self.unpack_k_bits = []
        self.blocks_sink = []
        for ch in range(0, self.channels):
            squelch = analog.pwr_squelch_cc(0, 0.001, 0, True)
            mpsk = digital.mpsk_receiver_cc(
                    4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001)
            diff_phasor = digital.diff_phasor_cc()
            complex_to_arg = blocks.complex_to_arg(1)
            multiply_const = blocks.multiply_const_vff((2./math.pi, ))
            add_const = blocks.add_const_vff((1.5, ))
            float_to_uchar = blocks.float_to_uchar()
            map_bits = digital.map_bb(([3, 2, 0, 1, 3]))
            unpack_k_bits = blocks.unpack_k_bits_bb(2)

            if out_type == 'udp':
                sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True)
            elif out_type == 'file':
                sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False)
                sink.set_unbuffered(True)
            else:
                raise ValueError("Invalid output URL '%s'" % options.output)

            self.connect((self.channelizer, ch),
                    (squelch, 0),
                    (mpsk, 0),
                    (diff_phasor, 0),
                    (complex_to_arg, 0),
                    (multiply_const, 0),
                    (add_const, 0),
                    (float_to_uchar, 0),
                    (map_bits, 0),
                    (unpack_k_bits, 0),
                    (sink, 0))

            self.squelch.append(squelch)
            self.digital_mpsk_receiver_cc.append(mpsk)
            self.diff_phasor.append(diff_phasor)
            self.complex_to_arg.append(complex_to_arg)
            self.multiply_const.append(multiply_const)
            self.add_const.append(add_const)
            self.float_to_uchar.append(float_to_uchar)
            self.map_bits.append(map_bits)
            self.unpack_k_bits.append(unpack_k_bits)
            self.blocks_sink.append(sink)

        self.connect(
                (self.src, 0),
                (self.freq_xlating, 0),
                (self.channelizer, 0))

        ##################################################
        # signal strenght identification
        ##################################################
        self.pwr_probes = []
        for ch in range(self.channels):
            pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel)
            self.pwr_probes.append(pwr_probe)
            self.connect((self.channelizer, ch), (pwr_probe, 0))
        def _sig_det_probe():
            while True:
                pwr = [self.pwr_probes[ch].level()
                        for ch in range(self.channels)
                        if ch in self.sig_det_channels]
                pwr = [10 * math.log10(p) for p in pwr if p > 0.]
                if not pwr:
                    continue
                pwr = min(pwr) + self.sig_det_threshold
                print "Power level for squelch % 5.1f" % pwr
                if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2):
                    for s in self.squelch:
                        s.set_threshold(pwr)
                    self.last_pwr = pwr
                time.sleep(self.sig_det_period)

        if self.sig_det_threshold is not None:
            self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe)
            self._sig_det_probe_thread.daemon = True
            self._sig_det_probe_thread.start()

        ##################################################
        # AFC blocks and connections
        ##################################################
        self.afc_selector = grc_blks2.selector(
                item_size=gr.sizeof_gr_complex,
                num_inputs=self.channels,
                num_outputs=1,
                input_index=0,
                output_index=0,
                )

        self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi))
        samp_afc = self.srate_channel*self.afc_period / 2
        self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain)
        self.afc_probe = blocks.probe_signal_f()

        def _afc_probe():
            while True:
                time.sleep(self.afc_period)
                if self.afc_channel == -1:
                    continue
                err = self.afc_probe.level()
                if abs(err) < self.afc_ppm_step:
                    continue
                freq = self.freq_xlating.center_freq + err * self.afc_gain
                if self.debug:
                    print "err: %f\tfreq: %f" % (err, freq, )
                self.freq_xlating.set_center_freq(freq)
        self._afc_err_thread = threading.Thread(target=_afc_probe)
        self._afc_err_thread.daemon = True
        self._afc_err_thread.start()

        for ch in range(self.channels):
            self.connect((self.channelizer, ch), (self.afc_selector, ch))
        self.connect(
                (self.afc_selector, 0),
                (self.afc_demod, 0),
                (self.afc_avg, 0),
                (self.afc_probe, 0))

        if self.afc_channel != -1:
            self.afc_selector.set_input_index(self.afc_channel)
    def __init__(self):
        gr.top_block.__init__(self, "TJ Groundstation No Gui with Control")

        ##################################################
        # Variables
        ##################################################
        self.interp = interp = 4
        self.audio_rate = audio_rate = 48000
        self.tx_gain = tx_gain = 10
        self.rx_downsamp_bw = rx_downsamp_bw = 10000
        self.rf_tx_rate = rf_tx_rate = audio_rate * interp
        self.rf_rx_rate = rf_rx_rate = 192000
        self.preamble_len = preamble_len = 300
        self.groundstation_port_2 = groundstation_port_2 = "5557"
        self.groundstation_port_1 = groundstation_port_1 = "5555"
        self.groundstation_ip_addr = groundstation_ip_addr = "192.168.1.10"
        self.groundstation_controller_ip = groundstation_controller_ip = "192.268.1.3"
        self.gain = gain = 40
        self.freq = freq = 144.39e6
        self.baud_rate = baud_rate = 1200
        self.audio_line_driver = audio_line_driver = .8
        self.Decay = Decay = 0.8
        self.Attack = Attack = 0.8

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_1 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_1.set_samp_rate(rf_rx_rate)
        self.uhd_usrp_source_0_1.set_center_freq(freq, 0)
        self.uhd_usrp_source_0_1.set_gain(gain, 0)
        self.uhd_usrp_source_0_1.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_1.set_bandwidth(rf_rx_rate, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(rf_tx_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(rf_tx_rate, 0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=4,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            4,
            firdes.low_pass(1, rf_rx_rate, rx_downsamp_bw / 2, 1000,
                            firdes.WIN_HAMMING, 6.76))
        self.detectMarkSpace_1_0_0 = detectMarkSpace(
            Frequency=2200,
            attack=Attack,
            decay=Decay,
            samp_rate=audio_rate,
        )
        self.detectMarkSpace_0_0_0 = detectMarkSpace(
            Frequency=1200,
            attack=Attack,
            decay=Decay,
            samp_rate=audio_rate,
        )
        self.bruninga_str_to_aprs_0 = bruninga.str_to_aprs(
            'KN4DTQ', 'KN4DTQ', [])
        self.bruninga_ax25_fsk_mod_0 = bruninga.ax25_fsk_mod(
            audio_rate, preamble_len, 5, 2200, 1200, baud_rate)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(
            gr.sizeof_char * 1, groundstation_controller_ip,
            int(groundstation_port_2), 1472, True)
        self.blocks_sub_xx_0_0_0_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER",
                                                       groundstation_ip_addr,
                                                       groundstation_port_1,
                                                       10000, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.8, ))
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
            audio_rate=audio_rate,
            quad_rate=audio_rate,
            tau=75e-6,
            max_dev=5e3,
            fh=-1.0,
        )
        self.analog_nbfm_rx_0_0 = analog.nbfm_rx(
            audio_rate=audio_rate,
            quad_rate=audio_rate,
            tau=75e-6,
            max_dev=5e3,
        )
        self.afsk_ax25decode_1_0 = afsk.ax25decode(audio_rate, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.bruninga_str_to_aprs_0, 'in'))
        self.msg_connect((self.bruninga_str_to_aprs_0, 'out'),
                         (self.bruninga_ax25_fsk_mod_0, 'in'))
        self.connect((self.afsk_ax25decode_1_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0),
                     (self.detectMarkSpace_0_0_0, 0))
        self.connect((self.analog_nbfm_rx_0_0, 0),
                     (self.detectMarkSpace_1_0_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_sub_xx_0_0_0_0, 0),
                     (self.afsk_ax25decode_1_0, 0))
        self.connect((self.bruninga_ax25_fsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.detectMarkSpace_0_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 0))
        self.connect((self.detectMarkSpace_1_0_0, 0),
                     (self.blocks_sub_xx_0_0_0_0, 1))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_nbfm_rx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0_1, 0),
                     (self.low_pass_filter_0_0, 0))
Example #50
0
    def __init__(self, host, port, pkt_size, sample_rate, eof):
        gr.top_block.__init__(self, "audio_source")
        self.audio = audio.source(sample_rate)
	self.sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
        self.connect(self.audio, self.sink)
Example #51
0
    def __init__(self, mon_id, audio_port):
        gr.top_block.__init__(self, "EAS/SAME Monitor")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 8000

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

        # Resampler from input rate (44.1k) to internal rate (8k)
        self.rational_resampler_44k = filter.rational_resampler_fff(
                interpolation=80,
                decimation=441,
        )

        # Resampler from 8000 Hz to 4166 2/3rd Hz to deal with SAME's weird parameters
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=50,
                decimation=96,
                taps=None,
                fractional_bw=None,
        )

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcc(1, (firdes.low_pass(1, samp_rate, 600, 100)), 1822.916667, samp_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=8,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.01,
        	freq_error=0.0,
        	verbose=True,
        	log=False,
        )
        self.src = audio.source(44100, "eas_mon_%s:in" % (mon_id), True)
        self.agc = analog.agc_ff(0.0001, 0.1, 1.0)
        #self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_ff(-50, 0.0001, 0)
        self.msg_queue = gr.msg_queue(10)
        self.same_dec_0 = same.same_dec(self.msg_queue)

        self.tone_det_0 = fft.goertzel_fc(samp_rate, samp_rate / 10, 853)
        self.tone_det_1 = fft.goertzel_fc(samp_rate, samp_rate / 10, 960)
        self.tone_det_2 = fft.goertzel_fc(samp_rate, samp_rate / 10, 1050)
        self.wat_thresh_msg = same.wat_thresh_msg(self.msg_queue, 1, 0.05, 0.01)

        #self.avg_audio_level = analog.probe_avg_mag_sqrd_ff(-50)
        #self.level_thresh_msg = same.level_thresh_msg(self.msg_queue, 1, 3, db_to_abs(-30), db_to_abs(-40))

        self.audio_sink_converter = blocks.float_to_short(1, 3276)
        self.audio_sink = blocks.udp_sink(2, '127.0.0.1', audio_port)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.src, 0), (self.rational_resampler_44k, 0))
        self.connect((self.rational_resampler_44k, 0), (self.agc, 0))
        #self.connect((self.agc, 0), (self.analog_pwr_squelch_xx_0, 0))

        #self.connect((self.analog_pwr_squelch_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.agc, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.same_dec_0, 0))

        self.connect((self.agc, 0), (self.tone_det_0, 0), (self.wat_thresh_msg, 0))
        self.connect((self.agc, 0), (self.tone_det_1, 0), (self.wat_thresh_msg, 1))
        self.connect((self.agc, 0), (self.tone_det_2, 0), (self.wat_thresh_msg, 2))
        #self.connect((self.agc, 0), (self.avg_audio_level, 0), (self.level_thresh_msg, 0))

        self.connect((self.agc, 0), (self.audio_sink_converter, 0), (self.audio_sink, 0))

        self._watcher = _queue_watcher_thread(self.msg_queue, mon_id, audio_port)