def __init__(self, code_index, code_size=31, DataRate_Kbps=850, Nburst=32, Ncpb=16, MeanPRF_KHz=15600, Nsync=64, deltaL=16, Nsdf=8, bypass_conv_enc=0, isRangingPacket=0, msgq_limit=2):
        """
	Hierarchical block for the IEEE 802.15.4a UWB modulation.

        Packets to be sent are enqueued by calling send_pkt.
        The output is the complex modulated signal at baseband.

	@param fg: flow graph
	@type fg: flow graph
        @param msgq_limit: maximum number of messages in message queue
        @type msgq_limit: int
        @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
        @param bypass_conv_enc: bypass the convolutional encoding (1) or not (0)[default]
        @type bypass_conv_enc: int
        
        """
        gr.hier_block2.__init__(self, "ieee804154a_uwb_mod_pkt",
				gr.io_signature(0, 0, 0),                    # Input signature
				gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
				        
        # setting parameters
        self.code_index = code_index
        self.code_size = code_size
        self.DataRate_Kbps = DataRate_Kbps
        self.Nburst = Nburst
        self.Ncpb = Ncpb
        self.MeanPRF_KHz = MeanPRF_KHz
        self.Nsync = Nsync
        self.deltaL = deltaL
        self.Nsdf = Nsdf
        self.bypass_conv_enc = bypass_conv_enc
        self.isRangingPacket = bypass_conv_enc
        
        ############ THE SYNCH PATH
        # synchronization header
        self.synch_seq = ieee802_15_4a.msg_formatter.set_synch(self.code_size, self.code_index, self.Nsync, self.deltaL, self.Nsdf)
        self.synch_msg = gr.message_from_string(self.synch_seq)
        self._synch_input = blocks.message_source(gr.sizeof_char, msgq_limit)
        
        ############ THE MAIN PATH
        # accepts messages from the outside world
        self._pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)
        
        # convolutional encoding
        self._convolutional_encoder = ieee802_15_4a.conv_encoder (self.bypass_conv_enc);
        
        # BPSK BPM modulator
        self._modulator = ieee802_15_4a.bpsk_bpm_modulator(self.code_index, self.Nburst, self.Ncpb)
        
        # connect the blocks
        self.connect(self._pkt_input, self._convolutional_encoder, self._modulator)
        
        # THE CONNECTION BETWEEN THE PATHS
        self.delay = blocks.delay (gr.sizeof_char, len(self.synch_seq))
        self.sum2 = blocks.or_bb(1);
        
        self.connect (self._synch_input, (self.sum2, 0))
        self.connect (self._modulator, self.delay)
        self.connect (self.delay, (self.sum2, 1))
        self.connect (self.sum2, self)
Beispiel #2
0
    def __init__(self, dc_block_len=4, rx_gain=40):
        gr.top_block.__init__(self, "Uhd Adsb 6")

        ##################################################
        # Parameters
        ##################################################
        self.dc_block_len = dc_block_len
        self.rx_gain = rx_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.freq = freq = 1090e6
        self.filename = filename = "./bytes_" + str(dc_block_len) + ".csv"

        ##################################################
        # Message Queues
        ##################################################
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb(
            '1010000101000000', 0, 'adsb_preamble')
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(dc_block_len, True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/leffke/sandbox/adsb/adsb_20161212_2M_2.32fc', False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   filename, True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,
                                           tx_msgq=adsb_decoder_0_msgq_out,
                                           output_type="csv",
                                           check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.adsb_framer_0, 0))
Beispiel #3
0
	def __init__(self, samples_per_symbol, bits_per_symbol, pad_for_usrp=True):
		"""
		packet_mod constructor.

		Args:
			samples_per_symbol: number of samples per symbol
			bits_per_symbol: number of bits per symbol
			pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
		"""

		#setup parameters
		self._samples_per_symbol = samples_per_symbol
		self._bits_per_symbol = bits_per_symbol
		self._pad_for_usrp = pad_for_usrp

		#create blocks
		msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
		self._msgq_out = msg_source.msgq()
		#initialize hier2
		gr.hier_block2.__init__(
			self,
			"mwt1_packet_encoder",
			gr.io_signature(0, 0, 0), # Input signature
			gr.io_signature(1, 1, gr.sizeof_char) # Output signature
		)
		#connect
		self.connect(msg_source, self)
Beispiel #4
0
    def __init__(self):
        gr.hier_block2.__init__(self, "transmit_path",
            gr.io_signature(0,0,0),
            gr.io_signature(1, 1, gr.sizeof_gr_complex))

        ##################################################
        # Variables
        ##################################################
        self.msgq_limit = msgq_limit = 2

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

        self.pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)

        # self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

        self.mod = digital.gfsk_mod(
        	samples_per_symbol=4,
        	sensitivity=1.0,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect(self.pkt_input, self.mod, self)
Beispiel #5
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
        self._frame = frame
        self._panel = panel
        self._vbox = vbox

        ## Variable
        self._samp_rate = 1000000
        self._freq = 433.92e6
        self._unit = 5.33e-4  # 533us unit pulse width

        self._pkt_source = blocks.message_source(gr.sizeof_char, 8)
        self._modulator = bask_mod(samples_per_symbol=int(self._unit *
                                                          self._samp_rate))
        self.init_gui()

        # init uhd sink (USRP)
        self._uhd_sink = uhd.usrp_sink(device_addr='',
                                       stream_args=uhd.stream_args('fc32'))
        self._uhd_sink.set_samp_rate(self._samp_rate)
        self._uhd_sink.set_center_freq(self._freq, 0)
        self._uhd_sink.set_gain(15, 0)
        self._uhd_sink.set_antenna('TX/RX', 0)

        # wire everything up
        self.connect(self._pkt_source, self._modulator, self._uhd_sink)
Beispiel #6
0
    def __init__(self, packet_sink=None):
        #initialize hier2
        gr.hier_block2.__init__(
            self,
            "ofdm_mod",
            gr.io_signature(1, 1, 1),  # Input signature
            gr.io_signature(1, 1, 1)  # Output signature
        )
        #create blocks
        """msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
        #connect
        self.connect(self, packet_sink)
        """
        ##self.connect(self, packet_sink)
        #self.connect(packet_sink,self)

        msg_in = blocks.message_source(1, DEFAULT_MSGQ_LIMIT)
        msgq = msg_in.msgq()

        #msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
        correlator = digital.correlate_access_code_bb(packet_sink._access_code,
                                                      packet_sink._threshold)
        framer_sink = digital.framer_sink_1(msgq)
        self.connect(self, packet_sink)
        self.connect(packet_sink, self)
    def __init__(self, access_code='', threshold=-1):

	packet_sink=packet_decoder_sink(access_code, threshold, lambda ok, payload: self.recv_pkt(ok, payload))

	self._item_size_out = gr.sizeof_char
	
        #initialize hier2
        gr.hier_block2.__init__(
            self,
            "ofdm_mod",
            gr.io_signature(1, 1, packet_sink.input_signature().sizeof_stream_item(0)), # Input signature
            gr.io_signature(1, 1, self._item_size_out) # Output signature
        )
        #create blocks
        #msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
        #self._msgq_out = msg_source.msgq()
        # create message queue
	self._msgq_out = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
        # map message queue to tagged stream block
        msg_source=blocks.message_source(self._item_size_out, self._msgq_out, "packet_len")
        #connect
        self.connect(self, packet_sink)
        self.connect(msg_source, self)
        if packet_sink.output_signature().sizeof_stream_item(0):
            self.connect(packet_sink,
                         blocks.null_sink(packet_sink.output_signature().sizeof_stream_item(0)))
    def __init__(self, samples_per_symbol, bits_per_symbol, preamble='', access_code='', pad_for_usrp=True):
        """
        packet_mod constructor.
        
        Args:
            samples_per_symbol: number of samples per symbol
            bits_per_symbol: number of bits per symbol
            access_code: AKA sync vector
            pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
            payload_length: number of bytes in a data-stream slice

        """

	print "here1"
	gr.basic_block.__init__(self,name="packet_encoder",in_sig=[numpy.uint8],out_sig=[numpy.uint8])
        #setup parameters
        self._samples_per_symbol = samples_per_symbol
        self._bits_per_symbol = bits_per_symbol
        self._pad_for_usrp = pad_for_usrp
        if not preamble: #get preamble
            preamble = packet_utils.default_preamble
        if not access_code: #get access code
            access_code = packet_utils.default_access_code
        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (preamble,)
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)

        self._preamble = preamble
        self._access_code = access_code
        self._pad_for_usrp = pad_for_usrp
        #create blocks
        msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
Beispiel #9
0
    def __init__(self, access_code='', threshold=-1):

        packet_sink = packet_decoder_sink(
            access_code, threshold,
            lambda ok, payload: self.recv_pkt(ok, payload))

        self._item_size_out = gr.sizeof_char

        #initialize hier2
        gr.hier_block2.__init__(
            self,
            "ofdm_mod",
            gr.io_signature(
                1, 1,
                packet_sink.input_signature().sizeof_stream_item(
                    0)),  # Input signature
            gr.io_signature(1, 1, self._item_size_out)  # Output signature
        )
        #create blocks
        #msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
        #self._msgq_out = msg_source.msgq()
        # create message queue
        self._msgq_out = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
        # map message queue to tagged stream block
        msg_source = blocks.message_source(self._item_size_out, self._msgq_out,
                                           "packet_len")
        #connect
        self.connect(self, packet_sink)
        self.connect(msg_source, self)
        if packet_sink.output_signature().sizeof_stream_item(0):
            self.connect(
                packet_sink,
                blocks.null_sink(
                    packet_sink.output_signature().sizeof_stream_item(0)))
Beispiel #10
0
	def __init__(self, samples_per_symbol, bits_per_symbol, access_code='', pad_for_usrp=True):
		"""
		packet_mod constructor.
		
		Args:
		    samples_per_symbol: number of samples per symbol
		    bits_per_symbol: number of bits per symbol
		    access_code: AKA sync vector
		    pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
		    payload_length: number of bytes in a data-stream slice
		"""
		#setup parameters
		self._samples_per_symbol = samples_per_symbol
		self._bits_per_symbol = bits_per_symbol
		self._pad_for_usrp = pad_for_usrp
		if not access_code: #get access code
			access_code = packet_utils.default_access_code
		if not packet_utils.is_1_0_string(access_code):
			raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
		self._access_code = access_code
		self._pad_for_usrp = pad_for_usrp
		#create blocks
		msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
		self._msgq_out = msg_source.msgq()
		#initialize hier2
		gr.hier_block2.__init__(
			self,
			"packet_encoder",
			gr.io_signature(0, 0, 0), # Input signature
			gr.io_signature(1, 1, gr.sizeof_char) # Output signature
		)
		#connect
		self.connect(msg_source, self)
    def __init__(self, packet_sink=None):
        #initialize hier2
        gr.hier_block2.__init__(
            self,
            "ofdm_mod",
            gr.io_signature(1, 1, 1), # Input signature
            gr.io_signature(1, 1, 1) # Output signature
        )
        #create blocks
        """msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
        #connect
        self.connect(self, packet_sink)
        """
	##self.connect(self, packet_sink)
	#self.connect(packet_sink,self)



        msg_in = blocks.message_source(1, DEFAULT_MSGQ_LIMIT)
        msgq = msg_in.msgq()


	#msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
	correlator = digital.correlate_access_code_bb(packet_sink._access_code, packet_sink._threshold)
        framer_sink = digital.framer_sink_1(msgq)
        self.connect(self, packet_sink)
        self.connect(packet_sink, self)
Beispiel #12
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e3

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

        ##################################################
        # Blocks
        ##################################################
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(
            gr.sizeof_char * 1, 4)
        #self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 0, 1), True, 4, [])
        self.blocks_uchar_to_float_0_2 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0_1 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate, True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 4, self.blocks_message_source_0_msgq_in)
        #self.blocks_message_source_0.message_port_register_in(pmt.pmt_intern("input_port"))
        #self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*4, blocks_message_sink_0_msgq_out, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1,
                                                   "simple.float", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vff(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_vector_to_streams_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_uchar_to_float_0_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_uchar_to_float_0_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_uchar_to_float_0_2, 0),
                     (self.blocks_add_xx_0, 0))
        #self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_message_sink_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 3),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 2),
                     (self.blocks_uchar_to_float_0_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 1),
                     (self.blocks_uchar_to_float_0_1, 0))
        self.connect((self.blocks_vector_to_streams_0, 0),
                     (self.blocks_uchar_to_float_0_2, 0))
Beispiel #13
0
    def __init__(self, audio_output_dev):
	gr.hier_block2.__init__(self, "audio_tx",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature
				
        self.sample_rate = sample_rate = 8000
        self.packet_src = blocks.message_source(33)
        voice_decoder = vocoder.gsm_fr_decode_ps()
        s2f = blocks.short_to_float()
        sink_scale = blocks.multiply_const_ff(1.0/32767.)
        audio_sink = audio.sink(sample_rate, audio_output_dev)
        self.connect(self.packet_src, voice_decoder, s2f, sink_scale, audio_sink)
Beispiel #14
0
    def __init__(self, audio_output_dev):
	gr.hier_block2.__init__(self, "audio_tx",
				gr.io_signature(0, 0, 0), # Input signature
				gr.io_signature(0, 0, 0)) # Output signature
				
        self.sample_rate = sample_rate = 8000
        self.packet_src = blocks.message_source(33)
        voice_decoder = vocoder.gsm_fr_decode_ps()
        s2f = blocks.short_to_float()
        sink_scale = blocks.multiply_const_ff(1.0/32767.)
        audio_sink = audio.sink(sample_rate, audio_output_dev)
        self.connect(self.packet_src, voice_decoder, s2f, sink_scale, audio_sink)
Beispiel #15
0
    def __init__(self,
                 modulator,
                 preamble=None,
                 access_code=None,
                 msgq_limit=2,
                 pad_for_usrp=True,
                 use_whitener_offset=False,
                 modulate=True):
        """
	Hierarchical block for sending packets

        Packets to be sent are enqueued by calling send_pkt.
        The output is the complex modulated signal at baseband.

        Args:
            modulator: instance of modulator class (gr_block or hier_block2) (complex baseband out)
            access_code: AKA sync vector (string of 1's and 0's between 1 and 64 long)
            msgq_limit: maximum number of messages in message queue (int)
            pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
            use_whitener_offset: If true, start of whitener XOR string is incremented each packet
        
        See gmsk_mod for remaining parameters
        """

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

        self._modulator = modulator
        self._pad_for_usrp = pad_for_usrp
        self._use_whitener_offset = use_whitener_offset
        self._whitener_offset = 0

        if access_code is None:
            access_code = packet_utils.default_access_code
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (
                access_code, )
        self._access_code = access_code

        if preamble is None:
            preamble = packet_utils.default_preamble
        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (
                preamble, )
        self._preamble = preamble

        # accepts messages from the outside world
        self._pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)
        self.connect(self._pkt_input, self._modulator, self)
Beispiel #16
0
    def __init__(self,
                 samples_per_symbol,
                 bits_per_symbol,
                 preamble='',
                 access_code='',
                 pad_for_usrp=True,
                 do_whitening=False,
                 add_crc=False):
        """
		packet_mod constructor.
        
		Args:
			samples_per_symbol: number of samples per symbol
			bits_per_symbol: number of bits per symbol
			access_code: AKA sync vector
			pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
			do_whitening: apply CC111x whitening
			add_crc: add CRC16 
		"""

        #setup parameters
        self._samples_per_symbol = samples_per_symbol
        self._bits_per_symbol = bits_per_symbol
        self._pad_for_usrp = pad_for_usrp
        if not preamble:  #get preamble
            preamble = cc1111_packet_utils.default_preamble
        if not access_code:  #get access code
            access_code = cc1111_packet_utils.default_access_code
        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (
                preamble, )
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (
                access_code, )
        self._preamble = preamble
        self._access_code = access_code
        self._pad_for_usrp = pad_for_usrp
        self._do_whitening = do_whitening
        self._add_crc = add_crc

        #create blocks
        msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
        #initialize hier2
        gr.hier_block2.__init__(
            self,
            "cc1111_packet_encoder",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_char)  # Output signature
        )
        #connect
        self.connect(msg_source, self)
Beispiel #17
0
 def test_301(self):
     # Use itemsize, limit constructor
     src = blocks.message_source(gr.sizeof_char)
     dst = blocks.vector_sink_b()
     tb = gr.top_block()
     tb.connect(src, dst)
     src.msgq().insert_tail(gr.message_from_string('01234'))
     src.msgq().insert_tail(gr.message_from_string('5'))
     src.msgq().insert_tail(gr.message_from_string(''))
     src.msgq().insert_tail(gr.message_from_string('6789'))
     src.msgq().insert_tail(gr.message(1))  # send EOF
     tb.run()
     self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
Beispiel #18
0
    def test_301(self):
        # Use itemsize, limit constructor
        src = blocks.message_source(gr.sizeof_char)
        dst = blocks.vector_sink_b()
	tb = gr.top_block()
        tb.connect(src, dst)
        src.msgq().insert_tail(gr.message_from_string('01234'))
        src.msgq().insert_tail(gr.message_from_string('5'))
        src.msgq().insert_tail(gr.message_from_string(''))
        src.msgq().insert_tail(gr.message_from_string('6789'))
        src.msgq().insert_tail(gr.message(1))                  # send EOF
        tb.run()
        self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
Beispiel #19
0
    def __init__(self):
        gr.top_block.__init__(self, "Gr Adsb Example")

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

        ##################################################
        # Message Queues
        ##################################################
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(50, 0)
        self.osmosdr_source_0.set_if_gain(50, 0)
        self.osmosdr_source_0.set_bb_gain(50, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)
          
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb('1010000101000000', 0, 'adsb_preamble')
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.3, 0.31, 0)
        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, blocks_message_source_0_msgq_in)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/dev/stdout', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,tx_msgq=adsb_decoder_0_msgq_out,output_type="csv",check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_threshold_ff_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))    
        self.connect((self.blocks_message_source_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.adsb_framer_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
Beispiel #20
0
 def __init__(self, packet_sink=None):
     # initialize hier2
     gr.hier_block2.__init__(
         self,
         "ofdm_mod",
         gr.io_signature(1, 1, packet_sink._hb.input_signature().sizeof_stream_item(0)),  # Input signature
         gr.io_signature(1, 1, self._item_size_out),  # Output signature
     )
     # create blocks
     msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
     self._msgq_out = msg_source.msgq()
     # connect
     self.connect(self, packet_sink)
     self.connect(msg_source, self)
     if packet_sink._hb.output_signature().sizeof_stream_item(0):
         self.connect(packet_sink, blocks.null_sink(packet_sink._hb.output_signature().sizeof_stream_item(0)))
Beispiel #21
0
    def __init__(self,
                 type='BER',
                 win_size=default_win_size,
                 bits_per_symbol=2):
        """
        Error rate constructor.

        Args:
            type: a string 'BER' or 'SER'
            win_size: the number of samples to calculate over
            bits_per_symbol: the number of information bits per symbol (BER only)
        """
        #init
        gr.hier_block2.__init__(
            self,
            'error_rate',
            gr.io_signature(2, 2, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_float),
        )

        print "Warning: the blks2.error_rate is deprecated."

        assert type in ('BER', 'SER')
        self._max_samples = win_size
        self._bits_per_symbol = bits_per_symbol
        #setup message queue
        msg_source = blocks.message_source(gr.sizeof_float, 1)
        self._msgq_source = msg_source.msgq()
        msgq_sink = gr.msg_queue(2)
        msg_sink = blocks.message_sink(gr.sizeof_char, msgq_sink,
                                       False)  #False -> blocking
        inter = blocks.interleave(gr.sizeof_char)
        #start thread
        self._num_errs = 0
        self._err_index = 0
        self._num_samps = 0
        self._err_array = numpy.zeros(self._max_samples, numpy.int8)
        if type == 'BER':
            input_watcher(msgq_sink, self._handler_ber)
        elif type == 'SER':
            input_watcher(msgq_sink, self._handler_ser)
        #connect
        self.connect(msg_source, self)
        self.connect((self, 0), (inter, 0))
        self.connect((self, 1), (inter, 1))
        self.connect(inter, msg_sink)
 def __init__(self, packet_sink=None):
     #initialize hier2
     gr.hier_block2.__init__(
         self,
         "ofdm_mod",
         gr.io_signature(1, 1, packet_sink._hb.input_signature().sizeof_stream_item(0)), # Input signature
         gr.io_signature(1, 1, self._item_size_out) # Output signature
     )
     #create blocks
     msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
     self._msgq_out = msg_source.msgq()
     #connect
     self.connect(self, packet_sink)
     self.connect(msg_source, self)
     if packet_sink._hb.output_signature().sizeof_stream_item(0):
         self.connect(packet_sink,
                      blocks.null_sink(packet_sink._hb.output_signature().sizeof_stream_item(0)))
Beispiel #23
0
 def test_1 (self):
     data = ('hello', 'you', 'there')
     tx_msgq = gr.msg_queue()
     rx_msgq = gr.msg_queue()
     for d in data:
         tx_msgq.insert_tail(gr.message_from_string(d))
     tx_msgq.insert_tail(gr.message(1))                  # send EOF
     tb = gr.top_block()
     src = blocks.message_source(gr.sizeof_char, tx_msgq, "packet_length")
     snk = blocks.message_sink(gr.sizeof_char, rx_msgq, False, "packet_length")
     tb.connect(src, snk)
     tb.start()
     time.sleep(1)
     tb.stop()
     for d in data:
         msg = rx_msgq.delete_head()
         contents = msg.to_string()
         self.assertEqual(d, contents)
Beispiel #24
0
    def __init__(self,
                 samples_per_symbol,
                 bits_per_symbol,
                 preamble='',
                 access_code='',
                 pad_for_usrp=True):
        """
        packet_mod constructor.
        
        Args:
            samples_per_symbol: number of samples per symbol
            bits_per_symbol: number of bits per symbol
            access_code: AKA sync vector
            pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
            payload_length: number of bytes in a data-stream slice

        """

        print "here1"
        gr.basic_block.__init__(self,
                                name="packet_encoder",
                                in_sig=[numpy.uint8],
                                out_sig=[numpy.uint8])
        #setup parameters
        self._samples_per_symbol = samples_per_symbol
        self._bits_per_symbol = bits_per_symbol
        self._pad_for_usrp = pad_for_usrp
        if not preamble:  #get preamble
            preamble = packet_utils.default_preamble
        if not access_code:  #get access code
            access_code = packet_utils.default_access_code
        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (
                preamble, )
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (
                access_code, )

        self._preamble = preamble
        self._access_code = access_code
        self._pad_for_usrp = pad_for_usrp
        #create blocks
        msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
Beispiel #25
0
    def __init__(self, samples_per_symbol, bits_per_symbol, preamble='',
                 access_code='', pad_for_usrp=True, repeat=1, interleave=None,
                 debug=False):
        """
        packet_mod constructor.

        Args:
            samples_per_symbol: number of samples per symbol
            bits_per_symbol: number of bits per symbol
            preamble: string of ascii 0's and 1's
            access_code: AKA sync vector
            pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
        """
        #setup parameters
        self._samples_per_symbol = samples_per_symbol
        self._bits_per_symbol = bits_per_symbol
        self._pad_for_usrp = pad_for_usrp
        self._repeat = repeat
        self._interleave = interleave
        self._debug = debug

        if not preamble: #get preamble
            preamble = packet_utils.default_preamble
        if not access_code: #get access code
            access_code = packet_utils.default_access_code
        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (preamble,)
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
        self._preamble = preamble
        self._access_code = access_code
        self._pad_for_usrp = pad_for_usrp
        #create blocks
        msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
        #initialize hier2
        gr.hier_block2.__init__(
            self,
            "packet_encoder",
            gr.io_signature(0, 0, 0), # Input signature
            gr.io_signature(1, 1, gr.sizeof_char) # Output signature
        )
        #connect
        self.connect(msg_source, self)
    def __init__(self, options):
        gr.hier_block2.__init__(self, "ofdm_transmit_path",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))
        if options.data_file is not None:
            data = gr.message_source(gr.sizeof_gr_complex)
            ofdm = data
            framebytes = 0
        else:
            ofdm = ofdm_rxtx.TX(options)
            qam = raw_qam.qam_tx(options.bitrate,
                                 ofdm.params.data_tones,
                                 ofdm.size,
                                 log=options.log)
            framebytes = qam.framebytes
            data = blocks.message_source(gr.sizeof_char * framebytes, 16)
            data = blocks.message_burst_source(gr.sizeof_char * framebytes, 16)
            self.connect(
                data, blocks.vector_to_stream(gr.sizeof_char, qam.framebytes),
                qam,
                blocks.stream_to_vector(gr.sizeof_gr_complex,
                                        ofdm.params.data_tones), ofdm)

        # precoding module
        nco_sensitivity = 2.0 / options.fft_length  # correct for fine frequency
        nco = raw.pnc_frequency_modulator_fc(nco_sensitivity)
        print "===========>>>>>>>>>"
        print "precoding: ", options.precoding
        if options.precoding == "YES":
            self.connect(ofdm, nco, self)
            self.nco = nco
        else:
            self.connect(ofdm, self)
            self.nco = None

        self.data = data
        self.tx = ofdm
        self.framebytes = framebytes

        if options.log:
            self.connect(self.tx,
                         blocks.file_sink(gr.sizeof_gr_complex, 'logs/tx.dat'))
Beispiel #27
0
    def __init__(self, modulator, preamble=None, access_code=None, msgq_limit=2,
                 pad_for_usrp=True, use_whitener_offset=False, modulate=True):
        """
	Hierarchical block for sending packets

        Packets to be sent are enqueued by calling send_pkt.
        The output is the complex modulated signal at baseband.

        Args:
            modulator: instance of modulator class (gr_block or hier_block2) (complex baseband out)
            access_code: AKA sync vector (string of 1's and 0's between 1 and 64 long)
            msgq_limit: maximum number of messages in message queue (int)
            pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
            use_whitener_offset: If true, start of whitener XOR string is incremented each packet
        
        See gmsk_mod for remaining parameters
        """

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

        self._modulator = modulator
        self._pad_for_usrp = pad_for_usrp
        self._use_whitener_offset = use_whitener_offset
        self._whitener_offset = 0
        
        if access_code is None:
            access_code = packet_utils.default_access_code
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
        self._access_code = access_code
        
        if preamble is None:
            preamble = packet_utils.default_preamble
        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (preamble,)
        self._preamble = preamble

        # accepts messages from the outside world
        self._pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)
        self.connect(self._pkt_input, self._modulator, self)
	def __init__(self, packet_len = 500):
		gr.hier_block2.__init__(self,
			"payload_source",
			gr.io_signature(0, 0, 0),
			gr.io_signature(1, 1, gr.sizeof_char*1))

		self.packet_len = packet_len

		# initialize the message queues
		self.source_queue = gr.msg_queue()

		##################################################
		# Blocks
		self.msg_source = blocks.message_source(gr.sizeof_char*1, self.source_queue)
		self.stream_to_tagged_stream_txpath = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, "packet_len")

		##################################################
		# Connections
		#Data source
		self.connect(self.msg_source, self.stream_to_tagged_stream_txpath, self)
Beispiel #29
0
    def __init__(self, type='BER', win_size=default_win_size, bits_per_symbol=2):
        """
        Error rate constructor.

        Args:
            type: a string 'BER' or 'SER'
            win_size: the number of samples to calculate over
            bits_per_symbol: the number of information bits per symbol (BER only)
        """
        #init
        gr.hier_block2.__init__(
            self, 'error_rate',
            gr.io_signature(2, 2, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_float),
        )

        print "Warning: the blks2.error_rate is deprecated."

        assert type in ('BER', 'SER')
        self._max_samples = win_size
        self._bits_per_symbol = bits_per_symbol
        #setup message queue
        msg_source = blocks.message_source(gr.sizeof_float, 1)
        self._msgq_source = msg_source.msgq()
        msgq_sink = gr.msg_queue(2)
        msg_sink = blocks.message_sink(gr.sizeof_char, msgq_sink, False) #False -> blocking
        inter = blocks.interleave(gr.sizeof_char)
        #start thread
        self._num_errs = 0
        self._err_index = 0
        self._num_samps = 0
        self._err_array = numpy.zeros(self._max_samples, numpy.int8)
        if type == 'BER':
            input_watcher(msgq_sink, self._handler_ber)
        elif type == 'SER':
            input_watcher(msgq_sink, self._handler_ser)
        #connect
        self.connect(msg_source, self)
        self.connect((self, 0), (inter, 0))
        self.connect((self, 1), (inter, 1))
        self.connect(inter, msg_sink)
Beispiel #30
0
    def __init__(self, packet_len=500):
        gr.hier_block2.__init__(self, "payload_source",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_char * 1))

        self.packet_len = packet_len

        # initialize the message queues
        self.source_queue = gr.msg_queue()

        ##################################################
        # Blocks
        self.msg_source = blocks.message_source(gr.sizeof_char * 1,
                                                self.source_queue)
        self.stream_to_tagged_stream_txpath = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, "packet_len")

        ##################################################
        # Connections
        #Data source
        self.connect(self.msg_source, self.stream_to_tagged_stream_txpath,
                     self)
Beispiel #31
0
 def __init__(self,
              samples_per_symbol,
              bits_per_symbol,
              access_code='',
              pad_for_usrp=True):
     """
     packet_mod constructor.
     
     Args:
         samples_per_symbol: number of samples per symbol
         bits_per_symbol: number of bits per symbol
         access_code: AKA sync vector
         pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
         payload_length: number of bytes in a data-stream slice
     """
     #setup parameters
     self._samples_per_symbol = samples_per_symbol
     self._bits_per_symbol = bits_per_symbol
     self._pad_for_usrp = pad_for_usrp
     if not access_code:  #get access code
         access_code = packet_utils.default_access_code
     if not packet_utils.is_1_0_string(access_code):
         raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (
             access_code, )
     self._access_code = access_code
     self._pad_for_usrp = pad_for_usrp
     #create blocks
     msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
     self._msgq_out = msg_source.msgq()
     #initialize hier2
     gr.hier_block2.__init__(
         self,
         "packet_encoder",
         gr.io_signature(0, 0, 0),  # Input signature
         gr.io_signature(1, 1, gr.sizeof_char)  # Output signature
     )
     #connect
     self.connect(msg_source, self)
Beispiel #32
0
    def __init__(self):
        """
        packet_mod constructor.

        Args:
            station_id: The ID of the station transmitting the data.
        """
        # setup parameters
        self._samples_per_symbol = 1
        self._bits_per_symbol = 1
        self._pad_for_usrp = False

        access_code = STATION_CODES["default"]
        preamble = packet_utils.default_preamble + "1010110011011101101001001110001011110010100011000010000011111100"

        if not packet_utils.is_1_0_string(preamble):
            raise ValueError, "Invalid preamble %r. Must be string of 1's and 0's" % (
                preamble, )
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (
                access_code, )

        self._preamble = preamble
        self._access_code = access_code

        # create blocks
        msg_source = blocks.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
        self._msgq_out = msg_source.msgq()
        # initialize hier2
        gr.hier_block2.__init__(
            self,
            "packet_encoder",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_char)  # Output signature
        )
        # connect
        self.connect(msg_source, self)
Beispiel #33
0
    def __init__(self):
        gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        # VerA
        # Create Input Vector here
        # barker13_uni = [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0]
        # barker13_wpadding_uni = [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0]
        # # sync_pattern = barker13_uni
        # sync_pattern = barker13_wpadding_uni
        # s = "Hello World\n"
        # msg = string_to_list.conv_string_to_1_0_list(s)
        # input_vector = sync_pattern + msg
        # self.input_vector_source = blocks.vector_source_b(input_vector, True, 1, [])
        # self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

        # VerB
        self.msgq_limit = msgq_limit = 2
        self.pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)

        self.mod = digital.gfsk_mod(
            samples_per_symbol=4,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )

        ##################################################
        # Connections
        ##################################################
        # VerA
        # self.connect(self.input_vector_source, self.input_unpacked_to_packed,  self.mod, self)

        # VerB
        self.connect(self.pkt_input, self.mod, self)
Beispiel #34
0
 def __init__(self, frame, panel, vbox, argv):
     stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
     self._frame = frame;
     self._panel = panel;
     self._vbox = vbox;
     
     ## Variable
     self._samp_rate = 1000000
     self._freq = 433.92e6
     self._unit = 5.33e-4 # 533us unit pulse width
     
     self._pkt_source = blocks.message_source(gr.sizeof_char, 8)
     self._modulator = bask_mod(samples_per_symbol=int(self._unit*self._samp_rate))
     self.init_gui()
     
     # init uhd sink (USRP)
     self._uhd_sink = uhd.usrp_sink(device_addr='', stream_args=uhd.stream_args('fc32'))
     self._uhd_sink.set_samp_rate(self._samp_rate)
     self._uhd_sink.set_center_freq(self._freq, 0)
     self._uhd_sink.set_gain(15, 0)
     self._uhd_sink.set_antenna('TX/RX', 0)
     
     # wire everything up
     self.connect(self._pkt_source, self._modulator, self._uhd_sink)
Beispiel #35
0
    def __init__(self):
        gr.top_block.__init__(self, "Cc Ordenat")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Cc Ordenat")
        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", "cc_ordenat")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 480e3
        self.lo_offset = lo_offset = 1e6
        self.freq_tx = freq_tx = 437.35e6
        self.freq_rx = freq_rx = 437.35e6

        ##################################################
        # Message Queues
        ##################################################
        uhd_amsg_source_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)

        ##################################################
        # Blocks
        ##################################################
        self.usrp_control_pdu_to_pmt_0_0 = usrp_control.pdu_to_pmt()
        self.usrp_control_pdu_to_pmt_0 = usrp_control.pdu_to_pmt()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq_rx, 0)
        self.uhd_usrp_source_0.set_gain(65, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq_tx, 0)
        self.uhd_usrp_sink_0.set_gain(77.5, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_amsg_source_0 = uhd.amsg_source(
            device_addr="", msgq=uhd_amsg_source_0_msgq_out)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_1.set_update_time(0.10)
        self.qtgui_number_sink_1.set_title("")

        labels = ["Frequency Shift", "", "", "", "", "", "", "", "", ""]
        units = ["Hz", "", "", "", "", "", "", "", "", ""]
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_1.set_min(i, -5000)
            self.qtgui_number_sink_1.set_max(i, 5000)
            self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_1.set_label(i, labels[i])
            self.qtgui_number_sink_1.set_unit(i, units[i])
            self.qtgui_number_sink_1.set_factor(i, factor[i])

        self.qtgui_number_sink_1.enable_autoscale(False)
        self._qtgui_number_sink_1_win = sip.wrapinstance(
            self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_1_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 2)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = [
            "Floor Power", "Band Power", "Noise Power", "", "", "", "", "", "",
            ""
        ]
        units = ["dBm", "dBm", "dBm", "", "", "", "", "", "", ""]
        colors = [("blue", "red"), ("blue", "red"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(2):
            self.qtgui_number_sink_0.set_min(i, -174)
            self.qtgui_number_sink_0.set_max(i, 10)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, "packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 56, "packet_len")
        self.blocks_socket_pdu_0_0_1 = blocks.socket_pdu(
            "TCP_SERVER", "", "52000", 223, False)
        self.blocks_socket_pdu_0_0_0_0 = blocks.socket_pdu(
            "UDP_SERVER", "", "52003", 255, False)
        self.blocks_socket_pdu_0_0_0 = blocks.socket_pdu(
            "UDP_SERVER", "", "52002", 255, False)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "",
                                                       "52001", 223, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52004",
                                                     255, True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.CC_Byte_Synchronizer_0 = CC_Byte_Synchronizer(
            access_code='11010011100100011101001110010001',
            param_packet_len=223,
            param_threshold=3,
        )
        self.CC_9600_TX_0 = CC_9600_TX()
        self.CC_9600_RX_0 = CC_9600_RX(man_offset=0, )

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.CC_Byte_Synchronizer_0, 'out'),
                         (self.blocks_socket_pdu_0_0_1, 'pdus'))
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'),
                         (self.CC_9600_TX_0, 'packet'))
        self.msg_connect((self.blocks_socket_pdu_0_0_0, 'pdus'),
                         (self.usrp_control_pdu_to_pmt_0, 'in'))
        self.msg_connect((self.blocks_socket_pdu_0_0_0_0, 'pdus'),
                         (self.usrp_control_pdu_to_pmt_0_0, 'in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.usrp_control_pdu_to_pmt_0, 'out'),
                         (self.uhd_usrp_source_0, 'command'))
        self.msg_connect((self.usrp_control_pdu_to_pmt_0_0, 'out'),
                         (self.uhd_usrp_sink_0, 'command'))
        self.connect((self.CC_9600_RX_0, 0), (self.CC_Byte_Synchronizer_0, 0))
        self.connect((self.CC_9600_RX_0, 1), (self.qtgui_number_sink_0, 1))
        self.connect((self.CC_9600_RX_0, 2), (self.qtgui_number_sink_0, 0))
        self.connect((self.CC_9600_RX_0, 3), (self.qtgui_number_sink_1, 0))
        self.connect((self.CC_9600_TX_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.CC_9600_RX_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_sink_x_0, 0))
Beispiel #36
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Adsb 4")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Adsb 4")
        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", "uhd_adsb_4")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.rx_gain = rx_gain = 40
        self.low = low = .3
        self.high = high = .31
        self.freq = freq = 1090e6
        self.bb_gain = bb_gain = 100e3

        ##################################################
        # Message Queues
        ##################################################
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._rx_gain_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            512,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0.set_y_axis(0, 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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, .00001,
                                                  .00005, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self._low_tool_bar = Qt.QToolBar(self)
        self._low_tool_bar.addWidget(Qt.QLabel("low" + ": "))
        self._low_line_edit = Qt.QLineEdit(str(self.low))
        self._low_tool_bar.addWidget(self._low_line_edit)
        self._low_line_edit.returnPressed.connect(lambda: self.set_low(
            eng_notation.str_to_num(str(self._low_line_edit.text().toAscii())))
                                                  )
        self.top_layout.addWidget(self._low_tool_bar)
        self._high_tool_bar = Qt.QToolBar(self)
        self._high_tool_bar.addWidget(Qt.QLabel("high" + ": "))
        self._high_line_edit = Qt.QLineEdit(str(self.high))
        self._high_tool_bar.addWidget(self._high_line_edit)
        self._high_line_edit.returnPressed.connect(lambda: self.set_high(
            eng_notation.str_to_num(str(self._high_line_edit.text().toAscii()))
        ))
        self.top_layout.addWidget(self._high_tool_bar)
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb(
            '1010000101000000', 0, 'adsb_preamble')
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(64, True)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/dev/stdout', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self._bb_gain_tool_bar = Qt.QToolBar(self)
        self._bb_gain_tool_bar.addWidget(Qt.QLabel("bb_gain" + ": "))
        self._bb_gain_line_edit = Qt.QLineEdit(str(self.bb_gain))
        self._bb_gain_tool_bar.addWidget(self._bb_gain_line_edit)
        self._bb_gain_line_edit.returnPressed.connect(lambda: self.set_bb_gain(
            eng_notation.str_to_num(
                str(self._bb_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._bb_gain_tool_bar)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,
                                           tx_msgq=adsb_decoder_0_msgq_out,
                                           output_type="csv",
                                           check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.adsb_framer_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
Beispiel #37
0
    def __init__(self):
        gr.top_block.__init__(self, "Transceiverloopbacksimulator")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Transceiverloopbacksimulator")
        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",
                                     "transceiverLoopbackSimulator")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.txUDPPort = txUDPPort = 9001
        self.time_offset = time_offset = 1.00
        self.sps = sps = 4
        self.snr = snr = 25
        self.samp_rate = samp_rate = 320000
        self.rxUDPPort = rxUDPPort = 9002
        self.modemConfiguration = modemConfiguration = {
            'encoder': 'cc',
            'rate': 0.5,
            'arity': 4,
            'excessBW': 0.35,
            'preambleOverhead': 8,
            'MTU': 100
        }
        self.freq_offset = freq_offset = 0

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

        ##################################################
        # Blocks
        ##################################################
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            "Timing Offset", "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._time_offset_win, 0, 2, 1, 1)
        self._freq_offset_range = Range(-0.25, 0.25, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            "Frequency Offset",
                                            "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 0, 1, 1, 1)
        self._snr_range = Range(0, 30, 1, 25, 200)
        self._snr_win = RangeWidget(self._snr_range, self.set_snr, "SNR (dB)",
                                    "counter_slider", float)
        self.top_grid_layout.addWidget(self._snr_win, 0, 0, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Frame",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

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

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

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

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

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

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

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

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

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1,
                                       1)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0,
            frequency_offset=freq_offset,
            epsilon=time_offset,
            taps=(-1, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     "127.0.0.1", txUDPPort,
                                                     modemConfiguration['MTU'],
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "127.0.0.1", rxUDPPort,
                                                 modemConfiguration['MTU'],
                                                 True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_message_sink_0 = blocks.message_sink(
            gr.sizeof_char * 1, blocks_message_sink_0_msgq_out, False)
        self.SatelliteModem_SyncPreamble_0 = SatelliteModem.SyncPreamble(
            int((modemConfiguration['MTU'] + 6) / modemConfiguration['rate']),
            modemConfiguration['preambleOverhead'])
        self.SatelliteModem_PreambleDetector_0 = SatelliteModem.PreambleDetector(
            int((modemConfiguration['MTU'] + 6) / modemConfiguration['rate']),
            modemConfiguration['preambleOverhead'])
        self.SatelliteModem_Framer_0 = SatelliteModem.Framer(
            SatelliteModem_Framer_0_msgq_in, modemConfiguration['MTU'], 0)
        self.SatelliteModem_FECEncoder_0 = SatelliteModem.FECEncoder(
            modemConfiguration['encoder'], modemConfiguration['MTU'] + 6,
            modemConfiguration['rate'])
        self.SatelliteModem_FECDecoder_0 = SatelliteModem.FECDecoder(
            modemConfiguration['encoder'], modemConfiguration['MTU'] + 6,
            modemConfiguration['rate'])
        self.SatelliteModem_Deframer_0 = SatelliteModem.Deframer(
            SatelliteModem_Deframer_0_msgq_out, modemConfiguration['MTU'])
        self.SatelliteModem_DPSKTransmitter_0 = SatelliteModem.DPSKTransmitter(
            1, modemConfiguration['excessBW'], sps,
            modemConfiguration['arity'])
        self.SatelliteModem_DPSKReceiver_0 = SatelliteModem.DPSKReceiver(
            modemConfiguration['excessBW'], sps, modemConfiguration['arity'])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.SatelliteModem_DPSKReceiver_0, 0),
                     (self.SatelliteModem_PreambleDetector_0, 0))
        self.connect((self.SatelliteModem_DPSKReceiver_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.SatelliteModem_DPSKTransmitter_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.SatelliteModem_DPSKTransmitter_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.SatelliteModem_FECDecoder_0, 0),
                     (self.SatelliteModem_Deframer_0, 0))
        self.connect((self.SatelliteModem_FECEncoder_0, 0),
                     (self.SatelliteModem_SyncPreamble_0, 0))
        self.connect((self.SatelliteModem_Framer_0, 0),
                     (self.SatelliteModem_FECEncoder_0, 0))
        self.connect((self.SatelliteModem_PreambleDetector_0, 0),
                     (self.SatelliteModem_FECDecoder_0, 0))
        self.connect((self.SatelliteModem_PreambleDetector_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.SatelliteModem_SyncPreamble_0, 0),
                     (self.SatelliteModem_DPSKTransmitter_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_message_sink_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.SatelliteModem_DPSKReceiver_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
Beispiel #38
0
    def __init__(self,q_rx,q_tx,samp_per_sym=3, antenna='TX/RX', \
        rx_freq=850000000.0, rx_gain=15.0, spec='A:0', tx_gain=15.0, \
        args='serial=E0R11Y0B1', bit_rate=100000.0, \
        tx_freq=851000000.0, tx_amplitude=0.25,):
        '''Constructor.
        TODO: I AM NOT SETTING the Tx_AMPLITUDE
        @param q_rx:
        '''
        gr.top_block.__init__(self)
        self.sink_queue = gr.msg_queue()
        bits_per_sym = 2   # only for QPSK!
        #samp_per_sym=3
        sym_rate = bit_rate/bits_per_sym 
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr=args,
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_subdev_spec(spec, 0)
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna(antenna, 0)
        self.set_sample_rate(self.uhd_usrp_source_0,sym_rate, samp_per_sym)

        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr=args,
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_subdev_spec(spec, 0)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna(antenna, 0)
        self.set_sample_rate(self.uhd_usrp_sink_0,sym_rate, samp_per_sym)

        #self.Add(self.wxgui_scopesink2_0_0.win)
        self.hier_rx_0 = hier_rx.hier_rx(
            bw_clock_sync=2*math.pi/100,
            bw_fll=2*math.pi/100,
            bits_per_sym=bits_per_sym,
            bw_costas=2*math.pi/100,
            n_filts=32,
            len_sym_srrc=11,
            constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(),
            samp_per_sym=samp_per_sym,
            alfa=0.45,
        )
        
        
        self.hier_tx_0 = hier_tx.hier_tx(
            alfa=0.45,
            samp_per_sym=samp_per_sym,
            constellation=[-1-1j,1-1j, 1+1j, -1+1j],
            len_sym_srrc=11,
            out_const_mul=0.4,
            bits_per_sym=bits_per_sym,
        )


        threshold = 12              # FIXME raise exception
        access_code = packet_utils.default_access_code
    
        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, 4)
        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
        self.correlator = digital.correlate_access_code_bb( access_code, threshold)
        #"Arreglar access_code en la llamada a correlate""""""
        self.framer_sink = digital.framer_sink_1(self._rcvd_pktq)
        
        self.vsnk_src = blocks.vector_sink_b()
        self.m_sink   = blocks.message_sink(gr.sizeof_char*1, self.sink_queue,True)
        ##################################################
        # Connections
        ##################################################
        #self.connect((self.hier_tx_pencoder_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect(( self.blocks_message_source_0, 0),(self.hier_tx_0, 0) )
        self.connect((self.hier_tx_0, 0), (self.uhd_usrp_sink_0, 0))

        self.connect((self.uhd_usrp_source_0, 0), (self.hier_rx_0, 0))
        self.connect((self.hier_rx_0, 0), self.correlator, self.framer_sink)
        self._watcher = _queue_watcher_thread(self._rcvd_pktq,q_rx)
        queue = self.blocks_message_source_0.msgq()
        self.snd = SendData(q_tx,queue,samp_per_sym)   
Beispiel #39
0
Datei: tx.py Projekt: jm-/voiz
    def __init__(   self,
                    carrier,
                    sideband,
                    transition,
                    sps,
                    interpolation,
                    looutdev):

        gr.top_block.__init__(self, "Transmit block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = SAMPLE_RATE

        self.carrier = carrier
        self.sideband = sideband
        self.transition = transition
        self.sps = sps
        self.interpolation = interpolation

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=interpolation,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,SAMPLE_RATE,carrier-sideband,carrier+sideband,transition)), -carrier, SAMPLE_RATE)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=sps,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
                samples_per_symbol=sps,
                bits_per_symbol=1,
                preamble="",
                access_code="",
                pad_for_usrp=False,
            ),
            payload_length=PAYLOAD_LEN,
        )
        self.audio_sink_0 = audio.sink(SAMPLE_RATE, looutdev, True)

        self.source_queue = gr.msg_queue()
        self.msg_source = blocks.message_source(gr.sizeof_char, self.source_queue)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.msg_source, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
    def __init__(self, principal_gui, options):
        '''
        See below for what options should hold
        '''
        gr.hier_block2.__init__(self, "transmit_path",
                gr.io_signature(0, 0, 0),                    # Input signature
                gr.io_signature(0, 0, 0)) # Output signature
        
        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose            = options.verbose
        self._tx_amplitude       = options.tx_amplitude    # digital amplitude sent to USRP
        self._bitrate            = options.rate        # desired bit rate
        self._samples_per_symbol = options.sps  # desired samples/baud

        #setup usrp
        self._setup_usrp_sink(options)
        
        #create a BPSK modulator 
        self.modulator = bpsk_modulator(principal_gui, options)         # the modulator we are using
        
        #create packet input like in ieee 802.15.4
        #the size of the queue is 2 messages 
        #######################*************
        msgq_limit = 10
        self.pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)
             
        #The same chain like in ieee transceiver
        #add gain like in ieee802.15.4
        #######################################*****************
        #self.normal_gain = 8000
        #self.gain = gr.multiply_const_cc (self.normal_gain)
    
        self.amp = blocks.multiply_const_cc(options.amplitude)
        #self.set_tx_amplitude(self._tx_amplitude)

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

        # Connect components in the flowgraph
        #self.connect(self.packet_transmitter, self.amp, self)
#        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
#            principal_gui.GetWin(),
#            title="Constellation Plot",
#            sample_rate=options.samp_rate,
#            frame_rate=5,
#            const_size=2048,
#            M=2,
#            theta=0,
#            fmax=0.06,
#            mu=0.5,
#            gain_mu=0.005,
#            symbol_rate=options.samp_rate/self._samples_per_symbol,
#            omega_limit=0.005,
#        )
#        principal_gui.Add(self.wxgui_constellationsink2_0.win)
        
        '''For Stream of bits '''
        self.vector_source = blocks.vector_source_b([1,], True)
        self.scrambler = digital.scrambler_bb(0x10,0x7F,7)
        #self.connect(self.vector_source,self.scrambler, self.modulator, self.amp, self.u)
        #self.connect(self.modulator,self.wxgui_constellationsink2_0)
        '''End For Stream of bits '''
        
        
        self.connect(self.pkt_input, self.modulator, self.amp, self.u)
    def __init__(self, freq_tx, freq_rx, gain, fname):
        gr.top_block.__init__(self, "Repeater")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 200000
        self.gain_tx = gain_tx = gain
        self.gain_rx = gain_rx = 15
        self.freq_tx = freq_tx
        self.freq_rx = freq_rx
        self.fname = fname

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

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq_rx, 0)
        self.uhd_usrp_source_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0.set_bandwidth(10e6, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq_tx, 0)
        self.uhd_usrp_sink_0.set_gain(gain_tx, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(10e6, 0)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, samp_rate / 2 - 2e3,
                            (samp_rate / 2 - 2e3) / 4, firdes.WIN_HAMMING,
                            6.76))
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
            samples_per_symbol=2,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=2,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, ))
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_message_sink_0 = blocks.message_sink(
            gr.sizeof_char * 1, blocks_message_sink_0_msgq_out, False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, fname,
                                                   True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=2,
                bits_per_symbol=1,
                preamble='',
                access_code='',
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code='',
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_message_sink_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_gmsk_demod_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Beispiel #42
0
    def __init__(self, parameter_0=0):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.parameter_0 = parameter_0

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000

        ##################################################
        # Message Queues
        ##################################################
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(2)
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	1090000000, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	256, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0.set_y_axis(0, 1.2)

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

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, .00001, .00002, 0, "adsb_preamble")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()

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

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

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

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb('1010000101000000', 0, 'adsb_preamble')
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(4, True)
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, blocks_message_source_0_msgq_in)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/zleffke/workspace/rocksat/2017/waveforms/captures/adsb_20161214_2M.32fc', True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/dev/stdout', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,tx_msgq=adsb_decoder_0_msgq_out,output_type="hex",check_parity=False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_message_source_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.adsb_framer_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.blocks_uchar_to_float_0, 0))
Beispiel #43
0
    def __init__(self):
        gr.top_block.__init__(self, "Adsb Uhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Adsb Uhd")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.thresh_mult = thresh_mult = 2
        self.samp_rate = samp_rate = 2e6
        self.low_thresh = low_thresh = 0
        self.rx_gain = rx_gain = 40
        self.low_thresh_lbl = low_thresh_lbl = low_thresh
        self.high = high = .4
        self.hi_thresh_lbl = hi_thresh_lbl = low_thresh * thresh_mult
        self.freq = freq = 1090e6
        self.filter_taps = filter_taps = firdes.low_pass(
            1, samp_rate, samp_rate / 2, 50000, firdes.WIN_FLATTOP, 6.76)
        self.decim = decim = 1
        self.center = center = 0
        self.bb_gain = bb_gain = .1e6

        ##################################################
        # Message Queues
        ##################################################
        adsb_decoder_0_msgq_out = baz_message_server_0_msgq_in = gr.msg_queue(
            2)
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.probe_power = blocks.probe_signal_f()
        self._thresh_mult_tool_bar = Qt.QToolBar(self)
        self._thresh_mult_tool_bar.addWidget(Qt.QLabel("thresh_mult" + ": "))
        self._thresh_mult_line_edit = Qt.QLineEdit(str(self.thresh_mult))
        self._thresh_mult_tool_bar.addWidget(self._thresh_mult_line_edit)
        self._thresh_mult_line_edit.returnPressed.connect(
            lambda: self.set_thresh_mult(
                eng_notation.str_to_num(
                    str(self._thresh_mult_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._thresh_mult_tool_bar)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._rx_gain_tool_bar)

        def _low_thresh_probe():
            while True:
                val = self.probe_power.level()
                try:
                    self.set_low_thresh(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _low_thresh_thread = threading.Thread(target=_low_thresh_probe)
        _low_thresh_thread.daemon = True
        _low_thresh_thread.start()

        self._center_tool_bar = Qt.QToolBar(self)
        self._center_tool_bar.addWidget(Qt.QLabel("center" + ": "))
        self._center_line_edit = Qt.QLineEdit(str(self.center))
        self._center_tool_bar.addWidget(self._center_line_edit)
        self._center_line_edit.returnPressed.connect(lambda: self.set_center(
            eng_notation.str_to_num(
                str(self._center_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._center_tool_bar)
        self._bb_gain_tool_bar = Qt.QToolBar(self)
        self._bb_gain_tool_bar.addWidget(Qt.QLabel("bb_gain" + ": "))
        self._bb_gain_line_edit = Qt.QLineEdit(str(self.bb_gain))
        self._bb_gain_tool_bar.addWidget(self._bb_gain_line_edit)
        self._bb_gain_line_edit.returnPressed.connect(lambda: self.set_bb_gain(
            eng_notation.str_to_num(
                str(self._bb_gain_line_edit.text().toAscii()))))
        self.top_layout.addWidget(self._bb_gain_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.01)
        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(-130, -70)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            4096,  #size
            samp_rate,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0.set_y_axis(0, 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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, .3,
                                                  .0001, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -80)
        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)
        self._low_thresh_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._low_thresh_lbl_formatter = None
        else:
            self._low_thresh_lbl_formatter = lambda x: x

        self._low_thresh_lbl_tool_bar.addWidget(
            Qt.QLabel("low_thresh_lbl" + ": "))
        self._low_thresh_lbl_label = Qt.QLabel(
            str(self._low_thresh_lbl_formatter(self.low_thresh_lbl)))
        self._low_thresh_lbl_tool_bar.addWidget(self._low_thresh_lbl_label)
        self.top_layout.addWidget(self._low_thresh_lbl_tool_bar)

        self._high_tool_bar = Qt.QToolBar(self)
        self._high_tool_bar.addWidget(Qt.QLabel("high" + ": "))
        self._high_line_edit = Qt.QLineEdit(str(self.high))
        self._high_tool_bar.addWidget(self._high_line_edit)
        self._high_line_edit.returnPressed.connect(lambda: self.set_high(
            eng_notation.str_to_num(str(self._high_line_edit.text().toAscii()))
        ))
        self.top_layout.addWidget(self._high_tool_bar)
        self._hi_thresh_lbl_tool_bar = Qt.QToolBar(self)

        if None:
            self._hi_thresh_lbl_formatter = None
        else:
            self._hi_thresh_lbl_formatter = lambda x: x

        self._hi_thresh_lbl_tool_bar.addWidget(
            Qt.QLabel("hi_thresh_lbl" + ": "))
        self._hi_thresh_lbl_label = Qt.QLabel(
            str(self._hi_thresh_lbl_formatter(self.hi_thresh_lbl)))
        self._hi_thresh_lbl_tool_bar.addWidget(self._hi_thresh_lbl_label)
        self.top_layout.addWidget(self._hi_thresh_lbl_tool_bar)

        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            1, (filter_taps), center, samp_rate)
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb(
            '1010000101000000', 0, 'adsb_preamble')
        self.blocks_threshold_ff_0 = blocks.threshold_ff(
            low_thresh, low_thresh * thresh_mult, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (bb_gain, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            1000, .0001, 4000)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/dev/stdout', True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.baz_message_server_0 = message_server.message_server(
            msgq=baz_message_server_0_msgq_in, port=12345)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,
                                           tx_msgq=adsb_decoder_0_msgq_out,
                                           output_type="csv",
                                           check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.probe_power, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.adsb_framer_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Transceiverloopbacksimulator Nogui")

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

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

        ##################################################
        # Blocks
        ##################################################
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0,
            frequency_offset=.01,
            epsilon=1,
            taps=(-1, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1,
                                                     "127.0.0.1", txUDPPort,
                                                     modemConfiguration['MTU'],
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "127.0.0.1", rxUDPPort,
                                                 modemConfiguration['MTU'],
                                                 True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_message_sink_0 = blocks.message_sink(
            gr.sizeof_char * 1, blocks_message_sink_0_msgq_out, False)
        self.SatelliteModem_SyncPreamble_0 = SatelliteModem.SyncPreamble(
            int((modemConfiguration['MTU'] + 6) / modemConfiguration['rate']),
            modemConfiguration['preambleOverhead'])
        self.SatelliteModem_PreambleDetector_0 = SatelliteModem.PreambleDetector(
            int((modemConfiguration['MTU'] + 6) / modemConfiguration['rate']),
            modemConfiguration['preambleOverhead'])
        self.SatelliteModem_Framer_0 = SatelliteModem.Framer(
            SatelliteModem_Framer_0_msgq_in, modemConfiguration['MTU'], 0)
        self.SatelliteModem_FECEncoder_0 = SatelliteModem.FECEncoder(
            modemConfiguration['encoder'], modemConfiguration['MTU'] + 6,
            modemConfiguration['rate'])
        self.SatelliteModem_FECDecoder_0 = SatelliteModem.FECDecoder(
            modemConfiguration['encoder'], modemConfiguration['MTU'] + 6,
            modemConfiguration['rate'])
        self.SatelliteModem_Deframer_0 = SatelliteModem.Deframer(
            SatelliteModem_Deframer_0_msgq_out, modemConfiguration['MTU'])
        self.SatelliteModem_DPSKTransmitter_0 = SatelliteModem.DPSKTransmitter(
            1, modemConfiguration['excessBW'], sps,
            modemConfiguration['arity'])
        self.SatelliteModem_DPSKReceiver_0 = SatelliteModem.DPSKReceiver(
            modemConfiguration['excessBW'], sps, modemConfiguration['arity'])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.SatelliteModem_DPSKReceiver_0, 0),
                     (self.SatelliteModem_PreambleDetector_0, 0))
        self.connect((self.SatelliteModem_DPSKTransmitter_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.SatelliteModem_FECDecoder_0, 0),
                     (self.SatelliteModem_Deframer_0, 0))
        self.connect((self.SatelliteModem_FECEncoder_0, 0),
                     (self.SatelliteModem_SyncPreamble_0, 0))
        self.connect((self.SatelliteModem_Framer_0, 0),
                     (self.SatelliteModem_FECEncoder_0, 0))
        self.connect((self.SatelliteModem_PreambleDetector_0, 0),
                     (self.SatelliteModem_FECDecoder_0, 0))
        self.connect((self.SatelliteModem_SyncPreamble_0, 0),
                     (self.SatelliteModem_DPSKTransmitter_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_message_sink_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.SatelliteModem_DPSKReceiver_0, 0))
Beispiel #45
0
    def __init__(self,
                 center_freq,
                 samp_rate,
                 gain,
                 fsk_deviation_hz,
                 baseband_file_name,
                 baseband_samp_rate,
                 freq_hop_list,
                 verbose=False,
                 hardware_transmit_enable=True,
                 hw_sel=0,
                 hw_gain=0,
                 iq_file_out=False):
        gr.top_block.__init__(self)

        # display the parameters used for transmit
        if True:  #verbose:
            print "Baseband File Name: {}".format(baseband_file_name)
            print "Baseband Sample Rate: {}".format(baseband_samp_rate)
            print "SDR Center Freq: {}".format(center_freq)
            print "SDR Sample Rate: {}".format(samp_rate)
            print "Flowgraph Gain: {}".format(gain)
            print "GFSK deviation: {}".format(fsk_deviation_hz)
            print "Freq 0-2: {}".format(freq_hop_list)
            print "Verbose: {}".format(verbose)
            print "Hardware TX Enable: {}".format(hardware_transmit_enable)
            print "IQ to File: {}".format(iq_file_out)

        ##################################################
        # Variables
        ##################################################
        self.center_freq = center_freq
        self.samp_rate = samp_rate
        self.gain = gain
        self.fsk_deviation_hz = fsk_deviation_hz
        self.baseband_file_name = baseband_file_name
        self.baseband_samp_rate = baseband_samp_rate
        self.freq_hop_list = freq_hop_list
        self.hw_sel = hw_sel
        self.hw_gain = hw_gain
        """
        r = gr.enable_realtime_scheduling()
        if r == gr.RT_OK:
            print "Note: Realtime scheduling enabled"
        """
        # self.cutoff_freq = channel_width/2
        ##################################################
        # Blocks
        ##################################################
        # replace this with a message source
        #self.blocks_file_source_0 = blocks.file_source(
        #    gr.sizeof_char * 1,
        #    baseband_file_name,
        #    repeat)
        # message sink is primary method of getting baseband data into
        # the flowgraph
        #self.source_queue = gr.msg_queue()
        #self.blocks_message_source_0 = blocks.message_source(
        #    gr.sizeof_char*1,
        #    self.source_queue)
        #self.blocks_message_source_0.set_max_output_buffer(1)

        # TESTING FLOWGRAPH ONLY (DELETE WHEN DONE)
        #blocks_message_sink_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(2)
        #self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 0, 1), True, 4, [])
        #self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char * 4, blocks_message_sink_0_msgq_out, False)
        #self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_message_sink_0, 0))

        self.source_queue_v = gr.msg_queue()
        #self.source_queue_v = gr.msg_queue(2048) # smaller values cause hang
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 4, self.source_queue_v)
        self.blocks_vector_to_streams = blocks.vector_to_streams(
            gr.sizeof_char * 1, 4)
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_vector_to_streams, 0))

        # blocks and connections for carrier for first hop frequency
        self.analog_sig_source_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq_hop_list[0] - center_freq, 1,
            0)
        self.repeat_0 = blocks.repeat(gr.sizeof_char * 1,
                                      int(samp_rate / baseband_samp_rate))
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_multiply_0 = blocks.multiply_vcc(1)
        self.connect((self.blocks_vector_to_streams, 1), (self.repeat_0, 0))
        self.connect((self.repeat_0, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_0, 1))
        self.connect((self.analog_sig_source_0, 0),
                     (self.blocks_multiply_0, 0))

        # blocks and connections for carrier for second hop frequency
        self.analog_sig_source_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq_hop_list[1] - center_freq, 1,
            0)
        self.repeat_1 = blocks.repeat(gr.sizeof_char * 1,
                                      int(samp_rate / baseband_samp_rate))
        self.blocks_uchar_to_float_1 = blocks.uchar_to_float()
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_multiply_1 = blocks.multiply_vcc(1)
        self.connect((self.blocks_vector_to_streams, 2), (self.repeat_1, 0))
        self.connect((self.repeat_1, 0), (self.blocks_uchar_to_float_1, 0))
        self.connect((self.blocks_uchar_to_float_1, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_uchar_to_float_1, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_1, 1))
        self.connect((self.analog_sig_source_1, 0),
                     (self.blocks_multiply_1, 0))

        # blocks and connections for carrier for third hop frequency
        self.analog_sig_source_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq_hop_list[2] - center_freq, 1,
            0)
        self.repeat_2 = blocks.repeat(gr.sizeof_char * 1,
                                      int(samp_rate / baseband_samp_rate))
        self.blocks_uchar_to_float_2 = blocks.uchar_to_float()
        self.blocks_float_to_complex_2 = blocks.float_to_complex(1)
        self.blocks_multiply_2 = blocks.multiply_vcc(1)
        self.connect((self.blocks_vector_to_streams, 3), (self.repeat_2, 0))
        self.connect((self.repeat_2, 0), (self.blocks_uchar_to_float_2, 0))
        self.connect((self.blocks_uchar_to_float_2, 0),
                     (self.blocks_float_to_complex_2, 0))
        self.connect((self.blocks_uchar_to_float_2, 0),
                     (self.blocks_float_to_complex_2, 1))
        self.connect((self.blocks_float_to_complex_2, 0),
                     (self.blocks_multiply_2, 1))
        self.connect((self.analog_sig_source_2, 0),
                     (self.blocks_multiply_2, 0))

        # now add the three gated carrier together; the selected
        # one will pass through
        self.blocks_add = blocks.add_vcc(1)
        self.connect((self.blocks_multiply_0, 0), (self.blocks_add, 0))
        self.connect((self.blocks_multiply_1, 0), (self.blocks_add, 1))
        self.connect((self.blocks_multiply_2, 0), (self.blocks_add, 2))

        # all of the baseband data goes to the modulation chain
        self.blocks_unpacked_to_packed = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.digital_gfsk_mod = digital.gfsk_mod(
            samples_per_symbol=int(samp_rate / baseband_samp_rate),
            sensitivity=(2 * math.pi * (fsk_deviation_hz / 2)) / samp_rate,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.connect((self.blocks_vector_to_streams, 0),
                     (self.blocks_unpacked_to_packed, 0))
        self.connect((self.blocks_unpacked_to_packed, 0),
                     (self.digital_gfsk_mod, 0))

        # use the passed-through carrier to tune/modulate the gfsk output
        self.blocks_multiply_tune = blocks.multiply_vcc(1)
        self.connect((self.digital_gfsk_mod, 0),
                     (self.blocks_multiply_tune, 0))
        self.connect((self.blocks_add, 0), (self.blocks_multiply_tune, 1))

        # setup osmocom block for HackRF control
        # NEED: add control switch for USRP models
        if hardware_transmit_enable:
            if self.hw_sel == 0:
                self.osmosdr_sink = osmosdr.sink(args="numchan=" + str(1) +
                                                 " " + "")
                self.osmosdr_sink.set_sample_rate(samp_rate)
                self.osmosdr_sink.set_center_freq(center_freq, 0)
                self.osmosdr_sink.set_freq_corr(0, 0)
                self.osmosdr_sink.set_gain(hw_gain, 0)
                self.osmosdr_sink.set_if_gain(20, 0)
                self.osmosdr_sink.set_bb_gain(20, 0)
                self.osmosdr_sink.set_antenna("", 0)
                self.osmosdr_sink.set_bandwidth(0, 0)
                self.connect((self.blocks_multiply_tune, 0),
                             (self.osmosdr_sink, 0))
            elif self.hw_sel == 1:
                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(center_freq, 0)
                self.uhd_usrp_sink_0.set_gain(hw_gain, 0)
                self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
                self.connect((self.blocks_multiply_tune, 0),
                             (self.uhd_usrp_sink_0, 0))

        # this file sink provides an IQ capture of the RF
        # being transmitted by this app; the resulting file
        # is used for debugging only and should be disabled
        # under normal use
        if iq_file_out:
            self.blocks_file_sink_iq = blocks.file_sink(
                gr.sizeof_gr_complex * 1, "takeover_output_c435M_s8M.iq",
                False)
            self.blocks_file_sink_iq.set_unbuffered(False)

            self.connect((self.blocks_multiply_tune, 0),
                         (self.blocks_file_sink_iq, 0))

        # attempts to decrease latency
        #self.blocks_message_source_0.set_max_noutput_items(128)
        #self.blocks_multiply_tune.set_max_noutput_items(512)
        buffer_size = 1
        self.blocks_message_source_0.set_max_output_buffer(buffer_size)
        self.blocks_vector_to_streams.set_max_output_buffer(buffer_size)
Beispiel #46
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.fsk_deviation_hz = fsk_deviation_hz = 15e3
        self.channel_width = channel_width = fsk_deviation_hz * 1.3
        self.t_width = t_width = channel_width / 10
        self.samp_rate = samp_rate = 8e6
        self.freq2 = freq2 = 433.777e6
        self.freq1 = freq1 = 434.138e6
        self.freq0 = freq0 = 433.178e6
        self.channel_filter_taps = channel_filter_taps = firdes.low_pass(
            1, samp_rate, channel_width, t_width)
        self.center_freq = center_freq = 435e6
        self.baseband_samp_rate = baseband_samp_rate = 16e3

        ##################################################
        # Message Queues
        ##################################################
        #blocks_message_sink_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(2)
        self.blocks_message_source_0_msgq_in = gr.msg_queue()
        ##################################################
        # Blocks
        ##################################################

        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=int(samp_rate / baseband_samp_rate),
            sensitivity=(2 * math.pi * (fsk_deviation_hz / 2)) / samp_rate,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(
            gr.sizeof_char * 1, 4)
        self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 0, 1),
                                                               True, 4, [])
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_uchar_to_float_1_0_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_1_0 = blocks.uchar_to_float()
        self.blocks_uchar_to_float_1 = blocks.uchar_to_float()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_xx_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 4, self.blocks_message_source_0_msgq_in)
        #self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char * 4, blocks_message_sink_0_msgq_out, False)
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   "test.iq", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_0_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq2 - center_freq, 1, 0)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq1 - center_freq, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq0 - center_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0, 1))
        self.connect((self.blocks_float_to_complex_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 1))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_vector_to_streams_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_1, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_uchar_to_float_1, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_uchar_to_float_1, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_uchar_to_float_1_0, 0),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.blocks_uchar_to_float_1_0, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.blocks_uchar_to_float_1_0_0, 0),
                     (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.blocks_uchar_to_float_1_0_0, 0),
                     (self.blocks_float_to_complex_0_1, 1))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        #self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_message_sink_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 1),
                     (self.blocks_uchar_to_float_1, 0))
        self.connect((self.blocks_vector_to_streams_0, 2),
                     (self.blocks_uchar_to_float_1_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 3),
                     (self.blocks_uchar_to_float_1_0_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0),
                     (self.blocks_multiply_xx_0, 1))
    def __init__(self,q_rx,q_tx,noise_voltage=0.01,frequency_offset=0.01,epsilon=1.001,taps=(1+0.5j, ),):
        '''Constructor.
        
        @param q_rx:
        '''
	samp_per_sym =5
        gr.top_block.__init__(self)
        self.sink_queue = gr.msg_queue()
        #self.Add(self.wxgui_scopesink2_0_0.win)
        self.hier_rx_0 = hier_rx.hier_rx(
            bw_clock_sync=2*math.pi/5,
            bw_fll=math.pi/400,
            bits_per_sym=2,
            bw_costas=2*math.pi/100,
            n_filts=32,
            len_sym_srrc=7,
            constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(),
            samp_per_sym=samp_per_sym,
            alfa=0.35,
        )
        
        
        self.hier_tx_0 = hier_tx.hier_tx(
            alfa=0.35,
            samp_per_sym=samp_per_sym,
            bits_per_sym=2,
            constellation=[-1-1j,1-1j, 1+1j, -1+1j],
            len_sym_srrc=7,
            out_const_mul=0.4,
        )

        #self.hier_rx_0 = hier_rx()
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage,
        	frequency_offset,
        	epsilon,
        	taps,
        	noise_seed=0,
        	block_tags=False
        )
        threshold = 12              # FIXME raise exception
        access_code = packet_utils.default_access_code
        

        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, 4)
        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
        self.correlator = digital.correlate_access_code_bb( access_code, threshold)
        #"Arreglar access_code en la llamada a correlate""""""
        self.framer_sink = digital.framer_sink_1(self._rcvd_pktq)
        
        self.vsnk_src = blocks.vector_sink_b()
        self.m_sink   = blocks.message_sink(gr.sizeof_char*1, self.sink_queue,True)
        ##################################################
        # Connections
        ##################################################
        #self.connect((self.hier_tx_pencoder_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect(( self.blocks_message_source_0, 0),(self.hier_tx_0, 0) )
        self.connect((self.hier_tx_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.hier_rx_0, 0))        
        self.connect((self.hier_rx_0, 0), self.correlator, self.framer_sink)
        self._watcher = _queue_watcher_thread(self._rcvd_pktq,q_rx)
        queue = self.blocks_message_source_0.msgq()
        self.snd = SendData(q_tx,queue,samp_per_sym)   
Beispiel #48
0
    def __init__(self, dc_block_len=4, rx_gain=40):
        gr.top_block.__init__(self, "Uhd Adsb 6")

        ##################################################
        # Parameters
        ##################################################
        self.dc_block_len = dc_block_len
        self.rx_gain = rx_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2e6
        self.freq = freq = 1090e6
        self.filename = filename = "./bytes_" + str(dc_block_len) + ".csv"

        ##################################################
        # Message Queues
        ##################################################
        adsb_decoder_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(
            2)
        adsb_framer_0_msgq_out = adsb_decoder_0_msgq_in = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_auto_dc_offset("", 0)
        self.uhd_usrp_source_0.set_auto_iq_balance("", 0)
        self.digital_correlate_access_code_tag_xx_0 = digital.correlate_access_code_tag_bb(
            '1010000101000000', 0, 'adsb_preamble')
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(dc_block_len, True)
        self.blocks_message_source_0 = blocks.message_source(
            gr.sizeof_char * 1, blocks_message_source_0_msgq_in)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   filename, True)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.adsb_framer_0 = adsb.framer(tx_msgq=adsb_framer_0_msgq_out)
        self.adsb_decoder_0 = adsb.decoder(rx_msgq=adsb_decoder_0_msgq_in,
                                           tx_msgq=adsb_decoder_0_msgq_out,
                                           output_type="csv",
                                           check_parity=True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_correlate_access_code_tag_xx_0, 0))
        self.connect((self.digital_correlate_access_code_tag_xx_0, 0),
                     (self.adsb_framer_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))