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)
Beispiel #2
0
    def test_source_001(self):
        port = 65520

        n_data = 100
        src_data = [float(x) for x in range(n_data)]
        expected_result = tuple(src_data)
        send_data = numpy.array(src_data, dtype=numpy.float32)
        send_data = send_data.tobytes()

        udp_rcv = blocks.udp_source(gr.sizeof_float, '127.0.0.1', port)
        dst = blocks.vector_sink_f()
        self.tb_rcv.connect(udp_rcv, dst)
        self.tb_rcv.start()
        time.sleep(1.0)
        sendsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sendsock.sendto(send_data, ('127.0.0.1', port))
        time.sleep(1.0)
        sendsock.sendto(b'', ('127.0.0.1', port))
        sendsock.sendto(b'', ('127.0.0.1', port))
        sendsock.sendto(b'', ('127.0.0.1', port))
        self.tb_rcv.wait()
        sendsock.close()
        recv_data = tuple(dst.data())

        self.assertEqual(expected_result, recv_data)
    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?
    def __init__(self, samp_rate):
        gr.hier_block2.__init__(
            self, "throttled_source", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)
        )

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

        self.connect(self.source, self.throttle, self)
Beispiel #5
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))    
Beispiel #6
0
  def _setup_source(self, options):
    if options.source == "uhd":
      #UHD source by default
      from gnuradio import uhd
      self._u = uhd.single_usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1)

      if(options.subdev):
        self._u.set_subdev_spec(options.subdev, 0)

      if not self._u.set_center_freq(options.freq):
        print "Failed to set initial frequency"

      #check for GPSDO
      #if you have a GPSDO, UHD will automatically set the timestamp to UTC time
      #as well as automatically set the clock to lock to GPSDO.
      if self._u.get_time_source(0) != 'gpsdo':
        self._u.set_time_now(uhd.time_spec(0.0))

      if options.antenna is not None:
        self._u.set_antenna(options.antenna)

      self._u.set_samp_rate(options.rate)
      options.rate = int(self._u.get_samp_rate()) #retrieve actual

      if options.gain is None: #set to halfway
        g = self._u.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      print "Setting gain to %i" % options.gain
      self._u.set_gain(options.gain)
      print "Gain is %i" % self._u.get_gain()

    #TODO: detect if you're using an RTLSDR or Jawbreaker
    #and set up accordingly.
    elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
        import osmosdr
        self._u = osmosdr.source(options.args)
#        self._u.set_sample_rate(3.2e6) #fixed for RTL dongles
        self._u.set_sample_rate(options.rate)
        if not self._u.set_center_freq(options.freq):
            print "Failed to set initial frequency"

#        self._u.set_gain_mode(0) #manual gain mode
        if options.gain is None:
            options.gain = 34
        self._u.set_gain(options.gain)
        print "Gain is %i" % self._u.get_gain()

        #Note: this should only come into play if using an RTLSDR.
#        lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3)
#        self._resample = filter.rational_resampler_ccf(interpolation=5, decimation=4, taps=lpfiltcoeffs)

    else:
      #semantically detect whether it's ip.ip.ip.ip:port or filename
      if ':' in options.source:
        try:
          ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups()
        except:
          raise Exception("Please input UDP source e.g. 192.168.10.1:12345")
        self._u = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port))
        print "Using UDP source %s:%s" % (ip, port)
      else:
        #self._u = blocks.file_source(gr.sizeof_gr_complex, options.source)
        self._u = ReadByteFile(options)
        print "Using file source %s" % options.source

    print "Rate is %i" % (options.rate,)
Beispiel #7
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))
Beispiel #8
0
    def __init__(self, host, port, pkt_size, eof, wait):
        gr.top_block.__init__(self, "vector_sink")

        udp = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
        sink = blocks.file_sink(gr.sizeof_float, "received.dat")
        self.connect(udp, sink)
Beispiel #9
0
    def __init__(self, options, nchans=16):
        gr.hier_block2.__init__(self,
                                "trunked_feed",
                                gr.io_signature(0,0,gr.sizeof_gr_complex),
                                gr.io_signature(nchans,nchans,gr.sizeof_gr_complex))
        pubsub.__init__(self)
        self._options = options
        self._freqs = {"center": options.center_freq,
                       "ctrl": options.ctrl_freq,
                       "audio": options.ctrl_freq
                      }
        self._nchans = nchans

        if options.source == "uhd":
            #UHD source by default
            from gnuradio import uhd
            src = uhd.usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1)
            if options.subdev is not None:
                src.set_subdev_spec(options.subdev)
            if options.antenna is not None:
                src.set_antenna(options.antenna)

            #pick a reasonable sample rate
            master_clock_rate = src.get_clock_rate()
            acceptable_rates = [i.start() for i in src.get_samp_rates() if i.start() > 8e6 and (master_clock_rate / i.start()) % 4 == 0]
            src.set_samp_rate(min(acceptable_rates))
            self._channel_decimation = 1
            print "Using sample rate: %i" % min(acceptable_rates)
            if options.gain is None: #set to halfway
                g = src.get_gain_range()
                options.gain = (g.start()+g.stop()) / 2.0
            src.set_gain(options.gain)
            print "Gain is %i" % src.get_gain()

        #TODO: detect if you're using an RTLSDR or Jawbreaker
        #and set up accordingly.
        elif options.source == "hackrf" or options.source == "rtlsdr": #RTLSDR dongle or HackRF Jawbreaker
            import osmosdr
            src = osmosdr.source(options.source)
            wat = src.get_sample_rates()
            rates = range(int(wat.start()), int(wat.stop()+1), int(wat.step()))
            acceptable_rates = [i for i in rates if i >= 8e6]
            if len(acceptable_rates) < 1: #we're in single-channel-only mode
                acceptable_rates = (max(rates))
            src.set_sample_rate(min(acceptable_rates))
            src.get_samp_rate = src.get_sample_rate #alias for UHD compatibility in get_rate

            if options.gain is None:
                options.gain = 34
            src.set_gain(options.gain)
            print "Gain is %i" % src.get_gain()

        else:
            #semantically detect whether it's ip.ip.ip.ip:port or filename
            self._rate = options.rate
            if ':' in options.source:
                try:
                    ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups()
                except:
                    raise Exception("Please input UDP source e.g. 192.168.10.1:12345")
                src = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port))
                print "Using UDP source %s:%s" % (ip, port)
            else:
                src = blocks.file_source(gr.sizeof_gr_complex, options.source, repeat=False)
                print "Using file source %s" % options.source

        channel_spacing = 25e3
        self._channel_decimation = int(options.rate / channel_spacing)
        self._filter_bank = filterbank(rate=options.rate,
                                        channel_spacing=channel_spacing) #TODO parameterize

        self.connect(src, self._filter_bank)
        for i in xrange(self._nchans):
            self.connect((self._filter_bank,i), (self, i))

        self._data_src = src
        self._source_name = options.source
        self.set_center_freq(options.center_freq)
        self.set_ctrl_freq(options.ctrl_freq)
        self.set_audio_freq(options.ctrl_freq) #wooboobooboboobobbo

        print "Using master rate: %f" % self.get_rate("master")
        print "Using ctrl rate: %f" % self.get_rate("ctrl")
        print "Using audio rate: %f" % self.get_rate("audio")
 def __init__(self, host, port, pkt_size, sample_rate, eof):
     gr.top_block.__init__(self, "dial_tone_sink")
     udp = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
     sink = audio.sink(sample_rate)
     self.connect(udp, sink)
Beispiel #11
0
  def _setup_source(self, options):
    if options.source == "uhd":
      #UHD source by default
      from gnuradio import uhd
      src = uhd.single_usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1)

      if(options.subdev):
        src.set_subdev_spec(options.subdev, 0)

      if not src.set_center_freq(162.0e6 * (1 + options.error/1.e6)):
        print "Failed to set initial frequency"
      else:
        print "Tuned to %.3fMHz" % (src.get_center_freq() / 1.e6)

      #check for GPSDO
      #if you have a GPSDO, UHD will automatically set the timestamp to UTC time
      #as well as automatically set the clock to lock to GPSDO.
      if src.get_time_source(0) != 'gpsdo':
        src.set_time_now(uhd.time_spec(0.0))

      if options.antenna is not None:
        src.set_antenna(options.antenna)

      src.set_samp_rate(options.rate)

      if options.gain is None: #set to halfway
        g = src.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      print "Setting gain to %i" % options.gain
      src.set_gain(options.gain)
      print "Gain is %i" % src.get_gain()

    #TODO: detect if you're using an RTLSDR or Jawbreaker
    #and set up accordingly.
    elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
        import osmosdr
        src = osmosdr.source(options.args)
        src.set_sample_rate(options.rate)
        src.get_samp_rate = src.get_sample_rate #alias for UHD compatibility
        if not src.set_center_freq(162.0e6 * (1 + options.error/1.e6)):
            print "Failed to set initial frequency"
        else:
            print "Tuned to %.3fMHz" % (src.get_center_freq() / 1.e6)

        if options.gain is None:
            options.gain = 34
        src.set_gain(options.gain)
        print "Gain is %i" % src.get_gain()

    else:
      #semantically detect whether it's ip.ip.ip.ip:port or filename
      self._rate = options.rate
      if ':' in options.source:
        try:
          ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups()
        except:
          raise Exception("Please input UDP source e.g. 192.168.10.1:12345")
        src = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port))
        print "Using UDP source %s:%s" % (ip, port)
      else:
        src = blocks.file_source(gr.sizeof_gr_complex, options.source)
        print "Using file source %s" % options.source

    return src
Beispiel #12
0
    def __init__(self, sc=8):
        gr.top_block.__init__(self)

        self.qapp = QtGui.QApplication(sys.argv)
        ss = open('style.qss')
        sstext = ss.read()
        ss.close()
        self.qapp.setStyleSheet(sstext)

        ##################################################
        # Variables
        ##################################################
        self.port = port = 9999
        self.gan = gan = 1
        self.fi = fi = 70000000
        self.sc = sc
        self.t = t = 1
        self.ab = ab = 32000000
        self.N = N = 1024
        self.IP = IP = "192.168.1.108"
        self.Antena = Antena = "RX2"
	self.remote_IP = "192.168.1.101"
        self.dino = remote_configurator(self.remote_IP, self.port)
        self.ventana = "Hamming"
        self.base = "exponencial"
        self.escala = 'dBm'
        self.y0 = y0 = -100
        self.y1 = y1 = 0
        self.File = File = "datos.txt"

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            N * sc,
            fi / 1e6,
            (sc * ab / N) / 1e6,
            "Frecuencia [MHz]",
            "Potencia",
            "",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.1)
        self.qtgui_vector_sink_f_0.set_y_axis(y0, y1)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("MHz")
        self.qtgui_vector_sink_f_0.set_y_axis_units("dBm")
        self.qtgui_vector_sink_f_0.set_ref_level(0)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, N)
        self.udp_source_0 = blocks.udp_source(gr.sizeof_float*1, IP, port, 1472, True)
        self.RadioGIS_dynamic_sink_0 = RadioGIS.dynamic_sink(N, sc)
        self.non_zero_file_sink_0 = RadioGIS.non_zero_file_sink(N, sc, File)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RadioGIS_dynamic_sink_0, 0), (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.udp_source_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.RadioGIS_dynamic_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.non_zero_file_sink_0, 0))

        self.ctrl_win = control_box()
        self.head_win = header()
        self.ctrl_win.attach_signal(self)

        self.main_box = dialog_box(self.head_win, display_box(self._qtgui_vector_sink_f_0_win), self.ctrl_win)
        self.main_box.show()
Beispiel #13
0
    def __init__(self):
        gr.top_block.__init__(self, "Example5B Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Example5B Rx")
        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", "example5b_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.udp_len = udp_len = 1472 * 8
        self.time_preamble = time_preamble = [
            0.125000 + 0.000000j, 0.522104 - 0.148216j, -0.495528 + 0.114832j,
            -0.267916 + 0.091700j, 0.236544 - 0.138456j, -0.098500 + 0.473800j,
            0.476480 - 0.225344j, -0.187516 + 0.035372j, 0.051776 - 0.353552j,
            -0.104936 + 0.059916j, 0.228684 + 0.117504j, -0.530912 + 0.560756j,
            0.359128 + 0.015872j, -0.132852 + 0.632840j, -0.105164 - 0.368872j,
            0.368272 - 0.032412j, 0.125000 + 0.750000j, 0.463968 + 0.457792j,
            0.151476 - 0.430948j, 0.685052 + 0.238524j, 0.494428 + 0.119428j,
            -0.557540 - 0.050056j, 0.416348 + 0.017368j, 0.104256 - 0.568836j,
            -0.301776 - 0.353552j, 0.079812 + 0.451516j, 0.439152 + 0.528072j,
            0.642060 + 0.178484j, -0.090096 + 0.465096j, -0.446492 + 0.305776j,
            -0.111440 - 0.093688j, -0.538848 - 0.320228j, 0.125000 + 0.000000j,
            -0.538848 + 0.320228j, -0.111440 + 0.093688j,
            -0.446492 - 0.305776j, -0.090096 - 0.465096j, 0.642060 - 0.178484j,
            0.439152 - 0.528072j, 0.079812 - 0.451516j, -0.301776 + 0.353552j,
            0.104256 + 0.568836j, 0.416348 - 0.017368j, -0.557540 + 0.050056j,
            0.494428 - 0.119428j, 0.685052 - 0.238524j, 0.151476 + 0.430948j,
            0.463968 - 0.457792j, 0.125000 - 0.750000j, 0.368272 + 0.032412j,
            -0.105164 + 0.368872j, -0.132852 - 0.632840j, 0.359128 - 0.015872j,
            -0.530912 - 0.560756j, 0.228684 - 0.117504j, -0.104936 - 0.059916j,
            0.051776 + 0.353552j, -0.187516 - 0.035372j, 0.476480 + 0.225344j,
            -0.098500 - 0.473800j, 0.236544 + 0.138456j, -0.267916 - 0.091700j,
            -0.495528 - 0.114832j, 0.522104 + 0.148216j
        ]
        self.threshold = threshold = 9.5
        self.samp_rate = samp_rate = 400000
        self.preamble_len = preamble_len = 64
        self.packet_len = packet_len = 1024
        self.number_len = number_len = 64 * 3
        self.length = length = 96

        ##################################################
        # Blocks
        ##################################################
        self._threshold_range = Range(0, 25, 0.25, 9.5, 200)
        self._threshold_win = RangeWidget(self._threshold_range,
                                          self.set_threshold, "Threshold",
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._threshold_win, 0, 0, 1, 2)
        self.qtgui_time_sink_x_0_0_0_2 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_2.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0_2.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0_0_2.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_0_0_2.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0_0_0_2.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0_0_0_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_2_win, 2,
                                       0, 1, 1)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 1, 0,
                                       1, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Demodulated OFDM  Data",  #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_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 5, 0, 1,
                                       2)
        self.mysvl_triggered_demux_0_0 = mysvl.triggered_demux(
            gr.sizeof_gr_complex * 1, gr.sizeof_float,
            (preamble_len, number_len, packet_len), 1, True)
        self.mysvl_triggered_demux_0 = mysvl.triggered_demux(
            gr.sizeof_gr_complex * 1, gr.sizeof_float,
            (preamble_len, number_len, packet_len), 1, True)
        self.mysvl_sync_channels_0 = mysvl.sync_channels(1024)
        self.mysvl_svl_1 = mysvl.svl(gr.sizeof_gr_complex * 1, 1,
                                     "./inputs/spectrum_maps/one_many_rx.txt",
                                     "./inputs/parameters/one_many_rx.txt")
        self.mysvl_drop_packet_0_0 = mysvl.drop_packet(1024)
        self.mysvl_drop_packet_0 = mysvl.drop_packet(1024)
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
            fft_len=64,
            cp_len=16,
            frame_length_tag_key='frame_' + "length",
            packet_length_tag_key="length",
            bps_header=1,
            bps_payload=1,
            debug_log=False,
            scramble_bits=False)
        self.digital_gfsk_demod_0_0 = digital.gfsk_demod(
            samples_per_symbol=2,
            sensitivity=1.0,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
            samples_per_symbol=2,
            sensitivity=1.0,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.digital_corr_est_cc_0_0 = digital.corr_est_cc((time_preamble), 1,
                                                           0, 0.99)
        self.digital_corr_est_cc_0 = digital.corr_est_cc((time_preamble), 1, 0,
                                                         0.99)
        self.blocks_udp_source_0_0 = blocks.udp_source(
            gr.sizeof_gr_complex * 1, "127.0.0.2", 4000, udp_len, True)
        (self.blocks_udp_source_0_0).set_min_output_buffer(1000000)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1,
                                                     "127.0.0.1", 4000,
                                                     udp_len, True)
        (self.blocks_udp_source_0).set_min_output_buffer(1000000)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "127.0.0.1", 3001, 1472, True)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(
            threshold, threshold, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            threshold, threshold, 0)
        self.blocks_tag_gate_1 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                   False)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_abs_xx_1_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_1 = blocks.abs_ff(1)
        self.blks2_packet_decoder_0_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code="",
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0_0.
                recv_pkt(ok, payload),
            ), )
        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_char_to_float_0_0_0, 0))
        self.connect((self.blks2_packet_decoder_0_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.blocks_abs_xx_1, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_abs_xx_1_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.mysvl_drop_packet_0_0, 1))
        self.connect((self.blocks_char_to_float_0_0_0, 0),
                     (self.mysvl_drop_packet_0, 1))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_abs_xx_1, 0))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.blocks_abs_xx_1_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.mysvl_triggered_demux_0, 0))
        self.connect((self.blocks_tag_gate_0_0, 0),
                     (self.mysvl_triggered_demux_0_0, 0))
        self.connect((self.blocks_tag_gate_1, 0), (self.digital_ofdm_rx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.mysvl_triggered_demux_0, 1))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.mysvl_triggered_demux_0_0, 1))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.digital_corr_est_cc_0, 0))
        self.connect((self.blocks_udp_source_0_0, 0),
                     (self.digital_corr_est_cc_0_0, 0))
        self.connect((self.digital_corr_est_cc_0, 1),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_corr_est_cc_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self.digital_corr_est_cc_0_0, 1),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.digital_corr_est_cc_0_0, 0),
                     (self.blocks_tag_gate_0_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gfsk_demod_0_0, 0),
                     (self.blks2_packet_decoder_0_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.mysvl_drop_packet_0, 0),
                     (self.mysvl_sync_channels_0, 0))
        self.connect((self.mysvl_drop_packet_0_0, 0),
                     (self.mysvl_sync_channels_0, 1))
        self.connect((self.mysvl_svl_1, 0), (self.blocks_tag_gate_1, 0))
        self.connect((self.mysvl_sync_channels_0, 0), (self.mysvl_svl_1, 0))
        self.connect((self.mysvl_sync_channels_0, 1), (self.mysvl_svl_1, 1))
        self.connect((self.mysvl_triggered_demux_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.mysvl_triggered_demux_0, 1),
                     (self.digital_gfsk_demod_0, 0))
        self.connect((self.mysvl_triggered_demux_0, 2),
                     (self.mysvl_drop_packet_0, 0))
        self.connect((self.mysvl_triggered_demux_0, 2),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.mysvl_triggered_demux_0_0, 0),
                     (self.blocks_null_sink_1_0, 0))
        self.connect((self.mysvl_triggered_demux_0_0, 1),
                     (self.digital_gfsk_demod_0_0, 0))
        self.connect((self.mysvl_triggered_demux_0_0, 2),
                     (self.mysvl_drop_packet_0_0, 0))
        self.connect((self.mysvl_triggered_demux_0_0, 2),
                     (self.qtgui_time_sink_x_0_0_0_2, 0))
Beispiel #14
0
    def __init__(self, in_url, samp_rate, channel_bw, freq=0, gain=None,
            fft_nbins=None, decimation=None, threshold=None,
            out_url='stdout://', rounds=-1, spectrum_out=None):
        gr.top_block.__init__(self, "RSTT Signal Detector")
        threshold = threshold or (4,6)

        if fft_nbins is None:
            # set FFT size to get 10 or more bins per channel
            fft_nbins = 10. * samp_rate / channel_bw
            fft_nbins = 2**int(math.ceil(math.log(fft_nbins, 2)))

        if decimation is None:
            # average samples for at least one second
            decimation = int(math.ceil(float(samp_rate) / fft_nbins))

        ntaps = int(2. * fft_nbins / samp_rate * channel_bw)

        if isinstance(threshold, (float, int)):
            threshold = (threshold, )

        self.in_url = in_url
        self.channel_bw = channel_bw
        self.samp_rate = samp_rate
        self.fft_nbins = fft_nbins
        self.decimation = decimation
        if spectrum_out:
            self.spectrum_out = open(spectrum_out, 'w')
        else:
            self.spectrum_out = None
        self.threshold_lo = min(threshold)
        self.threshold_hi = max(threshold)
        self.rounds = rounds
        self.freq = freq
        self.signals = []
# TODO: parametrize
        self.ttl = 1

        args = in_url.split('://', 1)
        if len(args) == 2:
            prefix, args = args
        else:
            prefix, args = "", args[0]
        if prefix == 'osmo-sdr':
            self.src = osmosdr.source( args="numchan=1 " + args )
            self.src.set_sample_rate(samp_rate)
            self.src.set_center_freq(freq, 0)
            if gain is None:
                self.src.set_gain_mode(True, 0)
            else:
                self.src.set_gain_mode(False)
                self.src.set_gain(gain)
                #self.src.set_if_gain(37)
        elif prefix == 'file' or prefix == "":
            self.src = blocks.file_source(gr.sizeof_gr_complex, args, False)
        elif prefix == 'udp':
            host, port = args.split(':', 1)
            self.src = blocks.udp_source(gr.sizeof_gr_complex, host, int(port), 65536, True)
        else:
            raise ValueError('Unsupported schema: "%s"' % in_url)

        self.signal_detector = signal_detector(samp_rate, decimation,
                mk_cos_taps(ntaps), threshold=self.threshold_lo, fft_size=fft_nbins,
                center_freq=freq)
        self.signal_detector.set_signals_detected_handler(self.on_signals_detected)

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

        args = out_url.split('://')
        if len(args) == 2:
            prefix, args = args
        else:
            prefix, args = "", args[0]
        if prefix == "file" or prefix == "":
            self.emit_signals = self._emit_signals_file
            self._out = open(args, 'w')
        elif prefix == "stdout":
            self.emit_signals = self._emit_signals_stdout
        else:
            raise ValueError('Unsupported schma: "%s"' % out_url)
 def init(self):
     self.channel1.sample_rate = 250.0
     self.channel1.color = 'orange'
     self.gr_block = blocks.udp_source(gr.sizeof_float*1, "127.0.0.1", 9999, 1472, True)
Beispiel #16
0
    def __init__(self, callsign='', ip='::', latitude=0, longitude=0, port=7355, recstart=''):
        gr.top_block.__init__(self, "QB50 AU03 i-INSPIRE II decoder")

        ##################################################
        # Parameters
        ##################################################
        self.callsign = callsign
        self.ip = ip
        self.latitude = latitude
        self.longitude = longitude
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = 4
        self.access_code = access_code = "11000011101010100110011001010101"

        ##################################################
        # Blocks
        ##################################################
        self.sync_to_pdu_packed_0 = sync_to_pdu_packed(
            packlen=255+3,
            sync=access_code,
            threshold=threshold,
        )
        self.satellites_u482c_decode_0 = satellites.u482c_decode(False, -1, -1, -1)
        self.satellites_submit_0 = satellites.submit('https://db.satnogs.org/api/telemetry/', 42731, callsign, longitude, latitude, recstart)
        self.satellites_print_timestamp_0 = satellites.print_timestamp('%Y-%m-%d %H:%M:%S', True)
        self.satellites_AU03_telemetry_parser_0 = satellites.au03_telemetry_parser()
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, 48000, 2600, 1000, firdes.WIN_HAMMING, 6.76))
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=10,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short*1, ip, port, 1472, False)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.analog_sig_source_x_0 = analog.sig_source_c(48000, analog.GR_COS_WAVE, -3600, 1, 0)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satellites_print_timestamp_0, 'out'), (self.satellites_AU03_telemetry_parser_0, 'in'))
        self.msg_connect((self.satellites_u482c_decode_0, 'out'), (self.satellites_print_timestamp_0, 'in'))
        self.msg_connect((self.satellites_u482c_decode_0, 'out'), (self.satellites_submit_0, 'in'))
        self.msg_connect((self.sync_to_pdu_packed_0, 'out'), (self.satellites_u482c_decode_0, 'in'))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.sync_to_pdu_packed_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0))
Beispiel #17
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.ntaps = ntaps = 11 * nfilts * sps
        self.excess_bw = excess_bw = 0.4
        self.txtaps = txtaps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, excess_bw, ntaps)
        self.timing_bw = timing_bw = 2 * pi / 100
        self.samp_rate = samp_rate = 320e3
        self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, excess_bw, ntaps)
        self.const_points = const_points = 8

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate / sps,
            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.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=0,
            ref_scale=2.0,
            sample_rate=samp_rate / sps,
            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.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(sps,
                                                             taps=(txtaps),
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.iir_filter_xxx_1 = filter.iir_filter_ffd(([1.0001, -1]),
                                                      ([-1, 1]), True)
        self.iir_filter_xxx_0 = filter.iir_filter_ffd(([10e-3]),
                                                      ([-1, 990e-3]), True)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_bw, (rx_taps), nfilts, 16, 1.5, 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ((1 + 0j), (0.707 + 0.707j), (0 + 1j), (-0.707 + 0.707j),
             (-1 + 0j), (-0.707 - 0.707j), (0 - 1j), (0.707 - 0.707j)), 1)
        self.blocks_vco_c_0_0 = blocks.vco_c(samp_rate / sps, -5, 1)
        self.blocks_vco_c_0 = blocks.vco_c(samp_rate / sps, samp_rate / sps, 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_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_multiply_xx_4 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff(
            (0.125, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.125, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 500)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1)
        self.blocks_complex_to_arg_1 = blocks.complex_to_arg(1)
        self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, 10e3, 1, 0)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, const_points, 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_throttle_0_0, 0))
        self.connect((self.blocks_complex_to_arg_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_arg_1, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.blocks_delay_0_0, 0), (self.iir_filter_xxx_1, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0),
                     (self.blocks_complex_to_arg_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_vco_c_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.iir_filter_xxx_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_delay_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.blocks_multiply_xx_3, 0))
        self.connect((self.blocks_multiply_xx_2, 0),
                     (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 0))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 1))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 2))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 3))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 4))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 5))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 6))
        self.connect((self.blocks_multiply_xx_3, 0),
                     (self.blocks_multiply_xx_4, 7))
        self.connect((self.blocks_multiply_xx_4, 0),
                     (self.blocks_complex_to_arg_1, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.blocks_vco_c_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.blocks_vco_c_0_0, 0),
                     (self.blocks_multiply_xx_3, 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_multiply_xx_1, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 2))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 3))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 4))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 5))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 6))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_1, 7))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.iir_filter_xxx_1, 0), (self.blocks_vco_c_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_throttle_0, 0))
Beispiel #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Pfb Test3")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Pfb Test3")
        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_test3")

        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 = 25e3

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0_1 = 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_1.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0_1.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_1.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_1.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_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_1.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_1.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_1.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_1_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_1_win)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex*1, '0.0.0.0', 7355, 1472, True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_udp_source_0, 0), (self.qtgui_waterfall_sink_x_0_1, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Transceiverloopbackuhd Nogui")

        ##################################################
        # 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.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_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_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))    
Beispiel #20
0
    def __init__(self,
                 callsign='',
                 invert=1,
                 ip='::',
                 latitude=0,
                 longitude=0,
                 port=7355,
                 recstart=''):
        gr.top_block.__init__(self, "AAUSAT-4 decoder")

        ##################################################
        # Parameters
        ##################################################
        self.callsign = callsign
        self.invert = invert
        self.ip = ip
        self.latitude = latitude
        self.longitude = longitude
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = 8
        self.access_code = access_code = "010011110101101000110100010000110101010101000010"

        ##################################################
        # Blocks
        ##################################################
        self.sync_to_pdu_packed_0_0 = sync_to_pdu_packed(
            packlen=251,
            sync=access_code,
            threshold=threshold,
        )
        self.sync_to_pdu_packed_0 = sync_to_pdu_packed(
            packlen=251,
            sync=access_code,
            threshold=threshold,
        )
        self.sids_submit_0 = sids.submit(
            'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 41460, callsign,
            longitude, latitude, recstart)
        self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(
            5.0, 0.25 * 0.175 * 0.175, 0.005, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            20.0, 0.25 * 0.175 * 0.175, 0.005, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip,
                                                     port, 1472, False)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (invert * 10, ))
        self.aausat_aausat4_fec_0 = aausat.aausat4_fec(False)
        self.aausat_aausat4_beacon_parser_0 = aausat.aausat4_beacon_parser()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.aausat_aausat4_fec_0, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.aausat_aausat4_fec_0, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.sids_print_timestamp_0, 'out'),
                         (self.aausat_aausat4_beacon_parser_0, 'in'))
        self.msg_connect((self.sync_to_pdu_packed_0, 'out'),
                         (self.aausat_aausat4_fec_0, 'in'))
        self.msg_connect((self.sync_to_pdu_packed_0_0, 'out'),
                         (self.aausat_aausat4_fec_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.sync_to_pdu_packed_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.sync_to_pdu_packed_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 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())

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_sink_x_0 = qtgui.sink_f(
        	256, #fftsize
        	firdes.WIN_HANN, #wintype
        	50, #fc
        	250, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/100)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
          
        #test_source = TestSource()
        test_source = blocks.udp_source(gr.sizeof_float*1, "127.0.0.1", 9999, 1472, True)

        src = UDPSource()

        # Signal Conditioning: DC Block and 50 Hz Notch Filter
        ch1 = NotchFilter(src.channel1)
        ch1 = DCBlock(ch1)

        #notched = NotchFilter(notched)
        #notched = NotchFilter(notched)
        alpha = BandPass(ch1, 8, 12)
        alpha.color = 'green'
        alpha = RMS(alpha, 0.02)
        #alpha = ExponentialAverage(alpha, 5.1)

        smrlevel = RMS(BandPass(ch1, 9.5, 12.5), 0.02)

        oscclient = OSCSend(smrlevel, '/0x00/filter')

        osci = Oscilloscope(alpha)
        spec = BarSpectrogram(ch1, hi=42)

        self.top_layout.addWidget(osci.widget)
        self.top_layout.addWidget(spec.widget)

        visited = self.wireup(osci)
        visited = self.wireup(oscclient, visited)
        self.wireup(spec, visited)
Beispiel #22
0
    def __init__(self,
                 callsign='',
                 ip='::',
                 latitude=0,
                 longitude=0,
                 port=7355,
                 recstart=''):
        gr.top_block.__init__(self, "GOMX-1 decoder")

        ##################################################
        # Parameters
        ##################################################
        self.callsign = callsign
        self.ip = ip
        self.latitude = latitude
        self.longitude = longitude
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = 4
        self.access_code = access_code = "11000011101010100110011001010101"

        ##################################################
        # Blocks
        ##################################################
        self.sync_to_pdu_packed_0 = sync_to_pdu_packed(
            packlen=255 + 3,
            sync=access_code,
            threshold=threshold,
        )
        self.sids_submit_0 = sids.submit(
            'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 39430, callsign,
            longitude, latitude, recstart)
        self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1, firdes.low_pass(1, 48000, 2600, 1000, firdes.WIN_HAMMING, 6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=10,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip,
                                                     port, 1472, False)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.ax100_gomx1_decode_0 = ax100.gomx1_decode(False)
        self.ax100_gomx1_beacon_parser_0 = ax100.gomx1_beacon_parser()
        self.analog_sig_source_x_0 = analog.sig_source_c(
            48000, analog.GR_COS_WAVE, -3600, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax100_gomx1_decode_0, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.ax100_gomx1_decode_0, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.sids_print_timestamp_0, 'out'),
                         (self.ax100_gomx1_beacon_parser_0, 'in'))
        self.msg_connect((self.sync_to_pdu_packed_0, 'out'),
                         (self.ax100_gomx1_decode_0, 'in'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_short_to_float_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.sync_to_pdu_packed_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_gmsk_demod_0, 0))
 def __init__(self, host, port, pkt_size, sample_rate, eof):
     gr.top_block.__init__(self, "dial_tone_sink")
     udp = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
     sink = audio.sink(sample_rate)
     self.connect(udp, sink)
    def __init__(self):
        gr.top_block.__init__(self)

        self.qapp = QtGui.QApplication(sys.argv)
        ss = open('style.qss')
        sstext = ss.read()
        ss.close()
        self.qapp.setStyleSheet(sstext)

        ##################################################
        # Variables
        ##################################################
        self.port = port = 9999
        self.gan = gan = 10
        self.fc = fc = 99700000
        self.ab = ab = 20000000
        self.N = N = 1024
        self.n = n = 512
        self.IP = IP = "192.168.1.115"
        self.Antena = Antena = "RX2"
	self.remote_IP = "192.168.1.127"
        self.dino = remote_configurator(self.remote_IP, self.port)
        self.ventana = "Hamming"
        self.base = "exponencial"
        self.y0 = y0 = -100
        self.y1 = y1 = 0
        self.frequencies = frequencies = [0, 200, 600, 700, 900, 1000]
        self.amplitudes = amplitudes = [0, -20, -20, -15, -15, -34]

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            N,
            (fc - ab / 2) / 1e6,
            (ab / N) / 1e6,
            "Frecuencia (MHz)",
            "Amplitud",
            "",
            2 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.1)
        self.qtgui_vector_sink_f_0.set_y_axis(y0, y1)
        self.qtgui_vector_sink_f_0.enable_autoscale(False)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_vec_average(0.1)
        self.qtgui_vector_sink_f_0.set_x_axis_units("Hz")
        self.qtgui_vector_sink_f_0.set_y_axis_units("dBm")
        self.qtgui_vector_sink_f_0.set_ref_level(-90)
        
        labels = ["Espectro", "Mascara", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 3, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "yellow", "black", "cyan",
                  "magenta", "green", "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(2):
            if len(labels[i]) == 0:
                self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
        	N, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	fc - ab / 2, #fc
        	ab / N, #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)
        
        if float == type(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.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, N)
        self.udp_source_0 = blocks.udp_source(gr.sizeof_float*1, IP, port, 1472, True)
        self.RadioGIS_mask_0 = RadioGIS.mask(frequencies, amplitudes, N)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.RadioGIS_mask_0, 0), (self.qtgui_vector_sink_f_0, 1))
        self.connect((self.udp_source_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.qtgui_vector_sink_f_0, 0))    
        self.connect((self.udp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) 

        self.ctrl_win = control_box()
        self.head_win = header()
        self.ctrl_win.attach_signal(self)

        self.main_box = dialog_box(self.head_win, display_box(self._qtgui_vector_sink_f_0_win), (self._qtgui_waterfall_sink_x_0_win), self.ctrl_win)
        self.main_box.show()
Beispiel #25
0
 def __init__(self, host, port, pkt_size, sample_rate, eof):
     gr.top_block.__init__(self, "audio_sink")
     src = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
     dst = audio.sink(sample_rate)
     self.connect(src, dst)
    def __init__(self):
        gr.top_block.__init__(self, "SSB Transmitter V1 - F1ATB - MAY 2020")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2400000
        self.LSB_USB = LSB_USB = 1
        self.GainRF_TX = GainRF_TX = 100
        self.GainIF_TX = GainIF_TX = 300
        self.GainBB_TX = GainBB_TX = 40
        self.Fr_TX = Fr_TX = 145100000

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 9004), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=240,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " +
                                           '0x00664765')
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(Fr_TX, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(GainRF_TX, 0)
        self.osmosdr_sink_0.set_if_gain(GainIF_TX, 0)
        self.osmosdr_sink_0.set_bb_gain(GainBB_TX, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.hilbert_fc_0 = filter.hilbert_fc(64, firdes.WIN_HAMMING, 6.76)
        (self.hilbert_fc_0).set_min_output_buffer(10)
        (self.hilbert_fc_0).set_max_output_buffer(10)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1,
                                                     '127.0.0.1', 9005, 512,
                                                     True)
        (self.blocks_udp_source_0).set_max_output_buffer(2048)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (LSB_USB, ))
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate / 240,
                                     -1300 + LSB_USB * 1500,
                                     1300 + LSB_USB * 1500, 200,
                                     firdes.WIN_HAMMING, 6.76))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.band_pass_filter_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_short_to_float_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.hilbert_fc_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.osmosdr_sink_0, 0))