示例#1
0
	def __init__(self, esno=0, samp_rate=3200000):
		gr.hier_block2.__init__(
			self, "FECTEST",
			gr.io_signature(1, 1, gr.sizeof_char*1),
			gr.io_signature(2, 2, gr.sizeof_char*1))
                
		##################################################
		# Parameters
		##################################################
		self.esno = esno
		self.samp_rate = samp_rate
		
		##################################################
		# Blocks
		##################################################
		self.gr_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
		self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
                self.char_to_float = blocks.char_to_float()
                self.float_to_char = blocks.float_to_char()
		self.gr_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate)
		self.gaussnoise_ff_0 = fec.gaussnoise_ff(esno)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_unpacked_to_packed_xx_0_0, 0), (self, 0))
		self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self, 1))
		self.connect((self.gr_throttle_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
		self.connect((self.gaussnoise_ff_0, 0), (self.float_to_char, 0))
                self.connect((self.float_to_char, 0), (self.gr_unpacked_to_packed_xx_0_0, 0))
		self.connect(self, (self.gr_throttle_0, 0))
                self.connect((self.gr_throttle_0, 0), (self.char_to_float, 0))
                self.connect((self.char_to_float, 0), (self.gaussnoise_ff_0, 0))
示例#2
0
    def __init__(self, generic_encoder=0, generic_decoder=0,
                 esno=0, berminerrors=100, samp_rate=32000,
                 berlimit=-5.0, threading="capillary", puncpat='11'):
        gr.hier_block2.__init__(
            self, "BER Generator",
            gr.io_signature(0, 0, 0),
            gr.io_signature(1, 1, gr.sizeof_float*1))

        ##################################################
        # Parameters
        ##################################################
        self.generic_encoder = generic_encoder
        self.generic_decoder = generic_decoder
        self.esno = esno
        self.berminerrors = berminerrors
        self.samp_rate = samp_rate
        self.berlimit = berlimit
        self.threading = threading
        self.puncpat = puncpat

        ##################################################
        # Blocks
        ##################################################
        self.random_gen_b_0 = fec.random_gen_b(0)
        #self.puncture_ff_0 = fec.puncture_ff(0, read_bitlist(puncpat), puncpat.count('0'), len(puncpat))
        self.gr_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
        self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
        self.gr_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate)
        #self.generic_encoder_0 = fec.encoder(generic_encoder, gr.sizeof_char, gr.sizeof_float)
        self.gaussnoise_ff_0 = fec.gaussnoise_ff(esno)

        self.encoder_interface_0 = extended_encoder_interface \
            (encoder_obj_list=generic_encoder,
             threading='capillary', puncpat=puncpat)

        self.decoder_interface_0 = extended_decoder_interface \
            (decoder_obj_list=generic_decoder,
             threading='capillary', ann=None, puncpat=puncpat,
             integration_period=10000, rotator=None)

        self.ber_bf_0_0 = fec.ber_bf(berminerrors, berlimit)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_unpacked_to_packed_xx_0_0, 0), (self.ber_bf_0_0, 0))
        self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.ber_bf_0_0, 1))
        #self.connect((self.gr_throttle_0, 0), (self.generic_encoder_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
        self.connect((self.ber_bf_0_0, 0), (self, 0))
        self.connect((self.decoder_interface_0, 0), (self.gr_unpacked_to_packed_xx_0_0, 0))
        #self.connect((self.generic_encoder_0, 0), (self.puncture_ff_0, 0))
        #self.connect((self.puncture_ff_0, 0), (self.gaussnoise_ff_0, 0))
        self.connect((self.gaussnoise_ff_0, 0), (self.decoder_interface_0, 0))
        self.connect((self.random_gen_b_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.encoder_interface_0, 0))
        self.connect((self.encoder_interface_0, 0), (self.gaussnoise_ff_0, 0))
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, "lilacsat_1_deframer",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')
        self.message_port_register_hier_out('codec2')

        if syncword_threshold is None:
            syncword_threshold = self.options.syncword_threshold

        self.delay1 = blocks.delay(gr.sizeof_float, 1)
        self.viterbi0 = ccsds_viterbi()
        self.viterbi1 = ccsds_viterbi()
        self.differential0 = digital.diff_decoder_bb(2)
        self.differential1 = digital.diff_decoder_bb(2)
        self.tag0 = digital.correlate_access_code_tag_bb(
            _syncword, syncword_threshold, 'syncword')
        self.tag1 = digital.correlate_access_code_tag_bb(
            _syncword, syncword_threshold, 'syncword')
        self.scrambler0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword')
        self.scrambler1 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword')
        self.demux0 = lilacsat1_demux('syncword')
        self.demux1 = lilacsat1_demux('syncword')
        self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.multiply_length = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, 'packet_len', 1 / 8.0)
        self.tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.pdu2tag_codec2 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.pack_codec2 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.multiply_length_codec2 = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, 'packet_len', 1 / 8.0)
        self.tag2pdu_codec2 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')

        self.connect(self, self.viterbi0, self.differential0, self.tag0,
                     self.scrambler0, self.demux0)
        self.connect(self, self.delay1, self.viterbi1, self.differential1,
                     self.tag1, self.scrambler1, self.demux1)
        self.connect(self.pdu2tag, self.pack, self.multiply_length,
                     self.tag2pdu)
        self.connect(self.pdu2tag_codec2, self.pack_codec2,
                     self.multiply_length_codec2, self.tag2pdu_codec2)
        self.msg_connect((self.demux0, 'kiss'), (self.pdu2tag, 'pdus'))
        self.msg_connect((self.demux1, 'kiss'), (self.pdu2tag, 'pdus'))
        self.msg_connect((self.demux0, 'codec2'),
                         (self.pdu2tag_codec2, 'pdus'))
        self.msg_connect((self.demux1, 'codec2'),
                         (self.pdu2tag_codec2, 'pdus'))
        self.msg_connect((self.tag2pdu, 'pdus'), (self, 'out'))
        self.msg_connect((self.tag2pdu_codec2, 'pdus'), (self, 'codec2'))
示例#4
0
    def __init__(self):
        gr.top_block.__init__(self)

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

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_samp_rate(36e6)
        self.uhd_usrp_source_0_0.set_center_freq(5.42e9, 0)
        self.uhd_usrp_source_0_0.set_gain(5, 0)
        self.uhd_usrp_source_0_0.set_antenna("J1", 0)
        self.uhd_usrp_source_0_0.set_bandwidth(36e6, 0)

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

        self.demod = digital.gfsk_demod(
            samples_per_symbol=2,
            sensitivity=1.0,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )

        self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)

        self.frame_sync = frame_sync()

        self.output_file_sink = blocks.file_sink(gr.sizeof_char * 1,
                                                 "output.txt", False)
        self.output_file_sink.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect(self.uhd_usrp_source_0_0, self.demod, self.frame_sync,
                     self.output_unpacked_to_packed, self.output_file_sink)
示例#5
0
    def __init__(self):
        gr.top_block.__init__(self)

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

        #Create Input Vector here
        input_vector = 0  # <-- Change this: *Hint: Use string_to_list.conv_string_to_1_0_list(s)

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

        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)

        self.mod = digital.dbpsk_mod(samples_per_symbol=2,
                                     excess_bw=0.35,
                                     mod_code="gray",
                                     verbose=False,
                                     log=False)

        self.demod = digital.dbpsk_demod(samples_per_symbol=2,
                                         excess_bw=0.35,
                                         freq_bw=6.28 / 100.0,
                                         phase_bw=6.28 / 100.0,
                                         timing_bw=6.28 / 100.0,
                                         mod_code="gray",
                                         verbose=False,
                                         log=False)

        self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)

        self.frame_sync = frame_sync()  # Your custom block!!!

        self.output_file_sink = blocks.file_sink(gr.sizeof_char * 1,
                                                 "output.txt", False)
        self.output_file_sink.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect(self.input_vector_source, self.input_unpacked_to_packed,
                     self.mod, self.demod, self.output_unpacked_to_packed,
                     self.frame_sync, self.output_file_sink)
示例#6
0
	def __init__(self, generic_encoder=0, generic_decoder=0, esno=0, berminerrors=100, samp_rate=32000, berlimit=-5.0, threading="capillary", puncpat='11'):
		gr.hier_block2.__init__(
			self, "BER Generator",
			gr.io_signature(0, 0, 0),
			gr.io_signature(1, 1, gr.sizeof_float*1),
		)
                
		##################################################
		# Parameters
		##################################################
		self.generic_encoder = generic_encoder
		self.generic_decoder = generic_decoder
		self.esno = esno
		self.berminerrors = berminerrors
		self.samp_rate = samp_rate
		self.berlimit = berlimit
		self.threading = threading
		self.puncpat = puncpat

		##################################################
		# Blocks
		##################################################
		self.random_gen_b_0 = fec.random_gen_b(0)
		#self.puncture_ff_0 = fec.puncture_ff(0, read_bitlist(puncpat), puncpat.count('0'), len(puncpat))
		self.gr_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
		self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
		self.gr_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate)
		#self.generic_encoder_0 = fec.encoder(generic_encoder, gr.sizeof_char, gr.sizeof_float)
                self.encoder_interface_0 = extended_encoder_interface(encoder_obj_list=generic_encoder, threading='capillary', puncpat=puncpat);
		self.gaussnoise_ff_0 = fec.gaussnoise_ff(esno)
		self.decoder_interface_0 = extended_decoder_interface(decoder_obj_list=generic_decoder, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000, rotator=None)
		self.ber_bb_0_0 = fec.ber_bb(berminerrors, berlimit)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_unpacked_to_packed_xx_0_0, 0), (self.ber_bb_0_0, 0))
		self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.ber_bb_0_0, 1))
		#self.connect((self.gr_throttle_0, 0), (self.generic_encoder_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
		self.connect((self.ber_bb_0_0, 0), (self, 0))
		self.connect((self.decoder_interface_0, 0), (self.gr_unpacked_to_packed_xx_0_0, 0))
		#self.connect((self.generic_encoder_0, 0), (self.puncture_ff_0, 0))
		#self.connect((self.puncture_ff_0, 0), (self.gaussnoise_ff_0, 0))
		self.connect((self.gaussnoise_ff_0, 0), (self.decoder_interface_0, 0))
		self.connect((self.random_gen_b_0, 0), (self.gr_throttle_0, 0))
                self.connect((self.gr_throttle_0, 0), (self.encoder_interface_0, 0))
                self.connect((self.encoder_interface_0, 0), (self.gaussnoise_ff_0, 0))
示例#7
0
    def __init__(self):
        gr.top_block.__init__(self)

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

        s = "Hello Ether!" 
        #Create Input Vector here
        input_vector = string_to_list.conv_string_to_1_0_list(s)  # <-- Change this: *Hint: Use string_to_list.conv_string_to_1_0_list(s)

        ##################################################
        # Blocks
        ##################################################
        
        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)

        self.mod = digital.dbpsk_mod(
            samples_per_symbol=2,
            excess_bw=0.35,
            mod_code="gray",
            verbose=False,
            log=False)
            
        self.demod = digital.dbpsk_demod(
            samples_per_symbol=2,
            excess_bw=0.35,
            freq_bw=6.28/100.0,
            phase_bw=6.28/100.0,
            timing_bw=6.28/100.0,
            mod_code="gray",
            verbose=False,
            log=False
        )        
        
        self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

        self.frame_sync = frame_sync() # Your custom block!!!

        self.output_file_sink = blocks.file_sink(gr.sizeof_char*1, "output.txt", False)
        self.output_file_sink.set_unbuffered(True)
        
        ##################################################
        # Connections
        ##################################################
        self.connect(self.input_vector_source, self.input_unpacked_to_packed, self.mod, self.demod, self.output_unpacked_to_packed, self.frame_sync, self.output_file_sink)
示例#8
0
    def __init__(self, constellation, differential, rotation):
        if constellation.arity() > 256:
            # If this becomes limiting some of the blocks should be generalised so
            # that they can work with shorts and ints as well as chars.
            raise ValueError("Constellation cannot contain more than 256 points.")

        gr.hier_block2.__init__(
            self,
            "mod_demod",
            gr.io_signature(1, 1, gr.sizeof_char),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_char),
        )  # Output signature

        arity = constellation.arity()

        # TX
        self.constellation = constellation
        self.differential = differential
        import weakref

        self.blocks = [weakref.proxy(self)]
        # We expect a stream of unpacked bits.
        # First step is to pack them.
        self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
        # Second step we unpack them such that we have k bits in each byte where
        # each constellation symbol hold k bits.
        self.blocks.append(blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(), gr.GR_MSB_FIRST))
        # Apply any pre-differential coding
        # Gray-coding is done here if we're also using differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(self.constellation.pre_diff_code()))
        # Differential encoding.
        if self.differential:
            self.blocks.append(digital.diff_encoder_bb(arity))
        # Convert to constellation symbols.
        self.blocks.append(
            digital.chunks_to_symbols_bc(self.constellation.points(), self.constellation.dimensionality())
        )
        # CHANNEL
        # Channel just consists of a rotation to check differential coding.
        if rotation is not None:
            self.blocks.append(blocks.multiply_const_cc(rotation))

        # RX
        # Convert the constellation symbols back to binary values.
        self.blocks.append(digital.constellation_decoder_cb(self.constellation.base()))
        # Differential decoding.
        if self.differential:
            self.blocks.append(digital.diff_decoder_bb(arity))
        # Decode any pre-differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(mod_codes.invert_code(self.constellation.pre_diff_code())))
        # unpack the k bit vector into a stream of bits
        self.blocks.append(blocks.unpack_k_bits_bb(self.constellation.bits_per_symbol()))
        # connect to block output
        check_index = len(self.blocks)
        self.blocks = self.blocks[:check_index]
        self.blocks.append(weakref.proxy(self))

        self.connect(*self.blocks)
示例#9
0
    def setup_bpsk0(self):
        self.tb = gr.top_block()

        # Build the constellation object
        arity = 2
        bps = 1
        pts, code = digital.psk_2_0x0()
        constellation = digital.constellation_psk(pts, code, 2)

        # Create BPSK data to pass to the demodulator
        src = blocks.vector_source_b(self.src_data_bpsk)
        p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        mod = digital.generic_mod(constellation, True, self.sps, True, self.eb)
        snk = blocks.vector_sink_c()

        tb = gr.top_block()
        tb.connect(src, p2u, mod, snk)
        tb.run()

        self.src = blocks.vector_source_c(snk.data())
        self.freq_recov = digital.fll_band_edge_cc(self.sps, self.eb,
                                                   self.fll_ntaps, self.freq_bw)
        self.time_recov = digital.pfb_clock_sync_ccf(self.sps, self.timing_bw, self.taps,
                                                     self.nfilts, self.nfilts//2, self.timing_max_dev)
        self.receiver = digital.constellation_receiver_cb(
            constellation.base(), self.phase_bw, self.fmin, self.fmax)
        self.diffdec = digital.diff_decoder_bb(arity)
        self.symbol_mapper = digital.map_bb(
            mod_codes.invert_code(constellation.pre_diff_code()))
        self.unpack = blocks.unpack_k_bits_bb(bps)
        self.snk = blocks.null_sink(gr.sizeof_char)

        self.tb.connect(self.src, self.freq_recov, self.time_recov, self.receiver)
        self.tb.connect(self.receiver, self.diffdec, self.symbol_mapper, self.unpack)
        self.tb.connect(self.unpack, self.snk)
示例#10
0
 def __init__(self, constellation, differential,
              data_length=None, src_data=None, freq_offset=True):
     """
     Args:
         constellation: a constellation object
         differential: whether differential encoding is used
         data_length: the number of bits of data to use
         src_data: a list of the bits to use
         freq_offset: whether to use a frequency offset in the channel
     """
     super(rec_test_tb, self).__init__()
     # Transmission Blocks
     if src_data is None:
         self.src_data = tuple([random.randint(0,1) for i in range(0, data_length)])
     else:
         self.src_data = src_data
     packer = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
     src = blocks.vector_source_b(self.src_data)
     mod = generic_mod(constellation, differential=differential)
     # Channel
     if freq_offset:
         channel = channel_model(NOISE_VOLTAGE, FREQUENCY_OFFSET, TIMING_OFFSET)
     else:
         channel = channel_model(NOISE_VOLTAGE, 0, TIMING_OFFSET)
     # Receiver Blocks
     if freq_offset:
         demod = generic_demod(constellation, differential=differential,
                               freq_bw=FREQ_BW,
                               phase_bw=PHASE_BW)
     else:
         demod = generic_demod(constellation, differential=differential,
                               freq_bw=0, phase_bw=0)
     self.dst = blocks.vector_sink_b()
     self.connect(src, packer, mod, channel, demod, self.dst)
示例#11
0
    def __init__(self, sample_rate, amplitude):
        gr.hier_block2.__init__(
            self,
            "gsm_source_c",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))  # Output signature

        self._symb_rate = 13e6 / 48
        self._samples_per_symbol = 2

        self._data = blocks.vector_source_b(self.gen_gsm_seq(), True, 2)
        self._split = blocks.vector_to_streams(gr.sizeof_char * 1, 2)

        self._pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self._mod = digital.gmsk_mod(self._samples_per_symbol, bt=0.35)

        self._pwr_f = blocks.char_to_float(1, 1)
        self._pwr_c = blocks.float_to_complex(1)
        self._pwr_w = blocks.repeat(gr.sizeof_gr_complex * 1,
                                    self._samples_per_symbol)

        self._mul = blocks.multiply_vcc(1)
        self._interpolate = filter.fractional_resampler_cc(
            0, (self._symb_rate * self._samples_per_symbol) / sample_rate)
        self._scale = blocks.multiply_const_cc(amplitude)

        self.connect(self._data, self._split)
        self.connect((self._split, 0), self._pack, self._mod, (self._mul, 0))
        self.connect((self._split, 1), self._pwr_f, self._pwr_c, self._pwr_w,
                     (self._mul, 1))
        self.connect(self._mul, self._interpolate, self._scale, self)
示例#12
0
    def __init__(self, sample_rate, amplitude):
        gr.hier_block2.__init__(self, "gsm_source_c",
            gr.io_signature(0, 0, 0), # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        self._symb_rate = 13e6 / 48;
        self._samples_per_symbol = 2

        self._data  = blocks.vector_source_b(self.gen_gsm_seq(), True, 2)
        self._split = blocks.vector_to_streams(gr.sizeof_char*1, 2)

        self._pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self._mod  = digital.gmsk_mod(self._samples_per_symbol, bt=0.35)

        self._pwr_f = blocks.char_to_float(1, 1)
        self._pwr_c = blocks.float_to_complex(1)
        self._pwr_w = blocks.repeat(gr.sizeof_gr_complex*1, self._samples_per_symbol)

        self._mul = blocks.multiply_vcc(1)
        self._interpolate = filter.fractional_resampler_cc( 0,
            (self._symb_rate * self._samples_per_symbol) / sample_rate )
        self._scale = blocks.multiply_const_cc(amplitude)

        self.connect(self._data, self._split)
        self.connect((self._split, 0), self._pack, self._mod, (self._mul, 0))
        self.connect((self._split, 1), self._pwr_f, self._pwr_c, self._pwr_w, (self._mul, 1))
        self.connect(self._mul, self._interpolate, self._scale, self)
示例#13
0
 def test_001_t(self):
     energy_dispersal_undone = (0x05, 0x00, 0x10, 0xea, 0x04, 0x24, 0x06,
                                0x02, 0xd3, 0xa6, 0x01, 0x3f, 0x06, 0xff,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00, 0x00, 0x4c, 0x89)
     energy_dispersal_done = (0x02, 0xBE, 0x3E, 0x8E, 0x16, 0xB9, 0xA5,
                              0xCD, 0x48, 0xB3, 0x22, 0xB2, 0xAD, 0x76,
                              0x88, 0x80, 0x42, 0x30, 0x9C, 0xAB, 0x0D,
                              0xE9, 0xB9, 0x14, 0x2B, 0x4F, 0xD9, 0x25,
                              0xBF, 0x26, 0xEA, 0xE9)
     fib_packed_to_unpacked = blocks.packed_to_unpacked_bb(
         1, gr.GR_MSB_FIRST)
     fib_unpacked_to_packed = blocks.unpacked_to_packed_bb(
         1, gr.GR_MSB_FIRST)
     src = blocks.vector_source_b(energy_dispersal_undone)
     self.dp = grdab.parameters.dab_parameters(1, 2e6, False)
     prbs_src = blocks.vector_source_b(
         self.dp.prbs(self.dp.energy_dispersal_fic_vector_length), True)
     add_mod_2 = blocks.xor_bb()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, fib_packed_to_unpacked, add_mod_2,
                     fib_unpacked_to_packed, dst)
     self.tb.connect(prbs_src, (add_mod_2, 1))
     self.tb.run()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(energy_dispersal_done, result_data,
                                       6)
示例#14
0
    def __init__(self, constellation, samples_per_symbol, differential,
                 excess_bw, gray_coded, verbose, log):

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

        # Create BERT data bit stream
        self._bits = blocks.vector_source_b([
            1,
        ], True)  # Infinite stream of ones
        self._scrambler = digital.scrambler_bb(0x8A, 0x7F,
                                               7)  # CCSDS 7-bit scrambler

        self._mod = digital.generic_mod(constellation, differential,
                                        samples_per_symbol, gray_coded,
                                        excess_bw, verbose, log)

        self._pack = blocks.unpacked_to_packed_bb(self._mod.bits_per_symbol(),
                                                  gr.GR_MSB_FIRST)

        self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
示例#15
0
	def __init__(self):
		gr.top_block.__init__(self, "Wmbus Phy2")

		##################################################
		# Variables
		##################################################
		self.frame = frame = [1,1]

		##################################################
		# Blocks
		##################################################
		self.gr_vector_source_x_0 = blocks.vector_source_b((frame), False, 1)
		self.gr_vector_sink_x_1 = blocks.vector_sink_b(1)
		self.gr_vector_sink_x_0 = blocks.vector_sink_b(1)
		self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(4, gr.GR_MSB_FIRST)
		self.gr_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(6)
		self.digital_map_bb_1 = digital.map_bb(([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]))
		self.digital_map_bb_0 = digital.map_bb(([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 16, 1, 2, 16, 16, 16, 16, 7, 16, 16, 0, 16, 16, 5, 6, 16, 4, 16, 16, 16, 16, 16, 16, 11, 16, 9, 10, 16, 16, 15, 16, 16, 8, 16, 16, 16, 16, 13, 14, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]))

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_vector_source_x_0, 0), (self.gr_pack_k_bits_bb_0, 0))
		self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_map_bb_0, 0))
		self.connect((self.digital_map_bb_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
		self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.gr_vector_sink_x_0, 0))
		self.connect((self.digital_map_bb_0, 0), (self.digital_map_bb_1, 0))
		self.connect((self.digital_map_bb_1, 0), (self.gr_vector_sink_x_1, 0))
示例#16
0
    def setup_bpsk0(self):
        self.tb = gr.top_block()

        # Build the constellation object
        arity = 2
        bps = 1
        pts, code = digital.psk_2_0x0()
        constellation = digital.constellation_psk(pts, code, 2)

        # Create BPSK data to pass to the demodulator
        src = blocks.vector_source_b(self.src_data_bpsk)
        p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        mod = digital.generic_mod(constellation, True, self.sps, True, self.eb)
        snk = blocks.vector_sink_c()

        tb = gr.top_block()
        tb.connect(src, p2u, mod, snk)
        tb.run()

        self.src = blocks.vector_source_c(snk.data())
        self.freq_recov = digital.fll_band_edge_cc(self.sps, self.eb,
                                                   self.fll_ntaps, self.freq_bw)
        self.time_recov = digital.pfb_clock_sync_ccf(self.sps, self.timing_bw, self.taps,
                                                     self.nfilts, self.nfilts//2, self.timing_max_dev)
        self.receiver = digital.constellation_receiver_cb(
            constellation.base(), self.phase_bw, self.fmin, self.fmax)
        self.diffdec = digital.diff_decoder_bb(arity)
        self.symbol_mapper = digital.map_bb(
            mod_codes.invert_code(constellation.pre_diff_code()))
        self.unpack = blocks.unpack_k_bits_bb(bps)
        self.snk = blocks.null_sink(gr.sizeof_char)

        self.tb.connect(self.src, self.freq_recov, self.time_recov, self.receiver)
        self.tb.connect(self.receiver, self.diffdec, self.symbol_mapper, self.unpack)
        self.tb.connect(self.unpack, self.snk)
示例#17
0
    def __init__(self):
        gr.top_block.__init__(self)

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

        #Create Input Vector here
        barker13 = [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0]
        msg = string_to_list.conv_string_to_1_0_list("Hello World\n")
        pad = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        pad = pad + pad + pad + pad + pad
        input_vector = barker13+msg+pad  # <-- Change this: *Hint: Use string_to_list.conv_string_to_1_0_list(s)

        #print(input_vector)
        ##################################################
        # Blocks
        ##################################################
	
	#USRP        
	#Variables
        self.samp_rate = samp_rate = 390625.0
        self.sink_args = args = "type=b200"
        #self.address = address = "addr=192.168.10.2" # real men hard-code parameters!
        self.freq = freq= 1425000000
        self.freq_offset = freq_offset= 0
        self.gain = gain= 13
        print "Sample Rate:", samp_rate
        print "Freq:", freq

	#Init
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join((args, "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(gain+70.5, 0)

        ##################################################

        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)

        self.mod = digital.dbpsk_mod(
            samples_per_symbol=2,
            excess_bw=0.35,
            mod_code="gray",
            verbose=False,
            log=False)
           
        
        ##################################################
        # Connections
        ##################################################
        self.connect(self.input_vector_source, self.input_unpacked_to_packed, self.mod, self.uhd_usrp_sink_0)
 def __init__(self):
     gr.hier_block2.__init__(self, "transmitter_gfsk",
                             gr.io_signature(1, 1, gr.sizeof_char),
                             gr.io_signature(1, 1, gr.sizeof_gr_complex))
     self.repack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
     self.mod = digital.gfsk_mod(sps, sensitivity=0.1, bt=ebw)
     self.connect(self, self.repack, self.mod, self)
    def __init__(self, constellation, differential, rotation):
        if constellation.arity() > 256:
            # If this becomes limiting some of the blocks should be generalised so
            # that they can work with shorts and ints as well as chars.
            raise ValueError("Constellation cannot contain more than 256 points.")

        gr.hier_block2.__init__(self, "mod_demod",
                                gr.io_signature(1, 1, gr.sizeof_char),       # Input signature
                                gr.io_signature(1, 1, gr.sizeof_char))       # Output signature

        arity = constellation.arity()

        # TX
        self.constellation = constellation
        self.differential = differential
        import weakref
        self.blocks = [weakref.proxy(self)]
        # We expect a stream of unpacked bits.
        # First step is to pack them.
        self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
        # Second step we unpack them such that we have k bits in each byte where
        # each constellation symbol hold k bits.
        self.blocks.append(
            blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(),
                                         gr.GR_MSB_FIRST))
        # Apply any pre-differential coding
        # Gray-coding is done here if we're also using differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(self.constellation.pre_diff_code()))
        # Differential encoding.
        if self.differential:
            self.blocks.append(digital.diff_encoder_bb(arity))
        # Convert to constellation symbols.
        self.blocks.append(digital.chunks_to_symbols_bc(self.constellation.points(),
                                                        self.constellation.dimensionality()))
        # CHANNEL
        # Channel just consists of a rotation to check differential coding.
        if rotation is not None:
            self.blocks.append(blocks.multiply_const_cc(rotation))

        # RX
        # Convert the constellation symbols back to binary values.
        self.blocks.append(digital.constellation_decoder_cb(self.constellation.base()))
        # Differential decoding.
        if self.differential:
            self.blocks.append(digital.diff_decoder_bb(arity))
        # Decode any pre-differential coding.
        if self.constellation.apply_pre_diff_code():
            self.blocks.append(digital.map_bb(
                mod_codes.invert_code(self.constellation.pre_diff_code())))
        # unpack the k bit vector into a stream of bits
        self.blocks.append(blocks.unpack_k_bits_bb(
                self.constellation.bits_per_symbol()))
        # connect to block output
        check_index = len(self.blocks)
        self.blocks = self.blocks[:check_index]
        self.blocks.append(weakref.proxy(self))

        self.connect(*self.blocks)
示例#20
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sigma = sigma = 0.3
        self.samp_rate = samp_rate = 32000
        self.max_iterations = max_iterations = 50

        ##################################################
        # Blocks
        ##################################################
        self.ldpc_lh_detector_fb_0 = ldpc.lh_detector_fb()
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            ([1.0, -1.0]), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, "/home/manu/Downloads/in.flac", False)
        self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/home/manu/val")
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/home/manu/ref")
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/home/manu/out")
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(
            analog.GR_GAUSSIAN, sigma, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.ldpc_lh_detector_fb_0, 0))
        self.connect((self.ldpc_lh_detector_fb_0, 0),
                     (self.blocks_file_sink_2, 0))
        self.connect((self.ldpc_lh_detector_fb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
示例#21
0
 def test_001_t(self):
     src = dab.fib_source_b_make(1,1,7,'Galaxy_News', 'Wasteland_Radio1Wasteland_Radio2Wasteland_Radio3Wasteland_Radio4Wasteland_Radio5Wasteland_Radio6Wasteland_Radio7', 'Country_Mix', 0x09, [0, 1, 2, 3, 3, 2, 1], [8, 2, 8, 8, 2, 1, 4], [1, 1, 0, 1, 1, 0, 1])
     fib_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
     s2v = blocks.stream_to_vector(gr.sizeof_char, 32)
     crc16 = dab.crc16_bb(32, 0x1021, 0xffff)
     fibsink = dab.fib_sink_vb()
     self.tb.connect(src, fib_unpacked_to_packed, blocks.head(gr.sizeof_char, 3000), s2v, crc16, fibsink)
     self.tb.run()
     pass
示例#22
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Example1")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sigma = sigma = 0.5
        self.samp_rate = samp_rate = 32000
        self.max_iterations = max_iterations = 50
        self.alist_file = alist_file = "/home/manu/repos/ldpc/gr-ldpc/python/alist-files"

        ##################################################
        # Blocks
        ##################################################
        self.ldpc_ldpc_hier_encoder_bb_0 = ldpc.ldpc_hier_encoder_bb(
            "/home/manu/1920.1280.3.303/H1920.1280.3.303")
        self.ldpc_ldpc_hier_decoder_fb_0 = ldpc.ldpc_hier_decoder_fb(
            "/home/manu/1920.1280.3.303/H1920.1280.3.303", sigma,
            max_iterations)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            ([1.0, -1.0]), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            "/home/manu/Downloads/06 - Coming Back To Life.flac", False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/home/manu/Downloads/out",
                                                   False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(
            analog.GR_GAUSSIAN, sigma, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.ldpc_ldpc_hier_decoder_fb_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.ldpc_ldpc_hier_encoder_bb_0, 0))
        self.connect((self.ldpc_ldpc_hier_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.ldpc_ldpc_hier_decoder_fb_0, 0))
示例#23
0
    def __init__(self):
        gr.top_block.__init__(self, "Virtualtransmissiontest")

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

        ##################################################
        # Blocks
        ##################################################
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
            samples_per_symbol=2,
            sensitivity=1.0,
            bt=0.35,
            verbose=False,
            log=False,
        )
        self.digital_gfsk_demod_0 = digital.gfsk_demod(
            samples_per_symbol=2,
            sensitivity=1.0,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            4, gr.GR_MSB_FIRST)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            4, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/thomas/Documents/esft/packet', False)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/thomas/Documents/esft/transmittedpacket', False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_gfsk_demod_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.digital_gfsk_mod_0, 0))
        self.connect((self.digital_gfsk_demod_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_throttle_0, 0))
示例#24
0
    def setup_8psk0(self):
        self.tb = gr.top_block()

        constellation = digital.psk_constellation(8)

        self.src = blocks.vector_source_b(self.src_data_8psk)
        self.p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.mod = digital.generic_mod(constellation, True, self.sps, True, self.eb)
        self.snk = blocks.null_sink(gr.sizeof_gr_complex)

        self.tb.connect(self.src, self.p2u, self.mod, self.snk)
示例#25
0
    def setup_8psk0(self):
        self.tb = gr.top_block()

        constellation = digital.psk_constellation(8)

        self.src = blocks.vector_source_b(self.src_data_8psk)
        self.p2u = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.mod = digital.generic_mod(constellation, True, self.sps, True, self.eb)
        self.snk = blocks.null_sink(gr.sizeof_gr_complex)

        self.tb.connect(self.src, self.p2u, self.mod, self.snk)
    def test_006(self):
        src_data = (0,1,0,0,0,0,0,1,0,1,0,1,1,0,1,0)
        expected_results = (0x82, 0x5a)
        src = blocks.vector_source_b(src_data, False)
        op = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
        dst = blocks.vector_sink_b()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        self.assertEqual(expected_results, dst.data())
示例#27
0
    def test_005(self):
        src_data = (1,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0)
        expected_results = (0x82, 0x5a)
        src = blocks.vector_source_b(src_data, False)
        op = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        dst = blocks.vector_sink_b()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        self.assertEqual(expected_results, dst.data())
示例#28
0
    def test_008(self):
        src_data = [0, 4, 2, 0, 0]
        expected_results = [
            0x11,
        ]
        src = blocks.vector_source_b(src_data, False)
        op = blocks.unpacked_to_packed_bb(3, gr.GR_MSB_FIRST)
        dst = blocks.vector_sink_b()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()

        self.assertEqual(expected_results, dst.data())
示例#29
0
    def test_convolutional_encoder(self):
        """
        Tests convolutional encoder
        """
        src_data = make_transport_stream()
        constellation = [.7, .7,.7,-.7,-.7,.7,-.7,-.7]

        src = blocks.vector_source_b(src_data)
        unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        enc = dvb_convolutional_encoder_bb.convolutional_encoder_bb()
        repack1 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        repack2 = blocks.packed_to_unpacked_bb(2, gr.GR_MSB_FIRST)
        mapper = digital.chunks_to_symbols_bf(constellation, dvb.dimensionality)
        viterbi = trellis.viterbi_combined_fb(trellis.fsm(dvb.k, dvb.n, dvb_convolutional_encoder_bb.G),
                dvb.K, -1, -1, dvb.dimensionality, constellation, trellis.TRELLIS_EUCLIDEAN)
        pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        dst = blocks.vector_sink_b()

        self.tb.connect(src, unpack, enc, repack1, repack2, mapper)
        self.tb.connect(mapper, viterbi, pack, dst)
        self.tb.run()
        result_data = dst.data()
        self.assertEqual(tuple(src_data[:len(result_data)]), result_data)
示例#30
0
    def __init__(self, rx_callback, tx_status, rx_status):
        gr.hier_block2.__init__(self, "receive_path",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(0, 0, 0))

        ##################################################
        # Variables
        ##################################################
        self.callback = rx_callback

        ##################################################
        # Blocks
        ##################################################
        self.demod = digital.gfsk_demod(
        	samples_per_symbol=4,
        	sensitivity=1.0,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.frame_sync = frame_sync(tx_status, rx_status) # Your custom block!!!

        self.output_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)

        self.rcvd_pktq = gr.msg_queue()
        self.message_sink = blocks.message_sink(gr.sizeof_char, self.rcvd_pktq, True)

        self.queue_watcher_thread = _queue_watcher_thread(self.rcvd_pktq, self.callback)

        self.blocks_max = blocks.max_ff(1,1)

        #Don't Search if nothing is transmitting
        self.blocks_threshold_ff_0 = blocks.threshold_ff(0.00002, 0.00002, 0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(-80, 0.55)
        ##################################################
        # Connections
        ##################################################
        #main path
        self.connect(self, self.demod, (self.frame_sync, 0))
        self.connect(self.frame_sync, self.output_unpacked_to_packed, self.message_sink)

        #squelch path
        self.connect(self, (self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_max, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.frame_sync, 1))
示例#31
0
    def __init__(self,
                 packlen=0,
                 sync='00011010110011111111110000011101',
                 threshold=4):
        gr.hier_block2.__init__(
            self,
            'Sync and create packed PDU',
            gr.io_signature(1, 1, gr.sizeof_char * 1),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_out('out')

        ##################################################
        # Parameters
        ##################################################
        self.packlen = packlen
        self.sync = sync
        self.threshold = threshold

        ##################################################
        # Blocks
        ##################################################
        self.satellites_fixedlen_tagger_0_0_0 = (satellites.fixedlen_tagger(
            'syncword', 'packet_len', packlen * 8, numpy.byte))
        self.digital_correlate_access_code_tag_bb_0_0_0 = (
            digital.correlate_access_code_tag_bb(sync, threshold, 'syncword'))
        self.blocks_unpacked_to_packed_xx_0 = (blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST))
        self.blocks_tagged_stream_to_pdu_0_0_0 = (tagged_stream_to_pdu(
            byte_t, 'packet_len'))
        self.blocks_tagged_stream_multiply_length_0 = (
            blocks.tagged_stream_multiply_length(gr.sizeof_char * 1,
                                                 'packet_len', 1 / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'),
                         (self, 'out'))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0_0_0, 0),
                     (self.satellites_fixedlen_tagger_0_0_0, 0))
        self.connect((self, 0),
                     (self.digital_correlate_access_code_tag_bb_0_0_0, 0))
        self.connect((self.satellites_fixedlen_tagger_0_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
示例#32
0
 def test_001_t (self):
     energy_dispersal_undone = (0x05, 0x00, 0x10, 0xea, 0x04, 0x24, 0x06, 0x02, 0xd3, 0xa6, 0x01, 0x3f, 0x06, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x89)
     energy_dispersal_done = (0x02, 0xBE, 0x3E, 0x8E, 0x16, 0xB9, 0xA5, 0xCD, 0x48, 0xB3, 0x22, 0xB2, 0xAD, 0x76, 0x88, 0x80, 0x42, 0x30, 0x9C, 0xAB, 0x0D, 0xE9, 0xB9, 0x14, 0x2B, 0x4F, 0xD9, 0x25, 0xBF, 0x26, 0xEA, 0xE9)
     fib_packed_to_unpacked = blocks.packed_to_unpacked_bb(1,gr.GR_MSB_FIRST)
     fib_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
     src = blocks.vector_source_b(energy_dispersal_undone)
     self.dp = grdab.parameters.dab_parameters(1, 2e6, False)
     prbs_src = blocks.vector_source_b(self.dp.prbs(self.dp.energy_dispersal_fic_vector_length), True)
     add_mod_2 = blocks.xor_bb()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, fib_packed_to_unpacked, add_mod_2, fib_unpacked_to_packed, dst)
     self.tb.connect(prbs_src, (add_mod_2, 1))
     self.tb.run ()
     result_data = dst.data()
     self.assertFloatTuplesAlmostEqual(energy_dispersal_done, result_data, 6)
示例#33
0
    def __init__(self, fname, sigma, max_iterations):
        gr.top_block.__init__(self)

        encoder = ldpc.ldpc_hier_encoder_bf(fname)
        decoder = ldpc.ldpc_hier_decoder_fb(fname, sigma, max_iterations)

        unpack2pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        pack2unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)

        inFile = "/home/manu/Downloads/in.flac"
        outFile = "/home/manu/Downloads/out.flac"
        source = blocks.file_source(1, inFile, False)
        sink = blocks.file_sink(1, outFile)

        self.connect(source, pack2unpack, encoder, decoder, unpack2pack, sink)
示例#34
0
    def __init__(self, fname, sigma, max_iterations):
        gr.top_block.__init__(self)
        
        encoder = ldpc.ldpc_hier_encoder_bf(fname)
        decoder = ldpc.ldpc_hier_decoder_fb(fname,
                sigma, max_iterations)

        unpack2pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        pack2unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)

        inFile = "/home/tjt7a/src/gr-ldpc/apps/inputs/BonkEnc_test15_level8_5s_VBR_280kbps_Mono_32000Hz_16bit.flac"
        outFile = "/home/tjt7a/src/gr-ldpc/apps/inputs/out.flac"
        source = blocks.file_source(1, inFile, False)
        sink = blocks.file_sink(1, outFile)

        self.connect(source, pack2unpack, encoder, decoder, unpack2pack, sink)
示例#35
0
    def __init__(self, fname, epsilon, max_iterations):
        gr.top_block.__init__(self)

        self.src = blocks.vector_source_b(())
#        self.encoder = ldpc.ldpc_encoder_bf(fname)
#        self.decoder = ldpc.ldpc_decoder_fb(fname, epsilon, max_iterations)
#        self.encoder = ldpc.ldpc_encoder_bb(fname)
#        self.decoder = ldpc.ldpc_decoder_bb(fname, epsilon, max_iterations)
#        self.K = self.encoder.get_K()
#        self.N = self.encoder.get_N()
        self.K = 100
        self.N = 100
        print self.K
        print self.N
        copy = ldpc.copy_bb(self.K)
        self.dst = blocks.vector_sink_b()
        fsink1 = blocks.file_sink(gr.sizeof_char*self.K, "in")
        fsink1.set_unbuffered(False)
        fsink2 = blocks.file_sink(gr.sizeof_char*self.K, "out")
        fsink2.set_unbuffered(False)
#        fsink3 = blocks.file_sink(gr.sizeof_float*1, "encout")
#        fsink3.set_unbuffered(False)
        fsink3 = blocks.file_sink(gr.sizeof_char*self.N, "encout")
        fsink3.set_unbuffered(False)

        inFile = "/home/manu/Downloads/in.flac"
        outFile = "/home/manu/out.flac"
        source = blocks.file_source(gr.sizeof_char*self.K, inFile, False)
        sink = blocks.file_sink(gr.sizeof_char*self.K, outFile)
        unpack2pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        pack2unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        rsource= blocks.vector_source_b(map(int, np.random.randint(0x00, 0x02, 1000)), True)


#        str2Kvec = blocks.stream_to_vector(1, self.K)
#        str2Nvec = blocks.stream_to_vector(4, self.N)
#        Kvec2str = blocks.vector_to_stream(1, self.K)
#        Nvec2str = blocks.vector_to_stream(4, self.N)
        str2Kvec = blocks.stream_to_vector(1, self.K)
        str2Nvec = blocks.stream_to_vector(1, self.N)
        Kvec2str = blocks.vector_to_stream(1, self.K)
        Nvec2str = blocks.vector_to_stream(1, self.N)

        self.noise = analog.noise_source_f(analog.GR_GAUSSIAN, epsilon, 0)
        self.adder = blocks.add_vff(1)

        self.connect(source, copy, sink)
示例#36
0
    def __init__(self, fname, epsilon, max_iterations):
        gr.top_block.__init__(self)

        self.src = blocks.vector_source_b(())
        #        self.encoder = ldpc.ldpc_encoder_bf(fname)
        #        self.decoder = ldpc.ldpc_decoder_fb(fname, epsilon, max_iterations)
        #        self.encoder = ldpc.ldpc_encoder_bb(fname)
        #        self.decoder = ldpc.ldpc_decoder_bb(fname, epsilon, max_iterations)
        #        self.K = self.encoder.get_K()
        #        self.N = self.encoder.get_N()
        self.K = 100
        self.N = 100
        print self.K
        print self.N
        copy = ldpc.copy_bb(self.K)
        self.dst = blocks.vector_sink_b()
        fsink1 = blocks.file_sink(gr.sizeof_char * self.K, "in")
        fsink1.set_unbuffered(False)
        fsink2 = blocks.file_sink(gr.sizeof_char * self.K, "out")
        fsink2.set_unbuffered(False)
        #        fsink3 = blocks.file_sink(gr.sizeof_float*1, "encout")
        #        fsink3.set_unbuffered(False)
        fsink3 = blocks.file_sink(gr.sizeof_char * self.N, "encout")
        fsink3.set_unbuffered(False)

        inFile = "/home/manu/Downloads/in.flac"
        outFile = "/home/manu/out.flac"
        source = blocks.file_source(gr.sizeof_char * self.K, inFile, False)
        sink = blocks.file_sink(gr.sizeof_char * self.K, outFile)
        unpack2pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        pack2unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        rsource = blocks.vector_source_b(
            map(int, np.random.randint(0x00, 0x02, 1000)), True)

        #        str2Kvec = blocks.stream_to_vector(1, self.K)
        #        str2Nvec = blocks.stream_to_vector(4, self.N)
        #        Kvec2str = blocks.vector_to_stream(1, self.K)
        #        Nvec2str = blocks.vector_to_stream(4, self.N)
        str2Kvec = blocks.stream_to_vector(1, self.K)
        str2Nvec = blocks.stream_to_vector(1, self.N)
        Kvec2str = blocks.vector_to_stream(1, self.K)
        Nvec2str = blocks.vector_to_stream(1, self.N)

        self.noise = analog.noise_source_f(analog.GR_GAUSSIAN, epsilon, 0)
        self.adder = blocks.add_vff(1)

        self.connect(source, copy, sink)
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            'CCSDS descrambler',
            gr.io_signature(0, 0, 0),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_in("in")
        self.message_port_register_hier_out("out")

        ##################################################
        # Blocks
        ##################################################
        self.digital_additive_scrambler_bb_0_0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1,
            reset_tag_key="packet_len")
        self.blocks_unpacked_to_packed_xx_0_0_0_0 = (
            blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
        self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = (
            blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len'))
        self.blocks_tagged_stream_multiply_length_0_0_0_0 = (
            blocks.tagged_stream_multiply_length(
                gr.sizeof_char*1, 'packet_len', 1/8.0))
        self.blocks_pdu_to_tagged_stream_0 = (
            blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len'))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'),
            (self, 'out'))
        self.msg_connect(
            (self, 'in'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect(
            (self.blocks_pdu_to_tagged_stream_0, 0),
            (self.digital_additive_scrambler_bb_0_0, 0))
        self.connect(
            (self.blocks_tagged_stream_multiply_length_0_0_0_0, 0),
            (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0))
        self.connect(
            (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0),
            (self.blocks_tagged_stream_multiply_length_0_0_0_0, 0))
        self.connect(
            (self.digital_additive_scrambler_bb_0_0, 0),
            (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0))
示例#38
0
    def test_011(self):
        random.seed(0)
        src_data = []
        for i in range(56):
            src_data.append((random.randint(0,255)))
        src_data = tuple(src_data)
        expected_results = src_data
        src = blocks.vector_source_b(tuple(src_data),False)
        op1 = blocks.packed_to_unpacked_bb(7, gr.GR_LSB_FIRST)
        op2 = blocks.unpacked_to_packed_bb(7, gr.GR_LSB_FIRST)
        dst = blocks.vector_sink_b()

        self.tb.connect(src, op1, op2)
        self.tb.connect(op2, dst)
        self.tb.run()

        self.assertEqual(expected_results[0:201], dst.data())
    def test_011(self):
        random.seed(0)
        src_data = []
        for i in xrange(56):
            src_data.append((random.randint(0,255)))
        src_data = tuple(src_data)
        expected_results = src_data
        src = blocks.vector_source_b(tuple(src_data),False)
        op1 = blocks.packed_to_unpacked_bb(7, gr.GR_LSB_FIRST)
        op2 = blocks.unpacked_to_packed_bb(7, gr.GR_LSB_FIRST)
        dst = blocks.vector_sink_b()

        self.tb.connect(src, op1, op2)
        self.tb.connect(op2, dst)
        self.tb.run()

        self.assertEqual(expected_results[0:201], dst.data())
示例#40
0
    def test_001_dsss_encoder_bb (self):
        code_length = 21
        code = [random.randint(0, 1) for u in xrange(code_length)]
        data_length = 164
        data = [random.randint(0, 1) for u in xrange(data_length)]
        expected_result = py_encode(data, code)
        src = blocks.vector_source_b (data)
        packer = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        dsss_encoder = dsss.dsss_encoder_bb(code)
        dst = blocks.vector_sink_b ()

        self.tb.connect (src, packer,  dsss_encoder, dst)
        self.tb.start ()
        time.sleep(0.1)
        self.tb.stop()

        actual_result = list(dst.data ())
        self.assertTrue(len(actual_result) > len(expected_result)/2)
        self.assertEqual(actual_result, expected_result[:len(actual_result)])
示例#41
0
    def __init__(self, constellation, samples_per_symbol,
                 differential, excess_bw, gray_coded,
                 verbose, log):

        gr.hier_block2.__init__(self, "bert_transmit",
                                gr.io_signature(0, 0, 0),                    # Output signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Input signature
        
        # Create BERT data bit stream	
	self._bits = blocks.vector_source_b([1,], True)      # Infinite stream of ones
        self._scrambler = digital.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler

        self._mod = digital.generic_mod(constellation, differential,
                                        samples_per_symbol,
                                        gray_coded, excess_bw,
                                        verbose, log)

        self._pack = blocks.unpacked_to_packed_bb(self._mod.bits_per_symbol(), gr.GR_MSB_FIRST)

        self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
示例#42
0
    def __init__(self):
        gr.top_block.__init__(self, "TW-1 test decoder")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.samp_per_sym = samp_per_sym = 10
        self.gain_mu = gain_mu = 0.175*3

        ##################################################
        # Blocks
        ##################################################
        self.synctags_fixedlen_tagger_0 = synctags.fixedlen_tagger("syncword", "packet_len", 256*8, numpy.byte)
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate, 2400, 2000, firdes.WIN_HAMMING, 6.76))
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16)
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10010011000010110101000111011110", 4, "syncword")
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source("/tmp/tw-1c.wav", False)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_char*1, "packet_len", 1/8.0)
        self.blocks_message_debug_1 = blocks.message_debug()
        self.ax100_gomx3_rs_decode_0 = ax100.gomx3_rs_decode(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.blocks_message_debug_1, 'print_pdu'))    
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.ax100_gomx3_rs_decode_0, 'in'))    
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.synctags_fixedlen_tagger_0, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
        self.connect((self.synctags_fixedlen_tagger_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
示例#43
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sigma = sigma = 0.3
        self.samp_rate = samp_rate = 32000
        self.max_iterations = max_iterations = 50

        ##################################################
        # Blocks
        ##################################################
        self.ldpc_lh_detector_fb_0 = ldpc.lh_detector_fb()
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([1.0, -1.0]), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/manu/Downloads/in.flac", False)
        self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/val")
        self.blocks_file_sink_2.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/ref")
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/out")
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, sigma, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.ldpc_lh_detector_fb_0, 0))
        self.connect((self.ldpc_lh_detector_fb_0, 0), (self.blocks_file_sink_2, 0))
        self.connect((self.ldpc_lh_detector_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_1, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
示例#44
0
    def __init__(self, options=None):
        gr.hier_block2.__init__(self, "ops_sat_deframer",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')

        self.slicer = digital.binary_slicer_fb()
        self.nrzi = nrzi_decode()
        self.descrambler = digital.descrambler_bb(0x21, 0, 16)
        self.deframer = hdlc_deframer(False, 10000)  # we skip CRC-16 check
        self.strip = pdu_head_tail(3, 16)

        # CCSDS descrambler
        self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.scramble = digital.additive_scrambler_bb(
            0xA9,
            0xFF,
            7,
            count=0,
            bits_per_byte=1,
            reset_tag_key="packet_len")
        self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')

        # prevents passing codewords of incorrect size to the RS decoder
        self.length_filter = pdu_length_filter(33, 255)
        self.fec = decode_rs(False, 1)

        self.connect(self, self.slicer, self.nrzi, self.descrambler,
                     self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.strip, 'in'))
        self.msg_connect((self.strip, 'out'), (self.pdu2tag, 'pdus'))
        self.connect(self.pdu2tag, self.unpack, self.scramble, self.pack,
                     self.tag2pdu)
        self.msg_connect((self.tag2pdu, 'pdus'), (self.length_filter, 'in'))
        self.msg_connect((self.length_filter, 'out'), (self.fec, 'in'))
        self.msg_connect((self.fec, 'out'), (self, 'out'))
示例#45
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Example1")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.sigma = sigma = 0.5
        self.samp_rate = samp_rate = 32000
        self.max_iterations = max_iterations = 50
        self.alist_file = alist_file = "/home/manu/repos/ldpc/gr-ldpc/python/alist-files"

        ##################################################
        # Blocks
        ##################################################
        self.ldpc_ldpc_hier_encoder_bb_0 = ldpc.ldpc_hier_encoder_bb("/home/manu/1920.1280.3.303/H1920.1280.3.303")
        self.ldpc_ldpc_hier_decoder_fb_0 = ldpc.ldpc_hier_decoder_fb("/home/manu/1920.1280.3.303/H1920.1280.3.303", sigma, max_iterations)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([1.0, -1.0]), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/manu/Downloads/06 - Coming Back To Life.flac", False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/manu/Downloads/out", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_GAUSSIAN, sigma, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.ldpc_ldpc_hier_decoder_fb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ldpc_ldpc_hier_encoder_bb_0, 0))
        self.connect((self.ldpc_ldpc_hier_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.ldpc_ldpc_hier_decoder_fb_0, 0))
示例#46
0
    def __init__(self):
        gr.top_block.__init__(self, "Wmbus Phy2")

        ##################################################
        # Variables
        ##################################################
        self.frame = frame = [1, 1]

        ##################################################
        # Blocks
        ##################################################
        self.gr_vector_source_x_0 = blocks.vector_source_b((frame), False, 1)
        self.gr_vector_sink_x_1 = blocks.vector_sink_b(1)
        self.gr_vector_sink_x_0 = blocks.vector_sink_b(1)
        self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(
            4, gr.GR_MSB_FIRST)
        self.gr_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(6)
        self.digital_map_bb_1 = digital.map_bb(
            ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]))
        self.digital_map_bb_0 = digital.map_bb(([
            16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 3, 16, 1, 2, 16, 16,
            16, 16, 7, 16, 16, 0, 16, 16, 5, 6, 16, 4, 16, 16, 16, 16, 16, 16,
            11, 16, 9, 10, 16, 16, 15, 16, 16, 8, 16, 16, 16, 16, 13, 14, 16,
            12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
        ]))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_vector_source_x_0, 0),
                     (self.gr_pack_k_bits_bb_0, 0))
        self.connect((self.gr_pack_k_bits_bb_0, 0), (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0),
                     (self.gr_unpacked_to_packed_xx_0, 0))
        self.connect((self.gr_unpacked_to_packed_xx_0, 0),
                     (self.gr_vector_sink_x_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.digital_map_bb_1, 0))
        self.connect((self.digital_map_bb_1, 0), (self.gr_vector_sink_x_1, 0))
    def __init__(self, scrambler=0):
        gr.hier_block2.__init__(
            self, "AX.25 Line Coding Heir Block",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_char*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.scrambler = scrambler

        ##################################################
        # Blocks
        ##################################################
        self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x00, 16)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_char*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=scrambler,
        	output_index=0,
        )
        self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.blks2_selector_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.digital_scrambler_bb_0, 0))    
        self.connect((self.blks2_selector_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ax25_nrzi_encoder_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self, 0))    
        self.connect((self.digital_scrambler_bb_0, 0), (self.blks2_selector_0, 1))    
        self.connect((self, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
示例#48
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Multi Tx")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.audio_rate = audio_rate = 48000
        self.wpm = wpm = 15
        self.wbfm_on = wbfm_on = True
        self.usb_on = usb_on = True
        self.samp_rate = samp_rate = audio_rate * 40
        self.q_offset = q_offset = 0
        self.psk_on = psk_on = True
        self.phase = phase = 0
        self.nbfm_on = nbfm_on = True
        self.magnitude = magnitude = 0
        self.lsb_on = lsb_on = True
        self.i_offset = i_offset = 0
        self.gain = gain = 25
        self.cw_on = cw_on = True
        self.center_freq = center_freq = 441000000
        self.am_on = am_on = True

        ##################################################
        # Blocks
        ##################################################
        self._wbfm_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.wbfm_on,
        	callback=self.set_wbfm_on,
        	label="WBFM",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._wbfm_on_check_box, 4, 1, 1, 1)
        self._usb_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.usb_on,
        	callback=self.set_usb_on,
        	label="USB",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._usb_on_check_box, 4, 4, 1, 1)
        _q_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._q_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_q_offset_sizer,
        	value=self.q_offset,
        	callback=self.set_q_offset,
        	label="DC offset Q",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._q_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_q_offset_sizer,
        	value=self.q_offset,
        	callback=self.set_q_offset,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_q_offset_sizer, 3, 0, 1, 7)
        self._psk_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.psk_on,
        	callback=self.set_psk_on,
        	label="PSK31",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._psk_on_check_box, 4, 6, 1, 1)
        _phase_sizer = wx.BoxSizer(wx.VERTICAL)
        self._phase_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_phase_sizer,
        	value=self.phase,
        	callback=self.set_phase,
        	label="Phase correction",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._phase_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_phase_sizer,
        	value=self.phase,
        	callback=self.set_phase,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_phase_sizer, 0, 0, 1, 7)
        self._nbfm_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.nbfm_on,
        	callback=self.set_nbfm_on,
        	label="NBFM",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._nbfm_on_check_box, 4, 0, 1, 1)
        _magnitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._magnitude_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_magnitude_sizer,
        	value=self.magnitude,
        	callback=self.set_magnitude,
        	label="Magnitude correction",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._magnitude_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_magnitude_sizer,
        	value=self.magnitude,
        	callback=self.set_magnitude,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_magnitude_sizer, 1, 0, 1, 7)
        self._lsb_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.lsb_on,
        	callback=self.set_lsb_on,
        	label="LSB",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._lsb_on_check_box, 4, 3, 1, 1)
        _i_offset_sizer = wx.BoxSizer(wx.VERTICAL)
        self._i_offset_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_i_offset_sizer,
        	value=self.i_offset,
        	callback=self.set_i_offset,
        	label="DC offset I",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._i_offset_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_i_offset_sizer,
        	value=self.i_offset,
        	callback=self.set_i_offset,
        	minimum=-0.1,
        	maximum=0.1,
        	num_steps=200,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_i_offset_sizer, 2, 0, 1, 7)
        self._cw_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.cw_on,
        	callback=self.set_cw_on,
        	label="CW",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._cw_on_check_box, 4, 5, 1, 1)
        self._am_on_check_box = forms.check_box(
        	parent=self.GetWin(),
        	value=self.am_on,
        	callback=self.set_am_on,
        	label="AM",
        	true=True,
        	false=False,
        )
        self.GridAdd(self._am_on_check_box, 4, 2, 1, 1)
        self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, audio_rate, 5, 0.35, 200))
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(
        	1, audio_rate, 5, 0.35, 200))
        self.rational_resampler_xxx_3 = filter.rational_resampler_ccc(
                interpolation=192,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
                interpolation=samp_rate,
                decimation=audio_rate,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=samp_rate / audio_rate / 2,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=samp_rate / audio_rate / 4,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(gain, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_1 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	0.5, audio_rate, 5000, 400, firdes.WIN_HAMMING, 6.76))
        self.iqbalance_fix_cc_0 = iqbalance.fix_cc(magnitude, phase)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=2,
          mod_code="none",
          differential=True,
          samples_per_symbol=8,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_map_bb_0 = digital.map_bb(([1,0]))
        self.blocks_wavfile_source_0 = blocks.wavfile_source("multi_tx.wav", True)
        self.blocks_vector_source_x_2 = blocks.vector_source_b((0,0, 1,1,0,1,1,0,1, 0,0, 1,0,1,0,1,1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1,1,0,1,0,1, 0,0, 1,1,1,0,1,1,1, 0,0, 1,1,1,1,1,1,1,1, 0,0, 1,1,1,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1, 0,0, 1,0,1, 0,0, 1,1, 0,0, 1,0,1,1,1, 0,0, 1,0,1, 0,0, 1,1,0,1, 0,0, 1,1,1,1, 0,0, 1,0,1,1,0,1,1, 0,0, 1,0,1,0,1,1,1, 0,0, 1,1,1,0,1), True, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_c((1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0,0,0,0,0, 1,1,1,0,1,0,1, 0,0,0, 1, 0,0,0,0,0,0,0, 1,0,1,0,1,0,1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1,0,1,1,1,0,1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0, 1,0,1,1,1,0,1, 0,0,0,0,0,0,0, 1,1,1, 0,0,0, 1, 0,0,0, 1,0,1,0,1, 0,0,0, 1,1,1, 0,0,0, 1,0,1, 0,0,0, 1,1,1,0,1, 0,0,0, 1,1,1,0,1,1,1,0,1, 0,0,0,0,0,0,0), True, 1, [])
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, int(1.2 * audio_rate / wpm))
        self.blocks_multiply_xx_6 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_5 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_4 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vcc((i_offset + 1j * q_offset, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0.5, ))
        self.band_pass_filter_0_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass(
        	1, audio_rate, -2800, -200, 200, firdes.WIN_HAMMING, 6.76))
        self.band_pass_filter_0 = filter.interp_fir_filter_ccc(1, firdes.complex_band_pass(
        	1, audio_rate, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
        self.analog_wfm_tx_0 = analog.wfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate * 4,
        	tau=75e-6,
        	max_dev=75e3,
        )
        self.analog_sig_source_x_6 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 22000, 1 if psk_on else 0, 0)
        self.analog_sig_source_x_5 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 20000, 1 if cw_on else 0, 0)
        self.analog_sig_source_x_4 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 120000, 1.0 / 7, 0)
        self.analog_sig_source_x_3_0 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 11000, 1.8 if lsb_on else 0, 0)
        self.analog_sig_source_x_3 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 14000, 1.8 if usb_on else 0, 0)
        self.analog_sig_source_x_2 = analog.sig_source_c(audio_rate, analog.GR_COS_WAVE, 0, 1 if am_on else 0, 0)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 0, 1.0 / 7 if wbfm_on else 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -100000, 1.0 / 7 if nbfm_on else 0, 0)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=audio_rate,
        	quad_rate=audio_rate * 2,
        	tau=75e-6,
        	max_dev=5e3,
        )
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_wfm_tx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.analog_wfm_tx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.rational_resampler_xxx_2, 0))
        self.connect((self.blocks_multiply_xx_4, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.analog_sig_source_x_4, 0), (self.blocks_multiply_xx_4, 1))
        self.connect((self.rational_resampler_xxx_2, 0), (self.blocks_multiply_xx_4, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0_0, 0))
        self.connect((self.analog_sig_source_x_3_0, 0), (self.blocks_multiply_xx_3_0, 1))
        self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_3_0, 0))
        self.connect((self.blocks_multiply_xx_3_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_multiply_xx_3, 0))
        self.connect((self.analog_sig_source_x_3, 0), (self.blocks_multiply_xx_3, 1))
        self.connect((self.blocks_multiply_xx_3, 0), (self.blocks_add_xx_1, 2))
        self.connect((self.blocks_add_xx_0, 0), (self.iqbalance_fix_cc_0, 0))
        self.connect((self.blocks_multiply_xx_5, 0), (self.blocks_add_xx_1, 3))
        self.connect((self.analog_sig_source_x_5, 0), (self.blocks_multiply_xx_5, 1))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_multiply_xx_5, 0))
        self.connect((self.analog_sig_source_x_6, 0), (self.blocks_multiply_xx_6, 1))
        self.connect((self.blocks_multiply_xx_6, 0), (self.blocks_add_xx_1, 4))
        self.connect((self.rational_resampler_xxx_3, 0), (self.blocks_multiply_xx_6, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.rational_resampler_xxx_3, 0))
        self.connect((self.blocks_vector_source_x_2, 0), (self.digital_map_bb_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.root_raised_cosine_filter_1, 0))
        self.connect((self.root_raised_cosine_filter_1, 0), (self.root_raised_cosine_filter_0, 0))
        self.connect((self.iqbalance_fix_cc_0, 0), (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.band_pass_filter_0, 0))
    def __init__(self, frame_size=32, puncpat='11'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.frame_size = frame_size
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.samples_per_symbol = samples_per_symbol = 64
        self.rate = rate = 2
        self.polys = polys = [79, 109]
        self.k = k = 7
        self.bitrate = bitrate = 9600
        self.samp_rate = samp_rate = samples_per_symbol*bitrate
        self.gain = gain = 50
        
        
        self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size, k, rate, (polys), 0, -1, fec.CC_STREAMING, False)
            
        self.centre_freq = centre_freq = 401e6
        self.bandwidth = bandwidth = 200e3

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 100, 1, 50, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(centre_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._show_text_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #size
        	bitrate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-128, 128)
        
        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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win)
        self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec_cc, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.digital_map_bb_0 = digital.map_bb(([-1, 1]))
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=samples_per_symbol,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.ccsds_asm_deframer_0 = ccsds.asm_deframer(0,1,False,16)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test Files/Simple GMSK Receive/out.bin", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40, 1e-4, 0, True)
        self.ais_invert_0 = ais.invert()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ais_invert_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.digital_gmsk_demod_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_char_to_float_0_0, 0), (self.fec_extended_decoder_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ccsds_asm_deframer_0, 0), (self.show_text_0, 0))    
        self.connect((self.digital_gmsk_demod_0, 0), (self.ais_invert_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.ccsds_asm_deframer_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0))    
示例#50
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_freq = tx_freq = 432.100e6
        self.tone_ofs = tone_ofs = 3000
        self.rf_rate = rf_rate = 10000000
        self.baud_rate = baud_rate = 31.25

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=8000,
                decimation=int(baud_rate*8),
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=rf_rate,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(rf_rate)
        self.osmosdr_sink_0.set_center_freq(tx_freq-tone_ofs, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(1, 0)
        self.osmosdr_sink_0.set_if_gain(1, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=2,
          mod_code="none",
          differential=True,
          samples_per_symbol=8,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_map_bb_0 = digital.map_bb(([1,0]))
        self.blocks_vector_source_x_0 = blocks.vector_source_b((0,0)*10+(0,0, 1,1,0,1,1,0,1, 0,0, 1,0,1,0,1,1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1, 0,0, 1,0,1,1,1, 0,0, 1, 0,0, 1,1,0,1,1,0,1,0,1, 0,0, 1,1,1,0,1,1,1, 0,0, 1,1,1,1,1,1,1,1, 0,0, 1,1,1,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1,0,1,0,1,1,1,1, 0,0, 1, 0,0, 1,0,1, 0,0, 1,1, 0,0, 1,0,1,1,1, 0,0, 1,0,1, 0,0, 1,1,0,1, 0,0, 1,1,1,1, 0,0, 1,0,1,1,0,1,1, 0,0, 1,0,1,0,1,1,1, 0,0, 1,1,1,0,1), True, 1, [])
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.25, ))
        self.analog_sig_source_x_0 = analog.sig_source_c(8000, analog.GR_COS_WAVE, tone_ofs, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_source_x_0, 0), (self.digital_map_bb_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
示例#51
0
    def __init__(self):
        gr.top_block.__init__(self, "Rx 2017")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx 2017")
        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", "RX_2017")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.subchan_map = subchan_map = [1]*128
        self.samp_rate = samp_rate = int(1e7)
        self.packetlen_base = packetlen_base = 256 * 12 * 2
        self.cfg = cfg = fbmc.fbmc_config(channel_map=(subchan_map), num_payload_bits=packetlen_base, num_overlap_sym=4, samp_rate=int(samp_rate)/4)
        self.taps = taps = [0.003524782368913293, 0.002520402194932103, -3.532667373554307e-17, -0.0025783423334360123, -0.0036887258756905794, -0.0026390093844383955, -3.7046301165340785e-18, 0.0027025998570024967, 0.003868663916364312, 0.0027693307492882013, -9.712380039780164e-18, -0.0028394402470439672, -0.004067056812345982, -0.0029131921473890543, 2.454170927498071e-17, 0.0029908770229667425, 0.004286897834390402, 0.0030728192068636417, -9.712380039780164e-18, -0.0031593774911016226, -0.004531863145530224, -0.0032509532757103443, -6.861573196148834e-18, 0.0033479968551546335, 0.004806521814316511, 0.003451012307778001, -9.712380039780164e-18, -0.0035605679731816053, -0.005116619635373354, -0.0036773078609257936, 2.849619674016194e-17, 0.003801962360739708, 0.005469490308314562, 0.003935364540666342, -9.712380039780164e-18, -0.004078468773514032, -0.0058746375143527985, -0.004232373554259539, -1.196125168755972e-17, 0.004398348741233349, 0.006344608962535858, 0.004577873274683952, -9.712380039780164e-18, -0.004772676154971123, -0.0068963137455284595, -0.004984795115888119, 3.532667373554307e-17, 0.005216646008193493, 0.00755310570821166, 0.005471116863191128, -9.712380039780164e-18, -0.0057516866363584995, -0.00834816973656416, -0.00606258912011981, 9.712380039780164e-18, 0.006409022491425276, 0.009330307133495808, 0.006797448266297579, -9.712380039780164e-18, -0.007235993165522814, -0.010574348270893097, -0.007735027000308037, 9.712380039780164e-18, 0.008307991549372673, 0.012201170437037945, 0.008972631767392159, -9.712380039780164e-18, -0.00975286029279232, -0.014419564977288246, -0.010681704618036747, 9.712380039780164e-18, 0.011806094087660313, 0.017623912543058395, 0.013195047155022621, -9.712380039780164e-18, -0.01495438627898693, -0.022659316658973694, -0.017255060374736786, 9.712380039780164e-18, 0.020392345264554024, 0.03172304481267929, 0.02492397651076317, -9.712380039780164e-18, -0.03204511106014252, -0.052871737629175186, -0.04486315697431564, 9.712380039780164e-18, 0.0747719332575798, 0.15861520171165466, 0.22431577742099762, 0.24915219843387604, 0.22431577742099762, 0.15861520171165466, 0.0747719332575798, 9.712380039780164e-18, -0.04486315697431564, -0.052871737629175186, -0.03204511106014252, -9.712380039780164e-18, 0.02492397651076317, 0.03172304481267929, 0.020392345264554024, 9.712380039780164e-18, -0.017255060374736786, -0.022659316658973694, -0.01495438627898693, -9.712380039780164e-18, 0.013195047155022621, 0.017623912543058395, 0.011806094087660313, 9.712380039780164e-18, -0.010681704618036747, -0.014419564977288246, -0.00975286029279232, -9.712380039780164e-18, 0.008972631767392159, 0.012201170437037945, 0.008307991549372673, 9.712380039780164e-18, -0.007735027000308037, -0.010574348270893097, -0.007235993165522814, -9.712380039780164e-18, 0.006797448266297579, 0.009330307133495808, 0.006409022491425276, 9.712380039780164e-18, -0.00606258912011981, -0.00834816973656416, -0.0057516866363584995, -9.712380039780164e-18, 0.005471116863191128, 0.00755310570821166, 0.005216646008193493, 3.532667373554307e-17, -0.004984795115888119, -0.0068963137455284595, -0.004772676154971123, -9.712380039780164e-18, 0.004577873274683952, 0.006344608962535858, 0.004398348741233349, -1.196125168755972e-17, -0.004232373554259539, -0.0058746375143527985, -0.004078468773514032, -9.712380039780164e-18, 0.003935364540666342, 0.005469490308314562, 0.003801962360739708, 2.849619674016194e-17, -0.0036773078609257936, -0.005116619635373354, -0.0035605679731816053, -9.712380039780164e-18, 0.003451012307778001, 0.004806521814316511, 0.0033479968551546335, -6.861573196148834e-18, -0.0032509532757103443, -0.004531863145530224, -0.0031593774911016226, -9.712380039780164e-18, 0.0030728192068636417, 0.004286897834390402, 0.0029908770229667425, 2.454170927498071e-17, -0.0029131921473890543, -0.004067056812345982, -0.0028394402470439672, -9.712380039780164e-18, 0.0027693307492882013, 0.003868663916364312, 0.0027025998570024967, -3.7046301165340785e-18, -0.0026390093844383955, -0.0036887258756905794, -0.0025783423334360123, -3.532667373554307e-17, 0.002520402194932103]
        self.phydyas_taps_time = phydyas_taps_time = np.array(cfg.phydyas_impulse_taps(cfg.num_total_subcarriers(), cfg.num_overlap_sym()))
        self.nguard_bins = nguard_bins = 8
        self.nchan = nchan = 4
        self.sync = sync = fbmc.sync_config(taps=(phydyas_taps_time[1:]/np.sqrt(phydyas_taps_time.dot(phydyas_taps_time))), N=cfg.num_total_subcarriers(), overlap=4, L=cfg.num_total_subcarriers()-1, pilot_A=2.0, pilot_timestep=4, pilot_carriers=(range(8, 118, 4) + [119]), subbands=nchan, bits=packetlen_base, pos=4, u=1, q=4, A=2.0, fft_len=2**13, guard=nguard_bins, order=4)
        self.su_frame_len_low_rate = su_frame_len_low_rate = sync.get_frame_samps(True)
        self.rx_gain = rx_gain = .9
        self.delay_offset = delay_offset = 1120
        self.corr_len = corr_len = len(sync.get_fir_sequences()[0])
        self.const = const = 1000
        self.cfreq = cfreq = uhd.tune_request(3.195e9, samp_rate)

        ##################################################
        # Blocks
        ##################################################
        self._rx_gain_range = Range(0, 1, .05, .9, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX gain (normalized)', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_gain_win, 0, 0, 1, 2)
        self._delay_offset_range = Range(0, 2240, 1, 1120, 200)
        self._delay_offset_win = RangeWidget(self._delay_offset_range, self.set_delay_offset, "delay_offset", "counter_slider", int)
        self.top_layout.addWidget(self._delay_offset_win)
        self._const_range = Range(0, 1000, .1, 1000, 200)
        self._const_win = RangeWidget(self._const_range, self.set_const, "const", "counter_slider", float)
        self.top_layout.addWidget(self._const_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("name=Chasmine", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_clock_source('gpsdo', 0)
        self.uhd_usrp_source_0.set_time_source('gpsdo', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(cfreq, 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.time_sync_0 = time_sync(
            constant=const,
            fir_sequences=sync.get_fir_sequences(),
            frame_len=sync.get_frame_samps(True) * nchan,
            peak_delay=delay_offset,
        )
        self.qtgui_time_sink_x_2_0_0 = qtgui.time_sink_f(
        	sync.get_frame_samps(True) * nchan, #size
        	1, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_2_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_2_0_0.set_y_label('Amplitude', "")
        
        self.qtgui_time_sink_x_2_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_2_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_2_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_2_0_0.enable_grid(False)
        self.qtgui_time_sink_x_2_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_2_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_2_0_0.disable_legend()
        
        labels = ['corr', 'corr', '', '', '',
                  '', '', '', '', '']
        widths = [1, 2, 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_2_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_2_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_2_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_2_0_0_win)
        self.fbmc_subchannel_deframer_vcb_0 = fbmc.subchannel_deframer_vcb(cfg.num_total_subcarriers(), nchan, nguard_bins, 0.9, (sync.get_preamble_symbols()), sync.get_syms_frame(), cfg.num_payload_bits(), (sync.get_pilot_carriers()), sync.get_pilot_timestep(), sync.get_bps())
        self.fbmc_sliding_fft_cvc_0 = fbmc.sliding_fft_cvc(cfg.num_total_subcarriers(), cfg.num_overlap_sym(), nchan, sync.get_syms_frame())
        self.fbmc_channel_estimator_vcvc_0 = fbmc.channel_estimator_vcvc(sync.get_syms_frame(), cfg.num_total_subcarriers(), cfg.num_overlap_sym(), nchan, (np.array(cfg.phydyas_frequency_taps(cfg.num_overlap_sym()))), sync.get_pilot_amplitude(), sync.get_pilot_timestep(), (sync.get_pilot_carriers()))
        self.fbmc_channel_equalizer_vcvc_0 = fbmc.channel_equalizer_vcvc(sync.get_syms_frame(), cfg.num_overlap_sym(), nchan, sync.get_pilot_timestep(), (sync.get_pilot_carriers()), cfg.num_total_subcarriers(), (cfg.phydyas_frequency_taps(cfg.num_overlap_sym())), sync.get_pilot_amplitude())
        self.classifier_packet_sink_0 = classifier.packet_sink("packet_len","127.0.0.1",5002,64,0)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(sync.get_bps(), gr.GR_LSB_FIRST)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 64, "packet_len")
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.classifier_packet_sink_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))    
        self.connect((self.fbmc_channel_equalizer_vcvc_0, 0), (self.fbmc_subchannel_deframer_vcb_0, 0))    
        self.connect((self.fbmc_channel_estimator_vcvc_0, 1), (self.fbmc_channel_equalizer_vcvc_0, 1))    
        self.connect((self.fbmc_channel_estimator_vcvc_0, 0), (self.fbmc_channel_equalizer_vcvc_0, 0))    
        self.connect((self.fbmc_sliding_fft_cvc_0, 0), (self.fbmc_channel_estimator_vcvc_0, 0))    
        self.connect((self.fbmc_subchannel_deframer_vcb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.time_sync_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.time_sync_0, 0), (self.fbmc_sliding_fft_cvc_0, 0))    
        self.connect((self.time_sync_0, 1), (self.qtgui_time_sink_x_2_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.time_sync_0, 0))    
    def __init__(self, decoder_obj_list, threading, ann=None, puncpat='11',
                 integration_period=10000, flush=None, rotator=None):
        gr.hier_block2.__init__(self, "extended_decoder",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(1, 1, gr.sizeof_char))
        self.blocks=[]
        self.ann=ann
        self.puncpat=puncpat
        self.flush=flush

        if(type(decoder_obj_list) == list):
            if(type(decoder_obj_list[0]) == list):
                gr.log.info("fec.extended_decoder: Parallelism must be 1.")
                raise AttributeError
        else:
            # If it has parallelism of 0, force it into a list of 1
            decoder_obj_list = [decoder_obj_list,]

        message_collector_connected=False

        ##anything going through the annihilator needs shifted, uchar vals
        if fec.get_decoder_input_conversion(decoder_obj_list[0]) == "uchar" or \
           fec.get_decoder_input_conversion(decoder_obj_list[0]) == "packed_bits":
            self.blocks.append(blocks.multiply_const_ff(48.0))

        if fec.get_shift(decoder_obj_list[0]) != 0.0:
            self.blocks.append(blocks.add_const_ff(fec.get_shift(decoder_obj_list[0])))
        elif fec.get_decoder_input_conversion(decoder_obj_list[0]) == "packed_bits":
            self.blocks.append(blocks.add_const_ff(128.0))

        if fec.get_decoder_input_conversion(decoder_obj_list[0]) == "uchar" or \
           fec.get_decoder_input_conversion(decoder_obj_list[0]) == "packed_bits":
            self.blocks.append(blocks.float_to_uchar());

        const_index = 0; #index that corresponds to mod order for specinvert purposes

        if not self.flush:
            flush = 10000;
        else:
            flush = self.flush;
        if self.ann: #ann and puncpat are strings of 0s and 1s
            cat = fec.ULLVector();
            for i in fec.read_big_bitlist(ann):
                cat.append(i);

            synd_garble = .49
            idx_list = list(self.garbletable.keys())
            idx_list.sort()
            for i in idx_list:
                if 1.0 / self.ann.count('1') >= i:
                    synd_garble = self.garbletable[i]
            print('using syndrom garble threshold ' + str(synd_garble) + 'for conv_bit_corr_bb')
            print('ceiling: .0335 data garble rate')
            self.blocks.append(fec.conv_bit_corr_bb(cat, len(puncpat) - puncpat.count('0'),
                                                    len(ann), integration_period, flush, synd_garble))

        if self.puncpat != '11':
            self.blocks.append(fec.depuncture_bb(len(puncpat), read_bitlist(puncpat), 0))

        if fec.get_decoder_input_conversion(decoder_obj_list[0]) == "packed_bits":
            self.blocks.append(blocks.uchar_to_float())
            self.blocks.append(blocks.add_const_ff(-128.0))
            self.blocks.append(digital.binary_slicer_fb())
            self.blocks.append(blocks.unpacked_to_packed_bb(1,0))

        if(len(decoder_obj_list) > 1):
            if(fec.get_history(decoder_obj_list[0]) != 0):
                gr.log.info("fec.extended_decoder: Cannot use multi-threaded parallelism on a decoder with history.")
                raise AttributeError

        if threading == 'capillary':
            self.blocks.append(capillary_threaded_decoder(decoder_obj_list,
                                                          fec.get_decoder_input_item_size(decoder_obj_list[0]),
                                                          fec.get_decoder_output_item_size(decoder_obj_list[0])))

        elif threading == 'ordinary':
            self.blocks.append(threaded_decoder(decoder_obj_list,
                                                fec.get_decoder_input_item_size(decoder_obj_list[0]),
                                                fec.get_decoder_output_item_size(decoder_obj_list[0])))

        else:
            self.blocks.append(fec.decoder(decoder_obj_list[0],
                                           fec.get_decoder_input_item_size(decoder_obj_list[0]),
                                           fec.get_decoder_output_item_size(decoder_obj_list[0])))

        if fec.get_decoder_output_conversion(decoder_obj_list[0]) == "unpack":
            self.blocks.append(blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST));

        self.connect((self, 0), (self.blocks[0], 0));
        self.connect((self.blocks[-1], 0), (self, 0));

        for i in range(len(self.blocks) - 1):
            self.connect((self.blocks[i], 0), (self.blocks[i+1], 0));
示例#53
0
    def __init__(self):
        gr.top_block.__init__(self, "OPS-SAT UHF demodulator/decoder")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OPS-SAT UHF demodulator/decoder")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

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

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

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

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'),
                         (self.satellites_decode_rs_0, 'in'))
        self.msg_connect((self.satellites_check_address_0, 'ok'),
                         (self.satellites_strip_ax25_header_0, 'in'))
        self.msg_connect((self.satellites_decode_rs_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.satellites_decode_rs_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.satellites_hdlc_deframer_0_0, 'out'),
                         (self.satellites_check_address_0, 'in'))
        self.msg_connect((self.satellites_strip_ax25_header_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_additive_scrambler_bb_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0))
        self.connect((self.digital_additive_scrambler_bb_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satellites_nrzi_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0_0, 0),
                     (self.satellites_hdlc_deframer_0_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.satellites_nrzi_decode_0, 0),
                     (self.digital_descrambler_bb_0_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
示例#54
0
    def __init__(self, tx_freq, if_gain, rf_amp, psk_vector):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.tx_freq = tx_freq
        self.tone_ofs = tone_ofs = 3000
        self.rf_rate = rf_rate = 500000
        self.baud_rate = baud_rate = 31.25

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
                interpolation=8000,
                decimation=int(baud_rate*8),
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=rf_rate,
                decimation=8000,
                taps=None,
                fractional_bw=None,
        )
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_sink_0.set_sample_rate(rf_rate)
        self.osmosdr_sink_0.set_center_freq(tx_freq-tone_ofs, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)


        # OK, osmocom is incredibly stupid. It interprets "0" for these fields as "not set",
        #and defaults to an IF gain of +16 and turning the RF amp *ON*.
        # A value of "1" for the RF gain turns it off, and a value >=7 turns it on.
        # For IF gain, 0->16, 1..47 behave as you'd expect. This means IF gain=0 is impossible.
        self.osmosdr_sink_0.set_gain(        14 if rf_amp  > 0 else 1, 0)
        self.osmosdr_sink_0.set_if_gain(if_gain if if_gain > 0 else 1, 0)

        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.digital_psk_mod_0 = digital.psk.psk_mod(
          constellation_points=2,
          mod_code="none",
          differential=True,
          samples_per_symbol=8,
          excess_bw=0.35,
          verbose=False,
          log=False,
          )
        self.digital_map_bb_0 = digital.map_bb(([1,0]))
        self.psk_vector = psk_vector
        self.blocks_vector_source_x_0 = blocks.vector_source_b(psk_vector, False, 1, [])
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.25, ))
        self.analog_sig_source_x_0 = analog.sig_source_c(8000, analog.GR_COS_WAVE, tone_ofs, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_source_x_0, 0), (self.digital_map_bb_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_psk_mod_0, 0))
        self.connect((self.digital_map_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
示例#55
0
    def __init__(self):
        gr.top_block.__init__(self, "Bluetooth LE Receiver")

        ##################################################
        # Variables
        ##################################################
        self.transition_width = transition_width = 300e3
        self.sample_rate = sample_rate = 4e6
        self.data_rate = data_rate = 1e6
        self.cutoff_freq = cutoff_freq = 850e3
        self.ble_channel_spacing = ble_channel_spacing = 2e6
        self.ble_channel = ble_channel = 12
        self.ble_base_freq = ble_base_freq = 2402e6
        self.squelch_threshold = squelch_threshold = -70
        self.rf_gain = rf_gain = 10
        self.lowpass_filter = lowpass_filter = firdes.low_pass(1, sample_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING, 6.76)
        self.gmsk_sps = gmsk_sps = int(sample_rate / data_rate)
        self.gmsk_omega_limit = gmsk_omega_limit = 0.035
        self.gmsk_mu = gmsk_mu = 0.5
        self.gmsk_gain_mu = gmsk_gain_mu = 0.7
        self.freq_offset = freq_offset = 1e6
        self.freq = freq = ble_base_freq+(ble_channel_spacing * ble_channel)

        ##################################################
        # Message Queues
        ##################################################
        self.message_queue = message_queue = gr.msg_queue(2)

        ##################################################
        # Blocks
        ##################################################
        self.unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
        self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source.set_sample_rate(sample_rate)
        self.osmosdr_source.set_center_freq(freq+freq_offset, 0)
        self.osmosdr_source.set_freq_corr(0, 0)
        self.osmosdr_source.set_dc_offset_mode(0, 0)
        self.osmosdr_source.set_iq_balance_mode(0, 0)
        self.osmosdr_source.set_gain_mode(False, 0)
        self.osmosdr_source.set_gain(rf_gain, 0)
        self.osmosdr_source.set_if_gain(20, 0)
        self.osmosdr_source.set_bb_gain(20, 0)
        self.osmosdr_source.set_antenna("", 0)
        self.osmosdr_source.set_bandwidth(0, 0)
          
        self.message_sink = blocks.message_sink(gr.sizeof_char*1, message_queue, True)
        self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(1, (lowpass_filter), -freq_offset, sample_rate)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=gmsk_sps,
        	gain_mu=gmsk_gain_mu,
        	mu=gmsk_mu,
        	omega_relative_limit=gmsk_omega_limit,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.analog_simple_squelch = analog.simple_squelch_cc(squelch_threshold, 0.1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_lp, 0), (self.digital_gmsk_demod_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.unpacked_to_packed, 0))
        self.connect((self.unpacked_to_packed, 0), (self.message_sink, 0))
        self.connect((self.osmosdr_source, 0), (self.analog_simple_squelch, 0))
        self.connect((self.analog_simple_squelch, 0), (self.freq_xlating_fir_filter_lp, 0))
示例#56
0
    def __init__(self, system, site_uuid, overseer_uuid):

        gr.top_block.__init__(self, "moto receiver")

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

        self.instance_uuid = '%s' % uuid.uuid4()
        self.log = logging.getLogger('overseer.moto_control_demod.%s' %
                                     self.instance_uuid)
        self.log.info('Initializing instance: %s site: %s overseer: %s' %
                      (self.instance_uuid, site_uuid, overseer_uuid))
        self.overseer_uuid = overseer_uuid
        self.site_uuid = site_uuid

        self.channel_rate = 12500

        self.packets = 0
        self.packets_bad = 0
        self.patches = {}

        self.quality = []
        self.site_detail = {}

        self.symbol_rate = symbol_rate = 3600.0
        self.control_source = 0

        self.offset = offset = 0
        self.is_locked = False

        self.system = system

        self.system_id = system['id']
        self.channels = system['channels']
        self.channels_list = self.channels.keys()

        self.thread_id = '%s-%s' % (self.system['type'], self.system_id)

        self.control_channel_key = 0
        self.control_channel = control_channel = self.channels[
            self.channels_list[0]]

        self.option_dc_offset = False
        self.option_udp_sink = False

        self.enable_capture = True
        self.keep_running = True

        ##################################################
        # Message Queues
        ##################################################
        self.control_msg_sink_msgq = gr.msg_queue(1024)

        ##################################################
        # Threads
        ##################################################

        receive_engine = threading.Thread(target=self.receive_engine)
        receive_engine.daemon = True
        receive_engine.start()

        quality_check = threading.Thread(target=self.quality_check)
        quality_check.daemon = True
        quality_check.start()

        self.connector = frontend_connector()
        self.redis_demod_publisher = redis_demod_publisher(parent_demod=self)
        self.client_redis = client_redis()

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

        self.source = None

        control_sample_rate = 12500
        channel_rate = control_sample_rate * 2

        self.control_quad_demod = analog.quadrature_demod_cf(5)

        if (self.option_dc_offset):
            moving_sum = blocks.moving_average_ff(1000, 1, 4000)
            divide_const = blocks.multiply_const_vff((0.001, ))
            self.probe = blocks.probe_signal_f()

        self.control_clock_recovery = digital.clock_recovery_mm_ff(
            channel_rate / symbol_rate, 1.4395919, 0.5, 0.05, 0.005)
        self.control_binary_slicer = digital.binary_slicer_fb()
        self.control_byte_pack = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.control_msg_sink = blocks.message_sink(gr.sizeof_char * 1,
                                                    self.control_msg_sink_msgq,
                                                    True)

        if (self.option_udp_sink):
            self.udp = blocks.udp_sink(gr.sizeof_gr_complex * 1, "127.0.0.1",
                                       self.system_id, 1472, True)

        moving_sum = blocks.moving_average_ff(10000, 1, 40000)
        subtract = blocks.sub_ff(1)
        divide_const = blocks.multiply_const_vff((0.0001, ))
        self.probe = blocks.probe_signal_f()
        self.connect(self.control_quad_demod, moving_sum, divide_const,
                     self.probe)

        ##################################################
        # Connections
        ##################################################

        self.connect(self.control_quad_demod, self.control_clock_recovery)
        self.connect(self.control_clock_recovery, self.control_binary_slicer,
                     self.control_byte_pack, self.control_msg_sink)

        if (self.option_dc_offset):
            self.connect(self.control_quad_demod, moving_sum, divide_const,
                         self.probe)

        if (self.option_udp_sink):
            self.connect(self.control_prefilter, self.udp)

        self.tune_next_control()
示例#57
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="FHSS Packets")

        ##################################################
        # Variables
        ##################################################
        self.samp_sym = samp_sym = 64
        self.samp_rate = samp_rate = 800000
        self.init = init = 1, 1, 1, 1
        self.generator = generator = 1, 1, 0, 0, 1
        self.code_rate = code_rate = int(1389 * samp_sym)

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Received Spread Spectrum Signal",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=1024,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Despread Signal",
        	peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 11000, 1000, firdes.WIN_HAMMING, 6.76))
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=samp_sym,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=samp_sym,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0.01,
        	frequency_offset=1 / samp_rate,
        	epsilon=1 + 0.000001,
        	taps=(1.0 + 1.0j, ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 0, samp_rate, (generator), (init))
        self.Spread_sync_0 = Spread.sync()
        self.Spread_rx_synthesizer_0 = Spread.rx_synthesizer(code_rate, 
                                      samp_sym, 
                                      samp_rate, 
                                      11000, 
                                      10000, 
                                      0.01, 
                                      (generator), 
                                      (init))
        self.Spread_rx_sync_0 = Spread.rx_sync(12)
        self.Spread_msg_source_0 = Spread.msg_source(500, 100)
        self.Spread_framer_0 = Spread.framer(0)
        self.Spread_deframer_0 = Spread.deframer(0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Spread_synthesizer_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.Spread_rx_synthesizer_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0), (self.Spread_rx_sync_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.Spread_synthesizer_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.Spread_sync_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.wxgui_fftsink2_0_0, 0))
        self.connect((self.Spread_rx_synthesizer_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_gmsk_demod_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.Spread_framer_0, "out", self.Spread_sync_0, "in")
        self.msg_connect(self.Spread_msg_source_0, "out", self.Spread_framer_0, "in")
        self.msg_connect(self.Spread_rx_sync_0, "out", self.Spread_deframer_0, "in")
示例#58
0
文件: fic.py 项目: andrmuel/gr-dab
    def __init__(self, dab_params, verbose=False, debug=False):
        """
        Hierarchical block for FIC decoding

        @param dab_params DAB parameter object (grdab.parameters.dab_parameters)
        """
        gr.hier_block2.__init__(self, "fic",
                                gr.io_signature(1, 1, gr.sizeof_float * dab_params.num_carriers * 2),
                                gr.io_signature(1, 1, gr.sizeof_char * 32))

        self.dp = dab_params
        self.verbose = verbose
        self.debug = debug

        # FIB selection and block partitioning
        self.select_fic_syms = grdab.select_vectors(gr.sizeof_float, self.dp.num_carriers * 2, self.dp.num_fic_syms, 0)
        self.repartition_fic = grdab.repartition_vectors(gr.sizeof_float, self.dp.num_carriers * 2,
                                                       self.dp.fic_punctured_codeword_length, self.dp.num_fic_syms,
                                                       self.dp.num_cifs)

        # unpuncturing
        self.unpuncture = grdab.unpuncture_vff(self.dp.assembled_fic_puncturing_sequence, 0)

        # convolutional coding
        # self.fsm = trellis.fsm(self.dp.conv_code_in_bits, self.dp.conv_code_out_bits, self.dp.conv_code_generator_polynomials)
        self.fsm = trellis.fsm(1, 4, [0133, 0171, 0145, 0133])  # OK (dumped to text and verified partially)
        self.conv_v2s = blocks.vector_to_stream(gr.sizeof_float, self.dp.fic_conv_codeword_length)
        # self.conv_decode = trellis.viterbi_combined_fb(self.fsm, 20, 0, 0, 1, [1./sqrt(2),-1/sqrt(2)] , trellis.TRELLIS_EUCLIDEAN)
        table = [
            0, 0, 0, 0,
            0, 0, 0, 1,
            0, 0, 1, 0,
            0, 0, 1, 1,
            0, 1, 0, 0,
            0, 1, 0, 1,
            0, 1, 1, 0,
            0, 1, 1, 1,
            1, 0, 0, 0,
            1, 0, 0, 1,
            1, 0, 1, 0,
            1, 0, 1, 1,
            1, 1, 0, 0,
            1, 1, 0, 1,
            1, 1, 1, 0,
            1, 1, 1, 1
        ]
        assert (len(table) / 4 == self.fsm.O())
        table = [(1 - 2 * x) / sqrt(2) for x in table]
        self.conv_decode = trellis.viterbi_combined_fb(self.fsm, 774, 0, 0, 4, table, trellis.TRELLIS_EUCLIDEAN)
        #self.conv_s2v = blocks.stream_to_vector(gr.sizeof_char, 774)
        self.conv_prune = grdab.prune(gr.sizeof_char, self.dp.fic_conv_codeword_length / 4, 0,
                                            self.dp.conv_code_add_bits_input)

        # energy dispersal
        self.prbs_src = blocks.vector_source_b(self.dp.prbs(self.dp.energy_dispersal_fic_vector_length), True)
        #self.energy_v2s = blocks.vector_to_stream(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length)
        self.add_mod_2 = blocks.xor_bb()
        self.energy_s2v = blocks.stream_to_vector(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length)
        self.cut_into_fibs = grdab.repartition_vectors(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length,
                                                     self.dp.fib_bits, 1, self.dp.energy_dispersal_fic_fibs_per_vector)

        # connect all
        self.nullsink = blocks.null_sink(gr.sizeof_char)
        self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.fibout = blocks.stream_to_vector(1, 32)
        # self.filesink = gr.file_sink(gr.sizeof_char, "debug/fic.dat")
        self.fibsink = grdab.fib_sink_vb()

        # self.connect((self,0), (self.select_fic_syms,0), (self.repartition_fic,0), self.unpuncture, self.conv_v2s, self.conv_decode, self.conv_s2v, self.conv_prune, self.energy_v2s, self.add_mod_2, self.energy_s2v, (self.cut_into_fibs,0), gr.vector_to_stream(1,256), gr.unpacked_to_packed_bb(1,gr.GR_MSB_FIRST), self.filesink)
        self.connect((self, 0),
                     (self.select_fic_syms, 0),
                     (self.repartition_fic, 0),
                     self.unpuncture,
                     self.conv_v2s,
                     self.conv_decode,
                     #self.conv_s2v,
                     self.conv_prune,
                     #self.energy_v2s,
                     self.add_mod_2,
                     self.energy_s2v,
                     (self.cut_into_fibs, 0),
                     blocks.vector_to_stream(1, 256),
                     self.pack,
                     self.fibout,
                     self.fibsink)
        self.connect(self.fibout, self)
        self.connect(self.prbs_src, (self.add_mod_2, 1))

        if self.debug:
            self.connect((self, 0), blocks.file_sink(gr.sizeof_float * self.dp.num_carriers * 2, "debug/transmission_frame.dat"))
            self.connect((self, 1), blocks.file_sink(gr.sizeof_char, "debug/transmission_frame_trigger.dat"))
            self.connect(self.select_fic_syms, blocks.file_sink(gr.sizeof_float * self.dp.num_carriers * 2, "debug/fic_select_syms.dat"))
            self.connect(self.repartition_fic, blocks.file_sink(gr.sizeof_float * self.dp.fic_punctured_codeword_length, "debug/fic_repartitioned.dat"))
            self.connect(self.unpuncture, blocks.file_sink(gr.sizeof_float * self.dp.fic_conv_codeword_length, "debug/fic_unpunctured.dat"))
            self.connect(self.conv_decode, blocks.file_sink(gr.sizeof_char, "debug/fic_decoded.dat"))
            self.connect(self.conv_prune, blocks.file_sink(gr.sizeof_char, "debug/fic_decoded_pruned.dat"))
            #self.connect(self.conv_decode, blocks.file_sink(gr.sizeof_char * self.dp.energy_dispersal_fic_vector_length, "debug/fic_energy_dispersal_undone.dat"))
            self.connect(self.pack, blocks.file_sink(gr.sizeof_char, "debug/fic_energy_undone.dat"))