def tune_next_control_channel(self):
        self.control_channel_i += 1
        if (self.control_channel_i >= len(self.system['channels'])):
            self.control_channel_i = 0

        self.control_channel = self.system['channels'][self.control_channel_i]
        self.lock()
        if self.source != None:
            if self.modulation == 'C4FM':
                self.disconnect(self.source, self.control_prefilter)
            elif self.modulation == 'CQPSK':
                self.disconnect(self.source, self.fm_demod)
                self.disconnect(self.source, self.resampler)
        self.connector.release_channel()
        channel_id, port = self.connector.create_channel(
            self.channel_rate, self.control_channel)
        for x in range(0, 3):
            try:
                self.source = zeromq.sub_source(
                    gr.sizeof_gr_complex * 1, 1,
                    'tcp://%s:%s' % (self.connector.host, port))
                break
            except Exception as e:
                self.log.error('Exception in zeromq source creation %s' % e)

        if self.modulation == 'C4FM':
            self.connect(self.source, self.control_prefilter)
        elif self.modulation == 'CQPSK':
            self.connect(self.source, self.fm_demod)
            self.connect(self.source, self.resampler)

        self.unlock()
        self.log.info('CC Change %s' % self.control_channel)
        self.decodequeue.flush()
Пример #2
0
    def test_004(self):

        #test that no message is received with wrong key
        vlen = 10
        raw_data = [
            numpy.array(range(vlen), 'float32') * 100,
            numpy.array(range(vlen, 2 * vlen), 'float32') * 100
        ]
        src_data = [a.tostring() for a in raw_data]

        src_data = [b"filter_key"] + src_data

        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float,
                                              vlen,
                                              self._address,
                                              key="wrong_filter_key")
        sink = blocks.vector_sink_f(vlen)
        self.tb.connect(zeromq_sub_source, sink)

        self.tb.start()
        time.sleep(0.05)
        self.pub_socket.send_multipart(src_data)
        time.sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        #no signal received with wrong key
        assert (len(sink.data()) == 0)
Пример #3
0
    def __init__(
        self,
        directory_name=".",
        file_name="test.fits",
        num_bins=4096,
        samp_rate=2400000,
    ):
        gr.top_block.__init__(self, "radio_save_spec_fits")

        ##################################################
        # Parameters
        ##################################################
        self.directory_name = directory_name
        self.file_name = file_name
        self.num_bins = num_bins
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_float, num_bins,
                                                     "tcp://127.0.0.1:5562",
                                                     100, True, -1)
        self.save_fits_file = save_fits_file.blk(directory=directory_name,
                                                 filename=file_name,
                                                 vec_length=num_bins)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.zeromq_sub_source_0, 0), (self.save_fits_file, 0))
Пример #4
0
    def tune_next_control(self):
        self.control_channel_key += 1
        if (self.control_channel_key >= len(self.channels)):
            self.control_channel_key = 0
        self.control_channel = self.channels[self.channels_list[
            self.control_channel_key]]

        self.lock()

        if self.source != None:
            self.disconnect(self.source, self.control_quad_demod)

        self.connector.release_channel()
        channel_id, port = self.connector.create_channel(
            self.channel_rate, self.control_channel)
        for tries in 1, 2, 3:
            try:
                self.source = zeromq.sub_source(
                    gr.sizeof_gr_complex * 1, 1,
                    'tcp://%s:%s' % (self.connector.host, port))
                break
            except:
                pass
        self.connect(self.source, self.control_quad_demod)

        self.unlock()
        self.log.info('Control Channel retuned to %s' % (self.control_channel))

        self.control_msg_sink_msgq.flush()
Пример #5
0
    def test_003(self):

        #append filter_key to sent message and check that message is correctly received (obv. without key)

        # Construct multipart source data to publish
        vlen = 10
        raw_data = [
            numpy.array(range(vlen), 'float32') * 100,
            numpy.array(range(vlen, 2 * vlen), 'float32') * 100
        ]
        src_data = [a.tostring() for a in raw_data]

        src_data = [b"filter_key"] + src_data

        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float,
                                              vlen,
                                              self._address,
                                              key="filter_key")
        sink = blocks.vector_sink_f(vlen)
        self.tb.connect(zeromq_sub_source, sink)

        self.tb.start()
        time.sleep(0.05)
        self.pub_socket.send_multipart(src_data)
        time.sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # Source block will concatenate everything together
        expected_data = numpy.concatenate(raw_data)
        self.assertFloatTuplesAlmostEqual(sink.data(), expected_data)
Пример #6
0
    def __init__(self,
                 block_size=40,
                 input_address='tcp://localhost',
                 input_port=35000,
                 one_in=24,
                 origin='some_gs'):
        gr.hier_block2.__init__(self, self.__class__.__name__,
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self.block_size = block_size
        self.input_address = input_address
        self.input_port = input_port
        self.one_in = one_in
        self.origin = origin

        zmq_input = '%s:%d' % (input_address, input_port)
        self.src = zeromq.sub_source(gr.sizeof_short, 1, zmq_input, 100, True,
                                     -1)
        self.cis2c = clever_ishort2complex()

        dest_filename = datetime.now().strftime('%Y.%m.%d.%H.%M.%S_seer_' +
                                                origin + '_block_size_' +
                                                str(block_size) + '_one_in_' +
                                                str(one_in) + '.int16')
        self.file_sink = blocks.file_sink(gr.sizeof_short, dest_filename,
                                          False)
        self.file_sink.set_unbuffered(False)

        self.connect(self.cis2c, self)
        self.connect(self.src, self.file_sink)
        self.connect(self.src, self.cis2c)
Пример #7
0
    def __init__(self):
        gr.top_block.__init__(self, "Capture The Flag")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Capture The Flag")
        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", "ctf_zmq_to_file")

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

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.symbols_per_byte = symbols_per_byte = 4
        self.samp_rate = samp_rate = 25000 * sps
        self.nfilts = nfilts = 32
        self.eb = eb = .35
        self.M = M = 4

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(
            gr.sizeof_gr_complex, 4, 'tcp://192.168.10.101:1234', 100, False,
            -1)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 4, 500000)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 4,
            '/share/git/gr-bfctfdata/grcon2019_ctf_5second_ota_marriott.dat',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.blocks_head_0, 0))
Пример #8
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options

        # socket addresses
        rpc_adr = "tcp://*:6667"
        probe_adr = "tcp://*:5557"
        source_adr = "tcp://"+self.options.servername+":5555"

        # blocks
        #self.zmq_source = zeromq.req_source(gr.sizeof_float, 1, source_adr)
        #self.zmq_source = zeromq.pull_source(gr.sizeof_float, 1, source_adr)
        self.zmq_source = zeromq.sub_source(gr.sizeof_float, 1, source_adr)
        #self.zmq_probe = zeromq.push_sink(gr.sizeof_float, 1, probe_adr)
        self.zmq_probe = zeromq.pub_sink(gr.sizeof_float, 1, probe_adr)

        # connects
        self.connect(self.zmq_source, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zeromq.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr)
        self.rpc_manager.add_interface("start_fg",self.start_fg)
        self.rpc_manager.add_interface("stop_fg",self.stop_fg)
        self.rpc_manager.start_watcher()
Пример #9
0
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.options = options

        # socket addresses
        rpc_adr = "tcp://*:6667"
        probe_adr = "tcp://*:5557"
        source_adr = "tcp://" + self.options.servername + ":5555"

        # blocks
        #self.zmq_source = zeromq.req_source(gr.sizeof_float, 1, source_adr)
        #self.zmq_source = zeromq.pull_source(gr.sizeof_float, 1, source_adr)
        self.zmq_source = zeromq.sub_source(gr.sizeof_float, 1, source_adr)
        #self.zmq_probe = zeromq.push_sink(gr.sizeof_float,probe_adr)
        self.zmq_probe = zeromq.pub_sink(gr.sizeof_float, probe_adr)

        # connects
        self.connect(self.zmq_source, self.zmq_probe)

        # ZeroMQ
        self.rpc_manager = zeromq.rpc_manager()
        self.rpc_manager.set_reply_socket(rpc_adr)
        self.rpc_manager.add_interface("start_fg", self.start_fg)
        self.rpc_manager.add_interface("stop_fg", self.stop_fg)
        self.rpc_manager.start_watcher()
Пример #10
0
    def test_002 (self): 
        # same as test_001, but insert a tag and set key filter 
        vlen = 10
        src_data = list(range(vlen))*100

        src_tags = tuple([make_tag('key', 'val', 0, 'src'), make_tag('key', 'val', 1, 'src')])

        src = blocks.vector_source_f(src_data, False, vlen, tags=src_tags)
        zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:0", 0, pass_tags=True, key="filter_key")
        address = zeromq_pub_sink.last_endpoint()
        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, address, 0, pass_tags=True, key="filter_key")
        sink = blocks.vector_sink_f(vlen)
        self.send_tb.connect(src, zeromq_pub_sink)
        self.recv_tb.connect(zeromq_sub_source, sink)

        # start both flowgraphs
        self.recv_tb.start()
        time.sleep(0.5)
        self.send_tb.start()
        time.sleep(0.5)
        self.recv_tb.stop()
        self.send_tb.stop()
        self.recv_tb.wait()
        self.send_tb.wait()

        # compare data
        self.assertFloatTuplesAlmostEqual(sink.data(), src_data)

        # compare all tags
        rx_tags = sink.tags()
        self.assertEqual(len(src_tags), len(rx_tags))

        for in_tag, out_tag in zip(src_tags, rx_tags):
            self.assertTrue(compare_tags(in_tag, out_tag)) 
Пример #11
0
    def __init__(self,
                 frequency=220.352e6,
                 rf_gain=25,
                 if_gain=0,
                 bb_gain=0,
                 use_zeromq=False,
                 server="tcp://127.0.0.1:10444",
                 server_control="tcp://127.0.0.1:10445"):

        gr.hier_block2.__init__(
            self,
            "osmo_or_zmq_source",
            # Input signature
            gr.io_signature(0, 0, 1),
            # Output signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))

        samp_rate = 2000000
        self.use_zeromq = use_zeromq

        if not use_zeromq:
            import osmosdr
            self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) +
                                                   " " + '')
            self.osmosdr_source_0.set_sample_rate(samp_rate)
            self.osmosdr_source_0.set_center_freq(frequency, 0)
            self.osmosdr_source_0.set_freq_corr(0, 0)
            self.osmosdr_source_0.set_dc_offset_mode(0, 0)
            self.osmosdr_source_0.set_iq_balance_mode(0, 0)
            self.osmosdr_source_0.set_gain_mode(False, 0)
            self.osmosdr_source_0.set_gain(rf_gain, 0)
            self.osmosdr_source_0.set_if_gain(if_gain, 0)
            self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
            self.osmosdr_source_0.set_antenna('', 0)
            self.osmosdr_source_0.set_bandwidth(2000000, 0)
            self.src = self.osmosdr_source_0
        else:
            from gnuradio import zeromq
            self.zeromq_source = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                   server, 100, False, -1)
            self.rpc_mgr_server = zeromq.rpc_manager()
            self.rpc_mgr_server.set_request_socket(server_control)
            self.rpc_mgr_server.request("set_sample_rate", [samp_rate])
            self.rpc_mgr_server.request("set_rf_gain", [rf_gain])
            self.rpc_mgr_server.request("set_if_gain", [if_gain])
            self.rpc_mgr_server.request("set_bb_gain", [bb_gain])
            self.rpc_mgr_server.request(
                "set_ppm", [0]
            )  # Not using hardware correction since it behaves differently on different hardware
            self.rpc_mgr_server.request("set_frequency", [frequency])
            self.src = self.zeromq_source

        self.connect(self.src, (self, 0))
Пример #12
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Gmsk Send")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 200e3

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_char, 1, "tcp://127.0.0.1:5558", 1000, False)
        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(102.3e6, 0)
        self.uhd_usrp_sink_0.set_gain(75, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(200e3, 0)
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=2,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
        		samples_per_symbol=2,
        		bits_per_symbol=1,
        		preamble="",
        		access_code="",
        		pad_for_usrp=True,
        	),
        	payload_length=19,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0))    
        self.connect((self.digital_gmsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.zeromq_sub_source_0, 0), (self.blks2_packet_encoder_0, 0))    

	###
    	t = Thread(target=sub, args=(self.change_freq,))
    	t.start()
Пример #13
0
    def test_001 (self):
        vlen = 10
        src_data = numpy.array(range(vlen)*100, 'float32')
        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555")
        sink = blocks.vector_sink_f(vlen)
        self.tb.connect(zeromq_sub_source, sink)

        self.tb.start()
        self.pub_socket.send(src_data.tostring())
        time.sleep(0.25)
        self.tb.stop()
        self.tb.wait()
        self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
Пример #14
0
 def test_001(self):
     vlen = 10
     src_data = range(vlen) * 100
     src = blocks.vector_source_f(src_data, False, vlen)
     zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:5556", 0)
     zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5556", 0)
     sink = blocks.vector_sink_f(vlen)
     self.tb.connect(src, zeromq_pub_sink)
     self.tb.connect(zeromq_sub_source, sink)
     self.tb.start()
     time.sleep(0.25)
     self.tb.stop()
     self.tb.wait()
     self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
Пример #15
0
    def test_001 (self):
        vlen = 10
        src_data = numpy.array(list(range(vlen))*100, 'float32')
        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5559")
        sink = blocks.vector_sink_f(vlen)
        self.tb.connect(zeromq_sub_source, sink)

        self.tb.start()
        time.sleep(0.05)
        self.pub_socket.send(src_data.tostring())
        time.sleep(0.25)
        self.tb.stop()
        self.tb.wait()
        self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
Пример #16
0
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")

        ##################################################
        # Variables
        ##################################################
        self.bw = bw = 250000
        self.time_wait = time_wait = 200
        self.threshold = threshold = 10
        self.sf = sf = 7
        self.samp_rate = samp_rate = bw
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 1
        self.multi_control = multi_control = True
        self.mult_const = mult_const = 1
        self.impl_head = impl_head = True
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 4

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     'tcp://127.0.0.1:50246',
                                                     100, False, -1)
        self.lora_sdr_hier_rx_1 = lora_sdr.hier_rx(samp_rate, bw, sf,
                                                   impl_head, cr, pay_len,
                                                   has_crc, [8, 16], True)
        self.lora_sdr_frame_detector_1 = lora_sdr.frame_detector(sf, 10)
        self.interp_fir_filter_xxx_0_1_0 = filter.interp_fir_filter_ccc(
            4, (-0.128616616593872, -0.212206590789194, -0.180063263231421,
                3.89817183251938e-17, 0.300105438719035, 0.636619772367581,
                0.900316316157106, 1, 0.900316316157106, 0.636619772367581,
                0.300105438719035, 3.89817183251938e-17, -0.180063263231421,
                -0.212206590789194, -0.128616616593872))
        self.interp_fir_filter_xxx_0_1_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_1_0.set_min_output_buffer(20000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.interp_fir_filter_xxx_0_1_0, 0),
                     (self.lora_sdr_hier_rx_1, 0))
        self.connect((self.lora_sdr_frame_detector_1, 0),
                     (self.interp_fir_filter_xxx_0_1_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.lora_sdr_frame_detector_1, 0))
Пример #17
0
    def __init__(self,
                 zmq_address_iq_in='tcp://127.0.0.1:5052',
                 zmq_address_iq_out='tcp://*:5051'):
        gr.top_block.__init__(self, "Zero Mq Split A")

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

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.limesdr_source_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.limesdr_sink_0, 0))
Пример #18
0
 def test_001(self):
     vlen = 10
     src_data = range(vlen) * 100
     src = blocks.vector_source_f(src_data, False, vlen)
     zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen,
                                       "tcp://127.0.0.1:5556", 0)
     zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen,
                                           "tcp://127.0.0.1:5556", 0)
     sink = blocks.vector_sink_f(vlen)
     self.tb.connect(src, zeromq_pub_sink)
     self.tb.connect(zeromq_sub_source, sink)
     self.tb.start()
     time.sleep(0.25)
     self.tb.stop()
     self.tb.wait()
     self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
Пример #19
0
    def __init__(self, directory_name="./rf_data", samp_rate=2400000):
        gr.top_block.__init__(self, "radio_save_raw")

        ##################################################
        # Parameters
        ##################################################
        self.directory_name = directory_name
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     'tcp://127.0.0.1:5558',
                                                     100, True, -1)
        self.gr_digital_rf_digital_rf_channel_sink_0 = gr_digital_rf.digital_rf_channel_sink(
            channel_dir=directory_name,
            dtype=np.complex64,
            subdir_cadence_secs=3600,
            file_cadence_millisecs=1000,
            sample_rate_numerator=int(samp_rate),
            sample_rate_denominator=1,
            start='now',
            ignore_tags=False,
            is_complex=True,
            num_subchannels=1,
            uuid_str=None,
            center_frequencies=[],
            metadata={},
            is_continuous=True,
            compression_level=0,
            checksum=False,
            marching_periods=True,
            stop_on_skipped=False,
            stop_on_time_tag=False,
            debug=False,
            min_chunksize=None,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.gr_digital_rf_digital_rf_channel_sink_0, 0))
Пример #20
0
 def test_001 (self):
     vlen = 10
     src_data = list(range(vlen))*100
     src = blocks.vector_source_f(src_data, False, vlen)
     zeromq_pub_sink = zeromq.pub_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:0", 0)
     address = zeromq_pub_sink.last_endpoint()
     zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, address, 0)
     sink = blocks.vector_sink_f(vlen)
     self.send_tb.connect(src, zeromq_pub_sink)
     self.recv_tb.connect(zeromq_sub_source, sink)
     self.recv_tb.start()
     time.sleep(0.5)
     self.send_tb.start()
     time.sleep(0.5)
     self.recv_tb.stop()
     self.send_tb.stop()
     self.recv_tb.wait()
     self.send_tb.wait()
     self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
Пример #21
0
    def __init__(self,
                 bandwidth=125000,
                 capture_freq=868500000,
                 decoded_out_port=40868,
                 samp_rate=1000000,
                 spreading_factor=12,
                 zmq_address_iq_in='tcp://127.0.0.1:5051'):
        gr.top_block.__init__(self, "Zero Mq Split B")

        ##################################################
        # Parameters
        ##################################################
        self.bandwidth = bandwidth
        self.capture_freq = capture_freq
        self.decoded_out_port = decoded_out_port
        self.samp_rate = samp_rate
        self.spreading_factor = spreading_factor
        self.zmq_address_iq_in = zmq_address_iq_in

        ##################################################
        # Variables
        ##################################################
        self.offset = offset = 0

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     zmq_address_iq_in, -1,
                                                     False, -1)
        self.lora_message_socket_sink_0 = lora.message_socket_sink(
            '127.0.0.1', decoded_out_port, 0)
        self.lora_lora_receiver_0_0 = lora.lora_receiver(
            samp_rate, capture_freq, (capture_freq, ), bandwidth,
            spreading_factor, False, 4, True, False, False, 1, False, False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.lora_lora_receiver_0_0, 'frames'),
                         (self.lora_message_socket_sink_0, 'in'))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.lora_lora_receiver_0_0, 0))
Пример #22
0
    def test_002 (self):
        vlen = 10

        # Construct multipart source data to publish
        raw_data = [numpy.array(range(vlen)*100, 'float32'), numpy.array(range(vlen, 2*vlen)*100, 'float32')]
        src_data = [a.tostring() for a in raw_data]
        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555")
        sink = blocks.vector_sink_f(vlen)
        self.tb.connect(zeromq_sub_source, sink)

        self.tb.start()
        self.pub_socket.send_multipart(src_data)
        time.sleep(0.25)
        self.tb.stop()
        self.tb.wait()

        # Source block will concatenate everything together
        expected_data = numpy.concatenate(raw_data)
        self.assertFloatTuplesAlmostEqual(sink.data(), expected_data)
Пример #23
0
 def test_001(self):
     vlen = 10
     src_data = list(range(vlen)) * 100
     src = blocks.vector_source_f(src_data, False, vlen)
     zeromq_pub_sink = zeromq.pub_sink("tcp://127.0.0.1:0", 0)
     address = zeromq_pub_sink.last_endpoint()
     zeromq_sub_source = zeromq.sub_source(address, 0)
     sink = blocks.vector_sink_f(vlen)
     self.send_tb.connect(src, zeromq_pub_sink)
     self.recv_tb.connect(zeromq_sub_source, sink)
     self.recv_tb.start()
     time.sleep(0.5)
     self.send_tb.start()
     time.sleep(0.5)
     self.recv_tb.stop()
     self.send_tb.stop()
     # self.recv_tb.wait()
     # self.send_tb.wait()
     self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
Пример #24
0
    def __init__(self, frequency=220.352e6, rf_gain=25, if_gain=0, bb_gain=0, use_zeromq=False, server="tcp://127.0.0.1:10444", server_control="tcp://127.0.0.1:10445"):

        gr.hier_block2.__init__(self,
                                "osmo_or_zmq_source",
                                # Input signature
                                gr.io_signature(0, 0, 1),
                                # Output signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        samp_rate = 2000000
        self.use_zeromq = use_zeromq

        if not use_zeromq:
            import osmosdr
            self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
            self.osmosdr_source_0.set_sample_rate(samp_rate)
            self.osmosdr_source_0.set_center_freq(frequency, 0)
            self.osmosdr_source_0.set_freq_corr(0, 0)
            self.osmosdr_source_0.set_dc_offset_mode(0, 0)
            self.osmosdr_source_0.set_iq_balance_mode(0, 0)
            self.osmosdr_source_0.set_gain_mode(False, 0)
            self.osmosdr_source_0.set_gain(rf_gain, 0)
            self.osmosdr_source_0.set_if_gain(if_gain, 0)
            self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
            self.osmosdr_source_0.set_antenna('', 0)
            self.osmosdr_source_0.set_bandwidth(2000000, 0)
            self.src = self.osmosdr_source_0
        else:
            from gnuradio import zeromq
            self.zeromq_source = zeromq.sub_source(gr.sizeof_gr_complex, 1, server, 100, False, -1)
            self.rpc_mgr_server = zeromq.rpc_manager()
            self.rpc_mgr_server.set_request_socket(server_control)
            self.rpc_mgr_server.request("set_sample_rate",[samp_rate])
            self.rpc_mgr_server.request("set_rf_gain",[rf_gain])
            self.rpc_mgr_server.request("set_if_gain",[if_gain])
            self.rpc_mgr_server.request("set_bb_gain",[bb_gain])
            self.rpc_mgr_server.request("set_ppm",[0]) # Not using hardware correction since it behaves differently on different hardware
            self.rpc_mgr_server.request("set_frequency",[frequency])
            self.src = self.zeromq_source


        self.connect(self.src, (self, 0))
Пример #25
0
    def test_002 (self):
        vlen = 10

        # Construct multipart source data to publish
        raw_data = [numpy.array(range(vlen), 'float32')*100, numpy.array(range(vlen, 2*vlen), 'float32')*100]
        src_data = [a.tostring() for a in raw_data]
        zeromq_sub_source = zeromq.sub_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5559")
        sink = blocks.vector_sink_f(vlen)
        self.tb.connect(zeromq_sub_source, sink)

        self.tb.start()
        time.sleep(0.05)
        self.pub_socket.send_multipart(src_data)
        time.sleep(0.25)
        self.tb.stop()
        self.tb.wait()

        # Source block will concatenate everything together
        expected_data = numpy.concatenate(raw_data)
        self.assertFloatTuplesAlmostEqual(sink.data(), expected_data)
Пример #26
0
    def __init__(self, directory_name=".", num_bins=4096):
        gr.top_block.__init__(self, "radio_calibrate")

        ##################################################
        # Parameters
        ##################################################
        self.directory_name = directory_name
        self.num_bins = num_bins

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_float, num_bins, 'tcp://127.0.0.1:5560', 100, True, -1)
        self.save_calibration = save_calibration.blk(directory=directory_name, filename='calibration.json', vec_length=num_bins, poly_smoothing_order=25)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.zeromq_sub_source_0, 0), (self.save_calibration, 0))
Пример #27
0
    def __init__(self):
        gr.top_block.__init__(self, "OPS-SAT UHF demodulator/decoder")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OPS-SAT UHF demodulator/decoder")
        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", "os_demod_decode")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 57600
        self.baud_rate = baud_rate = 9600
        self.gaussian_taps = gaussian_taps = firdes.gaussian(
            1.5, 2 * (samp_rate / baud_rate), 0.5, 12)
        self.gain_mu = gain_mu = 0.175

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     'tcp://127.0.0.1:5555',
                                                     100, False, -1)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1,
                                                 'tcp://127.0.0.1:38211', 100,
                                                 False, -1)
        self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header()
        self.satellites_nrzi_decode_0 = satellites.nrzi_decode()
        self.satellites_hdlc_deframer_0_0 = satellites.hdlc_deframer(
            check_fcs=True, max_length=1000)
        self.satellites_decode_rs_0 = satellites.decode_rs(True, 0)
        self.satellites_check_address_0 = satellites.check_address(
            'DP0OPS', "from")
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            512,  #size
            firdes.WIN_HAMMING,  #wintype
            0,  #fc
            samp_rate,  #bw
            "OPS-SAT UHF BEACON",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.03)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

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

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (gaussian_taps))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_descrambler_bb_0_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            (samp_rate / baud_rate) * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5,
            gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.digital_additive_scrambler_bb_0_0 = digital.additive_scrambler_bb(
            0xA9,
            0xFF,
            7,
            count=0,
            bits_per_byte=1,
            reset_tag_key="packet_len")
        self.blocks_unpacked_to_packed_xx_0_0_0_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            2 * (samp_rate / baud_rate) / (math.pi))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'),
                         (self.satellites_decode_rs_0, 'in'))
        self.msg_connect((self.satellites_check_address_0, 'ok'),
                         (self.satellites_strip_ax25_header_0, 'in'))
        self.msg_connect((self.satellites_decode_rs_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.satellites_decode_rs_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.satellites_hdlc_deframer_0_0, 'out'),
                         (self.satellites_check_address_0, 'in'))
        self.msg_connect((self.satellites_strip_ax25_header_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_additive_scrambler_bb_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0))
        self.connect((self.digital_additive_scrambler_bb_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satellites_nrzi_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0_0, 0),
                     (self.satellites_hdlc_deframer_0_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.satellites_nrzi_decode_0, 0),
                     (self.digital_descrambler_bb_0_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
Пример #28
0
    def __init__(self):
        gr.top_block.__init__(self, "Zmq Stream")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Zmq Stream")
        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", "zmq_stream")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 125e6

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0_0 = zeromq.sub_source(
            gr.sizeof_short, 1, 'tcp://192.168.0.200:9902', 200, False, -1)
        self.zeromq_sub_source_0 = zeromq.sub_source(
            gr.sizeof_short, 1, 'tcp://192.168.0.200:9901', 200, False, -1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            6  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 1)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_deinterleave_0_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)
        self.blocks_deinterleave_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_deinterleave_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_deinterleave_0, 1),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_deinterleave_0, 2),
                     (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_deinterleave_0_0, 0),
                     (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_deinterleave_0_0, 1),
                     (self.qtgui_time_sink_x_0, 4))
        self.connect((self.blocks_deinterleave_0_0, 2),
                     (self.qtgui_time_sink_x_0, 5))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_deinterleave_0, 0))
        self.connect((self.blocks_short_to_float_0_0, 0),
                     (self.blocks_deinterleave_0_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.zeromq_sub_source_0_0, 0),
                     (self.blocks_short_to_float_0_0, 0))
Пример #29
0
    def __init__(self, cdr, client_activemq, client_redis):
        self.thread_lock = threading.Lock()
        self.thread_lock.acquire()
        self.audio_capture = True

        gr.top_block.__init__(self, "logging_receiver")

        self.cdr = cdr
        self.in_use = False
        self.client_activemq = client_activemq
        self.client_redis = client_redis
        self.thread_id = 'logr-' + str(uuid.uuid4())

        self.filename = "/dev/null"
        self.filepath = "/dev/null"
        self.channel_rate = 0
        self.input_rate = 0

        #optionall log dat files
        self.log_dat = False

        #optionally keep wav files around
        self.log_wav = False

        self.sink = blocks.wavfile_sink(self.filepath, 1, 8000)

        self.protocol = None
        self.time_activity = 0

        self.codec_provoice = False
        self.codec_p25 = False

        self.destroyed = False

        self.log = logging.getLogger('overseer.logging_receiver')
        self.log.debug('Initializing call_recorder')

        #debug = threading.Thread(target=self.debug, name='logging_receiver_debug')
        #debug.daemon = True
        #debug.[tart()

        #Setup connector
        self.connector = frontend_connector()
        for retry in 1, 2, 3, 4, 5:
            try:
                channel_id, port = self.connector.create_channel(
                    int(self.cdr['channel_bandwidth']),
                    int(self.cdr['frequency']))
                self.source = zeromq.sub_source(
                    gr.sizeof_gr_complex * 1, 1,
                    'tcp://%s:%s' % (self.connector.host, port))
                break
            except:
                pass
        if self.source == None:
            self.connector.exit()
            return False

        if self.log_dat:
            self.dat_sink = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                             self.filename)
            self.connect(self.source, self.dat_sink)

        self.set_rate(int(self.cdr['channel_bandwidth'] * 2))
        self.configure_blocks(self.cdr['modulation_type'])
        if self.cdr['modulation_type'] == 'p25_tdma' or self.cdr[
                'modulation_type'] == 'p25_cqpsk_tdma':
            try:
                self.set_p25_xor_chars(
                    p25p2_lfsr(int(self.cdr['p25_nac']),
                               int(self.cdr['p25_system_id'], 0),
                               int(self.cdr['p25_wacn'], 0)).xor_chars)
            except:
                pass
            self.set_p25_tdma_slot(self.cdr['slot'])

        p25_sensor = threading.Thread(target=self.p25_sensor,
                                      name='p25_sensor',
                                      args=(self, ))
        p25_sensor.daemon = True
        p25_sensor.start()

        self.open()
        self.start()
        self.thread_lock.release()
Пример #30
0
    def __init__(self, decim=50, decim_df=.2, decim_f=.4, device_address="type=b200", device_arguments="master_clock_rate=30.72e6", df_ref=0, df_test=10e3, f_sample=960e3*4, f_sig=6e9, g_ref=0, g_sig=0, g_test=49, n_samples=1<<24, name="test", pass_tags=False, port_base=6880, f_dsp=0):
        gr.top_block.__init__(self, "Ampm Cli")

        ##################################################
        # Parameters
        ##################################################
        self.decim = decim
        self.decim_df = decim_df
        self.decim_f = decim_f
        self.device_address = device_address
        self.device_arguments = device_arguments
        self.df_ref = df_ref
        self.df_test = df_test
        self.f_sample = f_sample
        self.f_sig = f_sig
        self.g_ref = g_ref
        self.g_sig = g_sig
        self.g_test = g_test
        self.n_samples = n_samples
        self.name = name
        self.pass_tags = pass_tags
        self.port_base = port_base
        self.f_dsp = f_dsp

        ##################################################
        # Variables
        ##################################################
        self.info = info = {"name":name, "f_sig":f_sig, "df_ref":df_ref, "f_sample":f_sample, "decim":decim}
        self.filename = filename = "{:s}_f0{:.5g}_df{:.5g}_fs{:.5g}_d{:.5g}".format(name, f_sig/1e6, df_ref, f_sample/1e6, decim)

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0_2_0 = zeromq.sub_source(gr.sizeof_float, decim**0, "tcp://localhost:{}".format(port_base + 9), 100, pass_tags)
        self.zeromq_sub_source_0_2 = zeromq.sub_source(gr.sizeof_gr_complex, decim**0, "tcp://localhost:{}".format(port_base + 0), 100, pass_tags)
        self.zeromq_sub_source_0_1 = zeromq.sub_source(gr.sizeof_gr_complex, decim**1, "tcp://localhost:6881", 100, pass_tags)
        self.zeromq_sub_source_0_0 = zeromq.sub_source(gr.sizeof_gr_complex, decim**3, "tcp://localhost:6883", 100, pass_tags)
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, decim**2, "tcp://localhost:6882", 100, pass_tags)
        self.zeromq_pub_sink_0_1_2 = zeromq.pub_sink(gr.sizeof_float, decim**0, "tcp://*:{}".format(port_base + 9), 100, pass_tags)
        self.zeromq_pub_sink_0_1_1 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**1, "tcp://*:{}".format(port_base + 1), 100, pass_tags)
        self.zeromq_pub_sink_0_1_0_0 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**3, "tcp://*:{}".format(port_base + 3), 100, pass_tags)
        self.zeromq_pub_sink_0_1_0 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**2, "tcp://*:{}".format(port_base + 2), 100, pass_tags)
        self.zeromq_pub_sink_0_1 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**0, "tcp://*:{}".format(port_base + 0), 100, pass_tags)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join((device_address, device_arguments)),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_0_0.set_subdev_spec("A:A A:B", 0)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(f_sample)
        self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(target_freq=f_sig , dsp_freq=f_dsp, rf_freq_policy=uhd.tune_request.POLICY_AUTO, dsp_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0_0.set_gain(g_sig, 0)
        self.uhd_usrp_source_0_0.set_bandwidth(30.72e6, 0)
        self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(target_freq=f_sig + df_ref, dsp_freq=f_dsp, rf_freq_policy=uhd.tune_request.POLICY_AUTO, dsp_freq_policy=uhd.tune_request.POLICY_MANUAL), 1)
        self.uhd_usrp_source_0_0.set_gain(g_ref, 1)
        self.uhd_usrp_source_0_0.set_bandwidth(30.72e6, 1)
        self.blocks_stream_to_vector_0_1_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**3)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**2)
        self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_float*1, decim**0)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**0)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**1)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*decim**3, n_samples/decim**3)
        self.blocks_head_0_1 = blocks.head(gr.sizeof_gr_complex*decim**1, n_samples/decim**1)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_gr_complex*decim**3, n_samples/decim**3)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*decim**2, n_samples/decim**2)
        self.blocks_file_meta_sink_0_3_0 = blocks.file_meta_sink(gr.sizeof_float*decim**0, "{}_w.bin".format(filename), f_sample, decim**3, blocks.GR_FILE_FLOAT, False, 1<<20, "", True)
        self.blocks_file_meta_sink_0_3_0.set_unbuffered(False)
        self.blocks_file_meta_sink_0_3 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**0, "{}_0.bin".format(filename), f_sample, decim**3, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0_3.set_unbuffered(False)
        self.blocks_file_meta_sink_0_1 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**1, "{}_1.bin".format(filename), f_sample, decim**2, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0_1.set_unbuffered(False)
        self.blocks_file_meta_sink_0_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**3, "{}_3.bin".format(filename), f_sample, decim**0, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0_0.set_unbuffered(False)
        self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**2, "{}_2.bin".format(filename), f_sample, decim**1, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0.set_unbuffered(False)
        self.blocks_ctrlport_probe2_c_0_1 = blocks.ctrlport_probe2_c("d0", "diff0", 1024, gr.DISPTIME)
        self.blocks_ctrlport_probe2_c_0_0 = blocks.ctrlport_probe2_c("b", "input b", 1024, gr.DISPTIME)
        self.blocks_ctrlport_probe2_c_0 = blocks.ctrlport_probe2_c("a", "input a", 1024, gr.DISPTIME)
        self.blocks_ctrlport_monitor_0 = not True or monitor()
        self.Ampm_0 = Ampm(
            decim=decim,
            decim_df=decim_df,
            decim_f=decim_f,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Ampm_0, 0), (self.blocks_ctrlport_probe2_c_0_1, 0))    
        self.connect((self.Ampm_0, 2), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.Ampm_0, 3), (self.blocks_stream_to_vector_0_0, 0))    
        self.connect((self.Ampm_0, 4), (self.blocks_stream_to_vector_0_0_0, 0))    
        self.connect((self.Ampm_0, 1), (self.blocks_stream_to_vector_0_1, 0))    
        self.connect((self.Ampm_0, 0), (self.blocks_stream_to_vector_0_1_0, 0))    
        self.connect((self.blocks_head_0, 0), (self.blocks_file_meta_sink_0, 0))    
        self.connect((self.blocks_head_0_0, 0), (self.blocks_file_meta_sink_0_0, 0))    
        self.connect((self.blocks_head_0_1, 0), (self.blocks_file_meta_sink_0_1, 0))    
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_0_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.zeromq_pub_sink_0_1_1, 0))    
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.zeromq_pub_sink_0_1, 0))    
        self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.zeromq_pub_sink_0_1_2, 0))    
        self.connect((self.blocks_stream_to_vector_0_1, 0), (self.zeromq_pub_sink_0_1_0, 0))    
        self.connect((self.blocks_stream_to_vector_0_1_0, 0), (self.zeromq_pub_sink_0_1_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.Ampm_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.Ampm_0, 1))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_ctrlport_probe2_c_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_ctrlport_probe2_c_0_0, 0))    
        self.connect((self.zeromq_sub_source_0, 0), (self.blocks_head_0, 0))    
        self.connect((self.zeromq_sub_source_0_0, 0), (self.blocks_skiphead_0, 0))    
        self.connect((self.zeromq_sub_source_0_1, 0), (self.blocks_head_0_1, 0))    
        self.connect((self.zeromq_sub_source_0_2, 0), (self.blocks_file_meta_sink_0_3, 0))    
        self.connect((self.zeromq_sub_source_0_2_0, 0), (self.blocks_file_meta_sink_0_3_0, 0))    
Пример #31
0
def main(rf_gain, if_gain, bb_gain, ppm, use_zeromq_in=False, server="tcp://127.0.0.1:10444", server_control="tcp://127.0.0.1:10445"):
    global src
    global decoder
    global dab_ofdm_demod_0
    global c2f
    global f2c
    global audio_sink_0
    global fg
    global xrun_monitor
    global use_zeromq
    global rpc_mgr_server
    global dab_ofdm_demod_0
    global ppm_shared
    frequency=220.352e6
    audio_sample_rate=48000
    ppm_shared = ppm
    dab_bit_rate=64
    dab_address=304
    dab_subch_size=64
    dab_protect_level=1
    use_zeromq=use_zeromq_in
    if use_zeromq:
        from gnuradio import zeromq
    else:
        import osmosdr
    import time

    if len(channel_list) > 0:
        ch = channel_list[0]
        frequency = float(ch['frequency'])*1e6
    else:
        ch = {"bit_rate" : 64, "address" : 304, "subch_size" : 64, "protect_level" : 1}

    print("Setting frequency: %0.3f MHz" % (frequency/1e6))

    if not use_zeromq:
        osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        osmosdr_source_0.set_sample_rate(samp_rate)
        osmosdr_source_0.set_center_freq(frequency, 0)
        osmosdr_source_0.set_freq_corr(0, 0)
        osmosdr_source_0.set_dc_offset_mode(0, 0)
        osmosdr_source_0.set_iq_balance_mode(0, 0)
        osmosdr_source_0.set_gain_mode(False, 0)
        osmosdr_source_0.set_gain(rf_gain, 0)
        osmosdr_source_0.set_if_gain(if_gain, 0)
        osmosdr_source_0.set_bb_gain(bb_gain, 0)
        osmosdr_source_0.set_antenna('RX2', 0)
        osmosdr_source_0.set_bandwidth(2000000, 0)
    else:
        zeromq_source = zeromq.sub_source(gr.sizeof_gr_complex, 1, server, 100, False, -1)
        rpc_mgr_server = zeromq.rpc_manager()
        rpc_mgr_server.set_request_socket(server_control)
        rpc_mgr_server.request("set_sample_rate",[samp_rate])
        rpc_mgr_server.request("set_rf_gain",[rf_gain])
        rpc_mgr_server.request("set_if_gain",[if_gain])
        rpc_mgr_server.request("set_bb_gain",[bb_gain])
        rpc_mgr_server.request("set_ppm",[0]) # Not using hardware correction since it behaves differently on different hardware
        rpc_mgr_server.request("set_frequency",[frequency])
        time.sleep(0.7)

    sample_rate_correction_factor = 1 + float(ppm_shared)*1e-6
    dab_ofdm_demod_0 = grdab.ofdm_demod(
              grdab.parameters.dab_parameters(
                mode=1,
                sample_rate=samp_rate,
                verbose=False
              ),
              grdab.parameters.receiver_parameters(
                mode=1,
                softbits=True,
                input_fft_filter=True,
                autocorrect_sample_rate=False,
                sample_rate_correction_factor=sample_rate_correction_factor,
                always_include_resample=True,
                verbose=False,
                correct_ffe=True,
                equalize_magnitude=True
              )
            )

    if 'classic' in ch and ch['classic'] == True:
        dabplus = False
    else:
        dabplus = True

    if dabplus:
        decoder = grdab.dabplus_audio_decoder_ff(grdab.parameters.dab_parameters(mode=1, sample_rate=samp_rate, verbose=False), ch['bit_rate'], ch['address'], ch['subch_size'], ch['protect_level'], True)
    else:
        decoder = grdab.dab_audio_decoder_ff(grdab.parameters.dab_parameters(mode=1, sample_rate=samp_rate, verbose=False), ch['bit_rate'], ch['address'], ch['subch_size'], ch['protect_level'], True)

    xrun_monitor = grdab.xrun_monitor_cc(100000)
    xrun_monitor.set_report_fill(False)
    f2c = blocks.float_to_complex()
    c2f = blocks.complex_to_float()

    audio_sink_0 = audio.sink(audio_sample_rate, '', True)


    fg = gr.top_block()

    if not use_zeromq:
        src = osmosdr_source_0
    else:
        src = zeromq_source

    fg.connect(src, dab_ofdm_demod_0, decoder)
    fg.connect((decoder, 0), (f2c, 0))
    fg.connect((decoder, 1), (f2c, 1))
    fg.connect(f2c, xrun_monitor)
    fg.connect(xrun_monitor, c2f)
    fg.connect((c2f, 0), (audio_sink_0, 0))
    fg.connect((c2f, 1), (audio_sink_0, 1))




    fg.start()
    curses.wrapper(draw_menu)
Пример #32
0
def get_channels(frequency=220.352e6, rf_gain=25, if_gain=0, bb_gain=0, ppm=0, use_zeromq=False, server="tcp://127.0.0.1:10444", server_control="tcp://127.0.0.1:10445"):
    from gnuradio import gr, blocks, audio
    if use_zeromq:
        from gnuradio import zeromq

    import osmosdr
    import grdab
    import time

    samp_rate = samp_rate = 2000000

    print("Setting frequency: %0.3f MHz" % (frequency/1e6))

    if not use_zeromq:
        osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        osmosdr_source_0.set_sample_rate(samp_rate)
        osmosdr_source_0.set_center_freq(frequency, 0)
        osmosdr_source_0.set_freq_corr(0, 0)
        osmosdr_source_0.set_dc_offset_mode(0, 0)
        osmosdr_source_0.set_iq_balance_mode(0, 0)
        osmosdr_source_0.set_gain_mode(False, 0)
        osmosdr_source_0.set_gain(rf_gain, 0)
        osmosdr_source_0.set_if_gain(if_gain, 0)
        osmosdr_source_0.set_bb_gain(bb_gain, 0)
        osmosdr_source_0.set_antenna('RX2', 0)
        osmosdr_source_0.set_bandwidth(2000000, 0)
    else:
        zeromq_source = zeromq.sub_source(gr.sizeof_gr_complex, 1, server, 100, False, -1)
        rpc_mgr_server = zeromq.rpc_manager()
        rpc_mgr_server.set_request_socket(server_control)
        rpc_mgr_server.request("set_sample_rate",[samp_rate])
        rpc_mgr_server.request("set_rf_gain",[rf_gain])
        rpc_mgr_server.request("set_if_gain",[if_gain])
        rpc_mgr_server.request("set_bb_gain",[bb_gain])
        rpc_mgr_server.request("set_ppm",[0]) # Not using hardware correction since it behaves differently on different hardware
        rpc_mgr_server.request("set_frequency",[frequency])
        time.sleep(0.7)

    sample_rate_correction_factor = 1 + float(ppm)*1e-6
    dab_ofdm_demod_0 = grdab.ofdm_demod(
              grdab.parameters.dab_parameters(
                mode=1,
                sample_rate=samp_rate,
                verbose=False
              ),
              grdab.parameters.receiver_parameters(
                mode=1,
                softbits=True,
                input_fft_filter=True,
                autocorrect_sample_rate=False,
                sample_rate_correction_factor=sample_rate_correction_factor,
                always_include_resample=True,
                verbose=False,
                correct_ffe=True,
                equalize_magnitude=True
              )
            )

    dab_fic_decode_0 = grdab.fic_decode(
              grdab.parameters.dab_parameters(
                mode=1,
                sample_rate=samp_rate,
                verbose=False
              )
            )
    #dab_fic_decode_0.set_print_channel_info(True)

    fg = gr.top_block()

    if not use_zeromq:
        fg.connect(osmosdr_source_0, dab_ofdm_demod_0)
    else:
        fg.connect(zeromq_source, dab_ofdm_demod_0)
    fg.connect(dab_ofdm_demod_0, dab_fic_decode_0)



    fg.start()

    attempt = 0
    maxattempts = 9
    channels = {}
    while True:
        service_labels = dab_fic_decode_0.get_service_labels()
        if service_labels.strip() != "":
            service_labels_json = json.loads(service_labels.strip())
            for s in service_labels_json:
                if s['reference'] not in channels:
                    channels[s['reference']] = {}
                channels[s['reference']]['label'] = s['label']
            subch_info = dab_fic_decode_0.get_subch_info()
        service_info = dab_fic_decode_0.get_service_info() # mapping between service_labels number and subch_info number
        if service_info.strip() != "":
            service_info_json = json.loads(service_info.strip())
            for s in service_info_json:
                if s['reference'] not in channels:
                    channels[s['reference']] = {}
                channels[s['reference']]['id'] = s['ID']
                channels[s['reference']]['dabplus'] = s['DAB+']
        subch_info = dab_fic_decode_0.get_subch_info() # settings needed for setting channel
        if subch_info.strip() != "":
            subch_info_json = json.loads(subch_info.strip())
            for s in subch_info_json:
                if 'ID' in s:
                    current_id = s['ID']
                    for key,val in channels.items():
                        if 'id' in val:
                            if val['id'] == current_id:
                                channels[key]['subch_info'] = s
                                break

        all_have_label = True
        for c,item in channels.items():
            if 'label' not in item:
                all_have_label = False
        if attempt == maxattempts-1:
            all_have_label = True
        complete = False
        if len(channels) > 0 and all_have_label:
            print("Channels:")
            for c,item in channels.items():
                if 'subch_info' in item:
                    conv_table = [ 128, 8, 6, 5];
                    protect_level = item['subch_info']['protection']
                    subch_size = item['subch_info']['size']
                    if protect_level <= 4:
                        if 'label' in item:
                            label = item['label']
                        else:
                            label = "UNKNOWN"
                        bit_rate = subch_size * 8 / (conv_table[protect_level]);

                        print("%s: (address: %3d, subch_size: %3d, protect_level: %1d, bit_rate: %3d, classic: %1d)" % (label, item['subch_info']['address'], item['subch_info']['size'], item['subch_info']['protection'], bit_rate, not item['dabplus']))
                complete = True

        if complete:
            break
        attempt = attempt + 1
        time.sleep(1)
    fg.stop()
Пример #33
0
    def __init__(self):
        gr.top_block.__init__(self, "My CW TEst")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("My CW TEst")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "my_cw")

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

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

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_float, 1,
                                                     'tcp://127.0.0.1:50001',
                                                     100, False, -1)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            3  #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(-1, 1)

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

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

        labels = [
            'Audio Bcast', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5',
            'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

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

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win)
        self.msz_cw_0 = msz.cw(24, 0.1, 0.5)
        self.epy_block_0 = epy_block_0.blk(learning_vector=1000,
                                           initial_dit_length_samples=4800)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(2)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.analog_sig_source_x_1_0 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 50, 1, 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_f(
            samp_rate, analog.GR_SQR_WAVE, 40, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.msz_cw_0, 'cwevent'),
                         (self.epy_block_0, 'cwevent'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_int_to_float_0, 0), (self.epy_block_0, 0))
        self.connect((self.blocks_int_to_float_0, 0),
                     (self.qtgui_time_sink_x_2, 2))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.msz_cw_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_2, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.epy_block_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.msz_cw_0, 1), (self.blocks_int_to_float_0, 0))
        self.connect((self.msz_cw_0, 0), (self.qtgui_time_sink_x_2, 1))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Пример #34
0
    def __init__(self):
        gr.top_block.__init__(self, "Gnuradio Sink Zmq")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Gnuradio Sink Zmq")
        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", "gnuradio_sink_zmq")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 125e6 / 128

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0_0 = zeromq.sub_source(
            gr.sizeof_short, 1, 'tcp://192.168.0.10:9901', 200, False, -1)
        self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f(
            2**11,  #size
            samp_rate,  #samp_rate
            "PUB/SUB",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0.set_update_time(0.05)
        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, "packet_len")
        self.qtgui_time_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0.enable_stem_plot(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):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            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, 2, 0,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.05)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 1, 0,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_short_to_float_0_0 = blocks.short_to_float(1, 1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_deinterleave_0_0_0 = blocks.deinterleave(
            gr.sizeof_float * 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_deinterleave_0_0_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_deinterleave_0_0_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_deinterleave_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0, 0))
        self.connect((self.blocks_deinterleave_0_0_0, 1),
                     (self.qtgui_time_sink_x_0_0_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.blocks_short_to_float_0_0, 0),
                     (self.blocks_deinterleave_0_0_0, 0))
        self.connect((self.zeromq_sub_source_0_0, 0),
                     (self.blocks_short_to_float_0_0, 0))
Пример #35
0
    def __init__(self,
                 input_port_num="55555",
                 output_port_num="55556",
                 rx_bw=1e6,
                 rx_freq=2.2e9,
                 rx_gain=0.8,
                 serial_num="31C9237",
                 tx_bw=1e6,
                 tx_freq=2.2e9,
                 tx_gain=0.8):
        gr.top_block.__init__(self, "tranceiver_ofdm_usrp_RS")

        ##################################################
        # Parameters
        ##################################################
        self.input_port_num = input_port_num
        self.output_port_num = output_port_num
        self.rx_bw = rx_bw
        self.rx_freq = rx_freq
        self.rx_gain = rx_gain
        self.serial_num = serial_num
        self.tx_bw = tx_bw
        self.tx_freq = tx_freq
        self.tx_gain = tx_gain

        ##################################################
        # Variables
        ##################################################
        self.packet_len = packet_len = 200
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) +
            list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), )
        self.n = n = 255
        self.length_tag_key = length_tag_key = "frame_len"
        self.k = k = packet_len + 4
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.blocks_RS = blocks_RS = 1
        self.t = t = int((n * blocks_RS - k) / 2)
        self.sync_word2 = sync_word2 = [
            0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j),
            (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            0j, 0j, 0j, 0j, 0j
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 10000
        self.rolloff = rolloff = 0
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 1)
        self.out_buf_size = out_buf_size = 0
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)
        self.hdr_format = hdr_format = digital.header_format_ofdm(
            occupied_carriers,
            1,
            length_tag_key,
        )

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(
            gr.sizeof_char, 1, "tcp://127.0.0.1:" + input_port_num, 100, False,
            -1)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1,
                                                 "tcp://127.0.0.1:55556", 100,
                                                 False, -1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(rx_bw)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            packet_length_tag_key,
        )
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_samp_rate(tx_bw)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 100,
                                                 1000)
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc(
            2, 8, 0x11d, n, k, t, 0, blocks_RS)
        self.dtv_dvbt_reed_solomon_dec_0 = dtv.dvbt_reed_solomon_dec(
            2, 8, 0x11d, n, k, t, 0, 1)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, packet_length_tag_key)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len // 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, '', 0, '', True)
        self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len // 4, length_tag_key, True, 1)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len // 4, rolloff, packet_length_tag_key)
        self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(
            sync_word1, sync_word2, 1, 0, 3, False)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), packet_length_tag_key, True)
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            3, fft_len, fft_len // 4, length_tag_key, "", True,
            gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0)
        self.digital_crc32_bb_0_0 = digital.crc32_bb(False,
                                                     packet_length_tag_key,
                                                     True)
        self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key,
                                                   True)
        self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(
            payload_mod.base())
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            header_mod.points(), 1)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, k)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_char * 1, n)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, packet_length_tag_key, 0)
        self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, packet_length_tag_key, k / n)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, packet_length_tag_key, n / k)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(
            gr.sizeof_char * 1, k)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_char * 1, n)
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, k, packet_length_tag_key)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, packet_length_tag_key)
        self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), packet_length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, 1, packet_length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True,
            gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           fft_len + fft_len // 4)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_1, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0),
                     (self.dtv_dvbt_reed_solomon_dec_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0),
                     (self.dtv_dvbt_reed_solomon_enc_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.blocks_repack_bits_bb_0_1, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_constellation_decoder_cb_1, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.digital_crc32_bb_0_0, 0),
                     (self.blocks_stream_to_vector_1, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_header, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0),
                     (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0),
                     (self.digital_constellation_decoder_cb_1, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 1),
                     (self.digital_header_payload_demux_0, 1))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_dec_0, 0),
                     (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_1, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
Пример #36
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Hop on Demand")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_samp_rate = tx_samp_rate = 50e3
        self.tx_freq = tx_freq = 100e6
        self.sps = sps = 4
        self.rx_samp_rate = rx_samp_rate = 2e6
        self.rx_freq = rx_freq = 100e6
        self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.excess_bw = excess_bw = 0.35

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1, "tcp://127.0.0.1:5557", 1000, False, -1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=rx_freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=rx_samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=True,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=True,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        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(rx_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(15, 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(tx_samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(30, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, rx_samp_rate, 1e6, 30e3, firdes.WIN_HAMMING, 6.76))
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )
        self.blocks_probe_signal_x_0 = blocks.probe_signal_c()
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.digital_constellation_modulator_0, 0))    
        self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.zeromq_sub_source_0, 0), (self.blocks_probe_signal_x_0, 0))

	### Added by Bill Urrego ###
    	t = Thread(target=sub, args=(self.change_freq,))
    	t.start()
Пример #37
0
    def __init__(self, fD=10, id_user=0):
        gr.top_block.__init__(self, "Polar Coding with Coded Caching")

        ##################################################
        # Parameters
        ##################################################
        self.fD = fD
        self.id_user = id_user

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 14 + 20 * numpy.log10(4)
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.variance = variance = 1 / pow(10, snr / 10.0)
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.small_packet_len = small_packet_len = 52
        self.samp_rate = samp_rate = int(1e6)
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        self.gain = gain = 25
        self.freq = freq = 2450e6
        self.coderate = coderate = [1, 2, 2, 3, 4]
        self.Users = Users = 4
        self.Nbfiles = Nbfiles = 20
        self.NbStrgUsers = NbStrgUsers = 1
        self.NbChuncks = NbChuncks = 200
        self.N = N = 2048

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     'tcp://localhost:5565',
                                                     100, False, -1)
        self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source(
            'tcp://localhost:5575', 10)
        self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source(
            'tcp://localhost:5555', 10)
        self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc(
            fft_len, fft_len / 4, length_tag_key, True, occupied_carriers,
            pilot_carriers, pilot_symbols, 0, True)
        self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b(
            N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42,
            coderate[id_user], packet_length_tag_key)
        self.projectCACHE_PC_Error_Rate_0_0 = projectCACHE.PC_Error_Rate(
            id_user, 200)
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(
            3, 1000, 0.0001)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len / 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, '', 0, '', True)
        self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len / 4, length_tag_key, True, 1)
        self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(
            (sync_word1), (sync_word2), 1, 0, 3, False)
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            3,
            fft_len,
            fft_len / 4,
            length_tag_key,
            "",
            True,
            gr.sizeof_gr_complex,
            "rx_time",
            samp_rate,
            (),
            0,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           fft_len + fft_len / 4)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'SNR'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'BER_INFO'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'CH_USE'))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_header, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0),
                     (self.projectCACHE_PolarDec_b_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload_0, 0),
                     (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 1),
                     (self.digital_header_payload_demux_0, 1))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_serializer_vcc_payload_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0))
        self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
Пример #38
0
def receive_dabplus(frequency=220.352e6, rf_gain=25, if_gain=0, bb_gain=0, ppm=80, audio_sample_rate=48000, dab_bit_rate=64, dab_address=304, dab_subch_size=64, dab_protect_level=1, use_zeromq=False, dabplus=True, server="tcp://127.0.0.1:10444", server_control="tcp://127.0.0.1:10445"):
    from gnuradio import gr, blocks, audio
    if use_zeromq:
        from gnuradio import zeromq

    import time
    import osmosdr
    import grdab

    samp_rate = samp_rate = 2000000

    print("Setting frequency: %0.3f MHz" % (frequency/1e6))
    print("Setting RF gain to: %d" % rf_gain)
    print("Setting Frequency error (ppm) to: %d" % ppm)

    if not use_zeromq:
        osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        osmosdr_source_0.set_sample_rate(samp_rate)
        osmosdr_source_0.set_center_freq(frequency, 0)
        osmosdr_source_0.set_freq_corr(0, 0)
        osmosdr_source_0.set_dc_offset_mode(0, 0)
        osmosdr_source_0.set_iq_balance_mode(0, 0)
        osmosdr_source_0.set_gain_mode(False, 0)
        osmosdr_source_0.set_gain(rf_gain, 0)
        osmosdr_source_0.set_if_gain(if_gain, 0)
        osmosdr_source_0.set_bb_gain(bb_gain, 0)
        osmosdr_source_0.set_antenna('RX2', 0)
        osmosdr_source_0.set_bandwidth(2000000, 0)
    else:
        zeromq_source = zeromq.sub_source(gr.sizeof_gr_complex, 1, server, 100, False, -1)
        rpc_mgr_server = zeromq.rpc_manager()
        rpc_mgr_server.set_request_socket(server_control)
        rpc_mgr_server.request("set_sample_rate",[samp_rate])
        rpc_mgr_server.request("set_rf_gain",[rf_gain])
        rpc_mgr_server.request("set_if_gain",[if_gain])
        rpc_mgr_server.request("set_bb_gain",[bb_gain])
        rpc_mgr_server.request("set_ppm",[0]) # Not using hardware correction since it behaves differently on different hardware
        rpc_mgr_server.request("set_frequency",[frequency])
        time.sleep(0.7)

    sample_rate_correction_factor = 1 + float(ppm)*1e-6
    dab_ofdm_demod_0 = grdab.ofdm_demod(
              grdab.parameters.dab_parameters(
                mode=1,
                sample_rate=samp_rate,
                verbose=False
              ),
              grdab.parameters.receiver_parameters(
                mode=1,
                softbits=True,
                input_fft_filter=True,
                autocorrect_sample_rate=False,
                sample_rate_correction_factor=sample_rate_correction_factor,
                always_include_resample=True,
                verbose=False,
                correct_ffe=True,
                equalize_magnitude=True
              )
            )

    if dabplus:
        decoder = grdab.dabplus_audio_decoder_ff(grdab.parameters.dab_parameters(mode=1, sample_rate=samp_rate, verbose=False), dab_bit_rate, dab_address, dab_subch_size, dab_protect_level, True)
    else:
        decoder = grdab.dab_audio_decoder_ff(grdab.parameters.dab_parameters(mode=1, sample_rate=samp_rate, verbose=False), dab_bit_rate, dab_address, dab_subch_size, dab_protect_level, True)

    xrun_monitor = grdab.xrun_monitor_cc(100000)
    f2c = blocks.float_to_complex()
    c2f = blocks.complex_to_float()

    audio_sink_0 = audio.sink(audio_sample_rate, '', True)

    fg = gr.top_block()

    if not use_zeromq:
        src = osmosdr_source_0
    else:
        src = zeromq_source

    fg.connect(src, dab_ofdm_demod_0, decoder)
    fg.connect((decoder, 0), (f2c, 0))
    fg.connect((decoder, 1), (f2c, 1))
    fg.connect(f2c, xrun_monitor)
    fg.connect(xrun_monitor, c2f)
    fg.connect((c2f, 0), (audio_sink_0, 0))
    fg.connect((c2f, 1), (audio_sink_0, 1))



    fg.start()
    raw_input("Running..")
    #new = grdab.dabplus_audio_decoder_ff(grdab.parameters.dab_parameters(mode=1, sample_rate=samp_rate, verbose=False), 64, 304, 64, 1, True)
    #newaudio = audio.sink(44100, '', True)
    fg.stop()
Пример #39
0
    def __init__(self, frequency, channel_width=12500):
        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.samp_rate = samp_rate = channel_width

        ##################################################
        # Blocks
        ##################################################
        self.connector = frontend_connector()
        channel_id, port = self.connector.create_channel(
            channel_width, frequency)
        self.source = zeromq.sub_source(
            gr.sizeof_gr_complex * 1, 1,
            'tcp://%s:%s' % (self.connector.host, port))

        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            int(samp_rate),  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.source, 0), (self.qtgui_freq_sink_x_0, 0))
Пример #40
0
def receive_dabplus(frequency=220.352e6,
                    rf_gain=25,
                    if_gain=0,
                    bb_gain=0,
                    ppm=80,
                    audio_sample_rate=48000,
                    dab_bit_rate=64,
                    dab_address=304,
                    dab_subch_size=64,
                    dab_protect_level=1,
                    use_zeromq=False,
                    dabplus=True,
                    server="tcp://127.0.0.1:10444",
                    server_control="tcp://127.0.0.1:10445",
                    from_file=None,
                    from_file_repeat=False,
                    skip_xrun_monitor=False):
    from gnuradio import gr, blocks, audio
    if use_zeromq:
        from gnuradio import zeromq

    import time
    import osmosdr
    import grdab

    samp_rate = samp_rate = 2048000

    print("Setting frequency: %0.3f MHz" % (frequency / 1e6))
    print("Setting RF gain to: %d" % rf_gain)
    print("Setting Frequency error (ppm) to: %d" % ppm)

    fg = gr.top_block()

    if from_file != None:
        file_input = blocks.file_source(gr.sizeof_gr_complex, from_file,
                                        from_file_repeat)
        if skip_xrun_monitor:
            src = file_input
        else:
            fthrottle = blocks.throttle(gr.sizeof_gr_complex, samp_rate)
            fg.connect(file_input, fthrottle)
            src = fthrottle
        print("Run from file %s" % from_file)
    elif not use_zeromq:
        osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '')
        osmosdr_source_0.set_sample_rate(samp_rate)
        osmosdr_source_0.set_center_freq(frequency, 0)
        osmosdr_source_0.set_freq_corr(0, 0)
        osmosdr_source_0.set_dc_offset_mode(0, 0)
        osmosdr_source_0.set_iq_balance_mode(0, 0)
        osmosdr_source_0.set_gain_mode(False, 0)
        osmosdr_source_0.set_gain(rf_gain, 0)
        osmosdr_source_0.set_if_gain(if_gain, 0)
        osmosdr_source_0.set_bb_gain(bb_gain, 0)
        osmosdr_source_0.set_antenna('RX2', 0)
        osmosdr_source_0.set_bandwidth(2000000, 0)
        src = osmosdr_source_0
    else:
        zeromq_source = zeromq.sub_source(gr.sizeof_gr_complex, 1, server, 100,
                                          False, -1)
        rpc_mgr_server = zeromq.rpc_manager()
        rpc_mgr_server.set_request_socket(server_control)
        rpc_mgr_server.request("set_sample_rate", [samp_rate])
        rpc_mgr_server.request("set_rf_gain", [rf_gain])
        rpc_mgr_server.request("set_if_gain", [if_gain])
        rpc_mgr_server.request("set_bb_gain", [bb_gain])
        rpc_mgr_server.request(
            "set_ppm", [0]
        )  # Not using hardware correction since it behaves differently on different hardware
        rpc_mgr_server.request("set_frequency", [frequency])
        time.sleep(0.7)
        src = zeromq_source

    sample_rate_correction_factor = 1 + float(ppm) * 1e-6
    dab_ofdm_demod_0 = grdab.ofdm_demod(
        grdab.parameters.dab_parameters(mode=1,
                                        sample_rate=samp_rate,
                                        verbose=False),
        grdab.parameters.receiver_parameters(
            mode=1,
            softbits=True,
            input_fft_filter=True,
            autocorrect_sample_rate=False,
            sample_rate_correction_factor=sample_rate_correction_factor,
            always_include_resample=True,
            verbose=False,
            correct_ffe=True,
            equalize_magnitude=True))

    if dabplus:
        decoder = grdab.dabplus_audio_decoder_ff(
            grdab.parameters.dab_parameters(mode=1,
                                            sample_rate=samp_rate,
                                            verbose=False), dab_bit_rate,
            dab_address, dab_subch_size, dab_protect_level, True)
    else:
        decoder = grdab.dab_audio_decoder_ff(
            grdab.parameters.dab_parameters(mode=1,
                                            sample_rate=samp_rate,
                                            verbose=False), dab_bit_rate,
            dab_address, dab_subch_size, dab_protect_level, True)

    xrun_monitor = grdab.xrun_monitor_cc(100000)
    f2c = blocks.float_to_complex()
    c2f = blocks.complex_to_float()

    audio_sink_0 = audio.sink(audio_sample_rate, '', True)

    fg.connect(src, dab_ofdm_demod_0, decoder)
    fg.connect((decoder, 0), (f2c, 0))
    fg.connect((decoder, 1), (f2c, 1))
    if skip_xrun_monitor:
        fg.connect(f2c, c2f)
    else:
        fg.connect(f2c, xrun_monitor)
        fg.connect(xrun_monitor, c2f)
    fg.connect((c2f, 0), (audio_sink_0, 0))
    fg.connect((c2f, 1), (audio_sink_0, 1))

    if from_file != None and from_file_repeat == False and skip_xrun_monitor:
        fg.run()
    else:
        fg.start()
        input("Running..")
        fg.stop()
Пример #41
0
    def __init__(self,
                 parent=self if 'self' in locals() else None,
                 rx_frequency=1000000,
                 samp_rate=500000,
                 server_address_format="tcp://%s:%d",
                 server_bw_per_port=1000000,
                 server_ip='',
                 server_port_base=10000,
                 throttle=1,
                 zmq_rx_timeout=100):
        gr.hier_block2.__init__(
            self,
            "RF Over IP Source",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.parent = parent
        self.rx_frequency = rx_frequency
        self.samp_rate = samp_rate
        self.server_address_format = server_address_format
        self.server_bw_per_port = server_bw_per_port
        self.server_ip = server_ip
        self.server_port_base = server_port_base
        self.throttle = throttle
        self.zmq_rx_timeout = zmq_rx_timeout

        ##################################################
        # Variables
        ##################################################
        self.server_port = server_port = int(server_port_base +
                                             (rx_frequency /
                                              server_bw_per_port))
        self.server_address = server_address = server_address_format % (
            server_ip, server_port) if server_address_format != "" else ""

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     server_address,
                                                     zmq_rx_timeout, True, -1)
        self.tags_to_vars_0 = tags_to_vars(
            parent=parent,
            tag_map={"rx_rate": "set_samp_rate(value)"},
        )
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate, False)
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * 1,
            num_inputs=2,
            num_outputs=1,
            input_index=0 if throttle else 1,
            output_index=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_selector_0, 0), (self, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.blks2_selector_0, 1))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.tags_to_vars_0, 0))