def __init__(self, sample_rate, freq_offset, queue, logger = None, group_description_csv = None):

		gr.hier_block2.__init__(
			self,
			"SmartZone Control Channel",
			gr.io_signature(1, 1, gr.sizeof_gr_complex),		# input signature
			gr.io_signature(0, 0, 0)				# output signature
		)

		self._CC_DEVIATION	= 4e3		# observed

		self._symbol_rate	= 3600.0	# control channel rate is 3.6kb/s
		self._oversample	= 4		# XXX reduce
		
		# get close to the desired sample rate with decimation
		channel_decimation = int(sample_rate / (self._oversample * self._symbol_rate)) & ~1
		channel_rate = sample_rate / channel_decimation
		samples_per_symbol = channel_rate / self._symbol_rate

		# channel_bw = self._CC_DEVIATION + self._symbol_rate # from pager source
		channel_bw = 3 * self._symbol_rate

		# taps = firdes.low_pass(1, sample_rate, int(3.0 * self._symbol_rate), int(3.0 * self._symbol_rate / 10.0), firdes.WIN_HAMMING)
		channel_taps = firdes.low_pass(1, sample_rate, channel_bw, channel_bw / 10.0, firdes.WIN_HAMMING)
		channel_filter = filter.freq_xlating_fir_filter_ccf(channel_decimation, channel_taps, freq_offset, sample_rate)

		#quad_demod = analog.quadrature_demod_cf(1.0)
		quad_demod = analog.quadrature_demod_cf(channel_rate / (2 * math.pi * self._CC_DEVIATION))

		clock = digital.clock_recovery_mm_ff(omega = samples_per_symbol, gain_omega = 0.001, mu = 0, gain_mu = 0.001, omega_relative_limit = 0.005)
		slicer = digital.binary_slicer_fb()
		digital_correlate = digital.correlate_access_code_bb("10101100", 0)
		cc_sink = control_channel_sink(logger, queue, group_description_csv)

		self.connect(self, channel_filter, quad_demod, clock, slicer, digital_correlate, cc_sink)
Example #2
0
    def __init__(self, samp_rate):
        gr.hier_block2.__init__(
            self,
            "APRS demod",
            gr.io_signature(1, 1, gr.sizeof_float),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_out("out")

        self.samp_rate = samp_rate
        self.bit_rate = 1200

        taps = firdes.low_pass(1, self.samp_rate, 1200, 200)
        self.afsk_shift = filter.freq_xlating_fir_filter_fcc(
            1, taps, (1200 + 2200) / 2, self.samp_rate)

        self.afsk_demod = analog.quadrature_demod_cf(
            1.0)  # Don't care about gain just before binary slicer
        self.threashold = digital.binary_slicer_fb()
        self.clock_rec = igate.clock_recovery_timer_bb(self.samp_rate /
                                                       self.bit_rate)
        self.diff_decode = digital.diff_decoder_bb(2)
        self.negate = digital.map_bb(([1, 0]))
        self.packetizer = digital.hdlc_deframer_bp(16, 1024)
        self.parser = igate.aprs_decode_frame()

        self.connect((self, 0), (self.afsk_shift, 0))
        self.connect((self.afsk_shift, 0), (self.afsk_demod, 0))
        self.connect((self.afsk_demod, 0), (self.threashold, 0))
        self.connect((self.threashold, 0), (self.clock_rec, 0))
        self.connect((self.clock_rec, 0), (self.diff_decode, 0))
        self.connect((self.diff_decode, 0), (self.negate, 0))
        self.connect((self.negate, 0), (self.packetizer, 0))
        self.msg_connect((self.packetizer, 'out'), (self.parser, 'in'))
        self.msg_connect((self.parser, 'out'), (self, 'out'))
Example #3
0
    def __init__(self, mode, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, "ax100_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')

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

        if mode not in ['RS', 'ASM']:
            raise Exception("Unsupported AX100 mode. Use 'RS' or 'ASM'")

        self.slicer = digital.binary_slicer_fb()
        if mode == 'RS':
            self.descrambler = digital.descrambler_bb(0x21, 0, 16)
        self.deframer = sync_to_pdu_packed(packlen = 256 if mode == 'RS' else 255,\
                                           sync = _syncword,\
                                           threshold = syncword_threshold)
        self.fec = ax100_decode(self.options.verbose_fec) if mode == 'RS'\
          else u482c_decode(self.options.verbose_fec, 0, 1, 1)

        self._blocks = [self, self.slicer]
        if mode == 'RS':
            self._blocks.append(self.descrambler)
        self._blocks += [self.deframer]

        self.connect(*self._blocks)
        self.msg_connect((self.deframer, 'out'), (self.fec, 'in'))
        self.msg_connect((self.fec, 'out'), (self, 'out'))
Example #4
0
    def __init__(self,
                 frame_size=223,
                 differential=False,
                 dual_basis=False,
                 syncword_threshold=None,
                 options=None):
        gr.hier_block2.__init__(self, "ccsds_rs_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')

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

        self.slicer = digital.binary_slicer_fb()
        if differential:
            self.differential = digital.diff_decoder_bb(2)
        self.deframer = sync_to_pdu(packlen = (frame_size + 32) * 8,\
                                    sync = _syncword,\
                                    threshold = syncword_threshold)
        self.scrambler = ccsds_descrambler()
        self.fec = decode_rs(self.options.verbose_rs, 1 if dual_basis else 0)

        self._blocks = [self, self.slicer]
        if differential:
            self._blocks.append(self.differential)
        self._blocks += [self.deframer]

        self.connect(*self._blocks)
        self.msg_connect((self.deframer, 'out'), (self.scrambler, 'in'))
        self.msg_connect((self.scrambler, 'out'), (self.fec, 'in'))
        self.msg_connect((self.fec, 'out'), (self, 'out'))
Example #5
0
    def __init__(self, options):

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

        self._samples_per_symbol = options[ "samples_per_symbol" ]
        self._bits_per_sec = options[ "bits_per_sec" ]
        self._samplerate = self._samples_per_symbol * self._bits_per_sec
        self._clockrec_gain = options[ "clockrec_gain" ]
        self._omega_relative_limit = options[ "omega_relative_limit" ]
        self.fftlen = options[ "fftlen" ]
        self.freq_sync = gmsk_sync.square_and_fft_sync_cc(self._samplerate, self._bits_per_sec, self.fftlen)
        self.agc = analog.feedforward_agc_cc(512, 2)
        self.preamble = [1,1,0,0]*7
        self.mod = digital.gmsk_mod(self._samples_per_symbol, 0.4)
        self.mod_vector = ais.modulate_vector_bc(self.mod.to_basic_block(), self.preamble, [1])
        self.preamble_detect = ais.corr_est_cc(self.mod_vector,
                                               self._samples_per_symbol,
                                               1, #mark delay
                                               0.9) #threshold
        self.clockrec = ais.msk_timing_recovery_cc(self._samples_per_symbol,
                                                       self._clockrec_gain, #gain
                                                       self._omega_relative_limit, #error lim
                                                       1) #output sps

        sensitivity = (math.pi / 2)
        self.demod = analog.quadrature_demod_cf(sensitivity) #param is gain
        self.slicer = digital.binary_slicer_fb()
        self.diff = digital.diff_decoder_bb(2)
        self.invert = ais.invert() #NRZI signal diff decoded and inverted should give original signal

#        self.connect(self, self.gmsk_sync)

        self.connect(self, self.freq_sync, self.agc, (self.preamble_detect, 0), self.clockrec, self.demod, self.slicer, self.diff, self.invert, self)
Example #6
0
    def __init__(self, baudrate=1200, host_address='127.0.0.1', host_port=7355, output_file="/tmp/rx_data.bin", samp_rate=48000):
        gr.top_block.__init__(self, "Udp Decoder")

        ##################################################
        # Parameters
        ##################################################
        self.baudrate = baudrate
        self.host_address = host_address
        self.host_port = host_port
        self.output_file = output_file
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_rate/baudrate, 0.001, 0, 0.25, 0.001)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short*1, host_address, host_port, 1472, True)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, output_file, False)
        self.blocks_file_sink_0.set_unbuffered(False)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_short_to_float_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
Example #7
0
    def __init__(self, options=None):
        gr.hier_block2.__init__(
            self,
            'ax5043_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()
        # 4000 bits will leave enough room for the 200 byte packets
        self.deframer = sync_to_pdu(
            packlen=4000, sync=_syncword, threshold=4)
        self.deinterleave = deinterleave()
        self.viterbi = viterbi_decoder(5, [25, 23])
        self.pdu2tag = blocks.pdu_to_tagged_stream(byte_t, 'packet_len')
        self.hdlc = hdlc_deframer(True, 10000, crc_check_func=crc_check)

        self.connect(self, self.slicer, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.deinterleave, 'in'))
        self.msg_connect((self.deinterleave, 'out'), (self.viterbi, 'in'))
        self.msg_connect((self.viterbi, 'out'), (self.pdu2tag, 'pdus'))
        self.connect(self.pdu2tag, self.hdlc)
        self.msg_connect((self.hdlc, 'out'), (self, 'out'))
Example #8
0
    def __init__(self,
                 new_protocol=False,
                 syncword_threshold=None,
                 options=None):
        gr.hier_block2.__init__(self, "smogp_signalling_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')

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

        self.slicer = digital.binary_slicer_fb()
        self.deframer = sync_to_pdu_packed(packlen = 64,\
                                           sync = _syncword,\
                                           threshold = syncword_threshold)
        if new_protocol:
            self.deframer_tx = sync_to_pdu_packed(packlen = 64,\
                                                  sync = _syncword_tx,\
                                                  threshold = syncword_threshold)

        self.connect(self, self.slicer, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self, 'out'))
        if new_protocol:
            self.connect(self.slicer, self.deframer_tx)
            self.msg_connect((self.deframer_tx, 'out'), (self, 'out'))
Example #9
0
    def __init__(self,
                 if_rate=None,
                 filter_type=None,
                 excess_bw=_def_excess_bw,
                 symbol_rate=_def_symbol_rate):
        """
	Hierarchical block for P25 demodulation base class

		@param if_rate: sample rate of complex input channel
		@type if_rate: int
	"""
        self.if_rate = if_rate
        self.symbol_rate = symbol_rate
        self.bb_sink = None

        self.null_sink = blocks.null_sink(gr.sizeof_float)
        self.baseband_amp = blocks.multiply_const_ff(_def_bb_gain)
        coeffs = op25_c4fm_mod.c4fm_taps(
            sample_rate=self.if_rate,
            span=9,
            generator=op25_c4fm_mod.transfer_function_rx).generate()
        sps = self.if_rate / 4800
        if filter_type == 'rrc':
            ntaps = 7 * sps
            if ntaps & 1 == 0:
                ntaps += 1
            coeffs = filter.firdes.root_raised_cosine(1.0, if_rate,
                                                      symbol_rate, excess_bw,
                                                      ntaps)
        if filter_type == 'gmsk':
            # lifted from gmsk.py
            _omega = sps
            _gain_mu = _def_gmsk_mu
            _mu = _def_mu
            if not _gain_mu:
                _gain_mu = 0.175
            _gain_omega = .25 * _gain_mu * _gain_mu  # critically damped
            self.symbol_filter = blocks.multiply_const_ff(1.0)
            self.fsk4_demod = digital.clock_recovery_mm_ff(
                _omega, _gain_omega, _mu, _gain_mu, _def_omega_relative_limit)
            self.slicer = digital.binary_slicer_fb()
        elif filter_type == 'fsk4mm':
            self.symbol_filter = filter.fir_filter_fff(1, coeffs)
            _omega = sps
            _gain_mu = _def_gmsk_mu
            _mu = _def_mu
            if not _gain_mu:
                _gain_mu = 0.0175
            _gain_omega = .25 * _gain_mu * _gain_mu  # critically damped
            self.fsk4_demod = digital.clock_recovery_mm_ff(
                _omega, _gain_omega, _mu, _gain_mu, _def_omega_relative_limit)
            levels = [-2.0, 0.0, 2.0, 4.0]
            self.slicer = op25_repeater.fsk4_slicer_fb(levels)
        else:
            self.symbol_filter = filter.fir_filter_fff(1, coeffs)
            autotuneq = gr.msg_queue(2)
            self.fsk4_demod = op25.fsk4_demod_ff(autotuneq, self.if_rate,
                                                 self.symbol_rate)
            levels = [-2.0, 0.0, 2.0, 4.0]
            self.slicer = op25_repeater.fsk4_slicer_fb(levels)
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, "reaktor_hello_world_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')

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

        self.slicer = digital.binary_slicer_fb()
        self.deframer = sync_to_pdu_packed(packlen = 255,\
                                           sync = _syncword,\
                                           threshold = syncword_threshold)
        self.scrambler = pn9_scrambler()
        self.crop = cc11xx_packet_crop(True)
        self.crc = check_cc11xx_crc(self.options.verbose_crc)
        self.crop2 = cc11xx_remove_length()

        self.connect(self, self.slicer, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.scrambler, 'in'))
        self.msg_connect((self.scrambler, 'out'), (self.crop, 'in'))
        self.msg_connect((self.crop, 'out'), (self.crc, 'in'))
        self.msg_connect((self.crc, 'ok'), (self.crop2, 'in'))
        self.msg_connect((self.crop2, 'out'), (self, 'out'))
Example #11
0
	def __init__(self, dc_block_len=1000, samp_per_sym=10, rx_bit_inv=1):
		gr.hier_block2.__init__(
			self, "GMSK Demodulator",
			gr.io_signature(1, 1, gr.sizeof_float*1),
			gr.io_signature(1, 1, gr.sizeof_char*1),
		)

		##################################################
		# Parameters
		##################################################
		self.dc_block_len = dc_block_len
		self.samp_per_sym = samp_per_sym
		self.rx_bit_inv = rx_bit_inv

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 48000

		##################################################
		# Blocks
		##################################################
		self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
		self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
		self.dc_blocker_xx_0 = filter.dc_blocker_ff(dc_block_len, False)
		self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((rx_bit_inv, ))

		##################################################
		# Connections
		##################################################
		self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0, 0))
		self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0))
		self.connect((self.digital_binary_slicer_fb_0_0, 0), (self, 0))
		self.connect((self, 0), (self.dc_blocker_xx_0, 0))
Example #12
0
    def __init__(self, ebn0, nbits):
        gr.hier_block2.__init__(self, 'FSK',
            gr.io_signature(1, 1, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_char))

        samp_rate = 48e3
        sps = 5
        deviation = 5000
        bt = 1.0
        self.head = blocks.head(gr.sizeof_char, nbits)
        self.pack = blocks.pack_k_bits_bb(8)
        self.modulator = digital.gfsk_mod(
            samples_per_symbol = sps,
            sensitivity = 2*np.pi*deviation/samp_rate,
            bt = bt,
            verbose = False,
            log = False)
        
        spb = sps
        self.channel = channels.channel_model(np.sqrt(spb)/10**(ebn0/20), 0, 1.0, [1], RAND_SEED, False)

        self.demod = fsk_demodulator(samp_rate/sps, samp_rate, deviation = deviation, iq = True)
        self.slice = digital.binary_slicer_fb()

        self.connect(self, self.head, self.pack, self.modulator, self.channel,
                         self.demod, self.slice, self)
Example #13
0
File: rx.py Project: eti1/gr-btbr
    def set_decoder(self, chan, num):
        print("Add decoder for channel %d" % num)
        decoder = btbr.btdecode(num)
        # Both methods are quite equivalent
        if 1:
            quad_demod = analog.quadrature_demod_cf(self.samp_per_sym /
                                                    (2 * math.pi))
            clock_recov = digital.clock_recovery_mm_ff(
                omega=self.samp_per_sym,
                gain_omega=0.25 * self.gain_mu**2,
                mu=0.32,
                gain_mu=self.gain_mu,
                omega_relative_limit=0.005)
            binary_slicer = digital.binary_slicer_fb()

            self.connect(chan, quad_demod)
            self.connect(quad_demod, clock_recov)
            self.connect(clock_recov, binary_slicer)
            self.connect(binary_slicer, decoder)
            self.msg_connect((decoder, 'out'), (self.bthandler, 'in'))
        else:
            gfsk_demod = digital.gfsk_demod(
                samples_per_symbol=self.samp_per_sym,
                sensitivity=2 * math.pi / self.samp_per_sym,
                gain_mu=self.gain_mu,
                mu=0.32,
                omega_relative_limit=0.005,
                freq_error=0.0,
                verbose=False,
                log=False,
            )
            self.connect(chan, gfsk_demod)
            self.connect(gfsk_demod, decoder)
            self.msg_connect((decoder, 'out'), (self.bthandler, 'in'))
Example #14
0
    def __init__(self, dc_block_len=4, rx_gain=40):
        gr.top_block.__init__(self, "Uhd Adsb 6")

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

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

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

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

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.dc_blocker_xx_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_message_source_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0),
                     (self.adsb_framer_0, 0))
Example #15
0
    def __init__(self):
        gr.top_block.__init__(self)

        self.samp_rate = samp_rate = 1000000
        self.dump_freq = dump_freq = 2400490000

        self._u = uhd.usrp_source(
                device_addr="%default",
                io_type=uhd.io_type.COMPLEX_FLOAT32,
                num_channels=1)
                
        self._u.set_gain(0, 0)
        self._u.set_samp_rate(self.samp_rate)       


        treq = uhd.tune_request(self.dump_freq, 0)
        tr = self._u.set_center_freq(treq)

        if tr == None:
            sys.stderr.write('Failed to set center frequency\n')
            raise SystemExit, 1


        self.filter1 = gr.interp_fir_filter_ccf(1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76))
        self.squelch = gr.pwr_squelch_cc(-100, 0.001, 0, True)
        self.demod = gr.quadrature_demod_cf(1)
        
        self.sync = digital.clock_recovery_mm_ff(2, 0.0076562, 0.5, 0.175, 0.005)
        self.slicer = digital.binary_slicer_fb()
        self.detect_seq = digital.correlate_access_code_bb("01010101010101010101010101010101", 1)
        self.dump = flysky.dumpsync()

        self.connect(self._u,self.filter1,self.squelch,self.demod,self.sync,self.slicer,self.detect_seq, self.dump)
    def __init__(self, syncword_threshold=None, nrzi=True, options=None):
        gr.hier_block2.__init__(
            self,
            'astrocast_fx25_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')

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

        self.slicer = digital.binary_slicer_fb()
        if nrzi:
            self.nrzi = nrzi_decode()
        self.deframer = sync_to_pdu_packed(
            packlen=255, sync=_syncword, threshold=syncword_threshold)
        self.reflect = reflect_bytes()
        self.rs = decode_rs(True, 1)
        self.crc = check_astrocast_crc(self.options.verbose_crc)

        blocks = [self, self.slicer]
        if nrzi:
            blocks.append(self.nrzi)
        blocks.append(self.deframer)

        self.connect(*blocks)
        self.msg_connect((self.deframer, 'out'), (self.reflect, 'in'))
        self.msg_connect((self.reflect, 'out'), (self.rs, 'in'))
        self.msg_connect((self.rs, 'out'), (self.crc, 'in'))
        self.msg_connect((self.crc, 'ok'), (self, 'out'))
Example #17
0
    def __init__(self, interpolation=36, decimation=125):
        gr.hier_block2.__init__(self, "indri_smartnet_control_channel",
                                gr.io_signature(1,1,gr.sizeof_float),
                                gr.io_signature(1,1,1))
        
        # Figure out where zero should be, despite RTL-SDR drift
        avglen = 1000 # should be big enough to catch drifts
        offset = blocks.moving_average_ff(avglen, 1.0/avglen, 40*avglen)
        differential = blocks.sub_ff()
        self.connect(self, (differential,0))
        self.connect(self, offset)
        self.connect(offset, (differential,1))

        # sample off the offsets to adjust tuning
        offset_sampler = blocks.keep_one_in_n(gr.sizeof_float, 10*avglen)
        offset_mag_block = blocks.probe_signal_f()
        self.offset_mag = offset_mag_block
        self.connect(offset, offset_sampler, offset_mag_block)

        rational_resampler = gr_filter.rational_resampler_fff(
            interpolation=interpolation,
            decimation=decimation,
            taps=None,
            fractional_bw=0.45,
        )


        slicer = digital.binary_slicer_fb()

        self.connect(differential, rational_resampler, slicer, self)
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(
            self,
            'swiatowid_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')

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

        self.slicer = digital.binary_slicer_fb()
        self.deframer = sync_to_pdu_packed(
            packlen=8200, sync=_syncword, threshold=syncword_threshold)
        self.reflect = reflect_bytes()
        self.crop = swiatowid_packet_crop()
        self.split = swiatowid_packet_split()
        self.rs = decode_rs(8, 0x11d, 0, 1, 10, 1)

        self.connect(self, self.slicer, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.reflect, 'in'))
        self.msg_connect((self.reflect, 'out'), (self.crop, 'in'))
        self.msg_connect((self.crop, 'out'), (self.split, 'in'))
        self.msg_connect((self.split, 'out'), (self.rs, 'in'))
        self.msg_connect((self.rs, 'out'), (self, 'out'))
Example #19
0
    def __init__(self):
        gr.top_block.__init__(self, "Gotenna Rx Usrp")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000000
        self.fsk_deviation_hz = fsk_deviation_hz = 12500
        self.chan_spacing = chan_spacing = 500000
        self.baud_rate = baud_rate = 24000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", '')),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(915000000, 0)
        self.uhd_usrp_source_0.set_gain(5, 0)
        self.uhd_usrp_source_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None)
        self.gotenna_sink = gotenna_sink.blk()
        self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(
            digital.TED_DANDREA_AND_MENGALI_GEN_MSK,
            float(chan_spacing) / baud_rate / 4,
            0.05,
            1.5,
            1.0,
            0.001 * float(chan_spacing) / baud_rate / 4,
            1,
            digital.constellation_bpsk().base(),
            digital.IR_MMSE_8TAP,
            128,
            [])
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*1, samp_rate // chan_spacing)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(chan_spacing/(2*math.pi*fsk_deviation_hz))



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.gotenna_sink, 0))
        self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_symbol_sync_xx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_keep_one_in_n_0, 0))
Example #20
0
    def __init__(self, syncword_threshold = None, options = None):
        gr.hier_block2.__init__(self, "eseo_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')

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

        self.slicer = digital.binary_slicer_fb()
        self.deframer = sync_to_pdu_packed(packlen = 257,\
                                    sync = _syncword,\
                                    threshold = syncword_threshold)
        self.crop = eseo_packet_crop(drop_rs = False)
        self.rs = decode_rs_general(0x11d, 1, 1, 16, self.options.verbose_rs)
        self.line = eseo_line_decoder()
        self.crc = check_eseo_crc(self.options.verbose_crc)
        
        self.connect(self, self.slicer, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.crop, 'in'))
        self.msg_connect((self.crop, 'out'), (self.rs, 'in'))
        self.msg_connect((self.rs, 'out'), (self.line, 'in'))
        self.msg_connect((self.line, 'out'), (self.crc, 'in'))
        self.msg_connect((self.crc, 'ok'), (self, 'out'))
Example #21
0
	def __init__(self, options, filename):
		gr.top_block.__init__(self)

		inf_str = None
		symbol_rate = 152.34e3
		sample_rate = 1e6
		
		#if len(options) != 0:
		#	inf_str = args[0]

		squelch = analog.pwr_squelch_cc(float(options.squelch), 0.1, 0, True)
		demod = analog.quadrature_demod_cf(1.0)
		cr = digital.clock_recovery_mm_ff(sample_rate/symbol_rate, 0.00765625, 0, 0.175, 0.005)
		slicer = digital.binary_slicer_fb()
		corr = digital.correlate_access_code_bb(AC, 3)
		sink = sniffer()

		if False:
			print "Reading from: " + inf_str
			src = blocks.file_source(gr.sizeof_gr_complex, inf_str, False)
		
		else:
			freqs = {
				'AA':917.0e6, 'AB':913.0e6, 'AC':914.0e6, 'AD':915.0e6,
				'BA':916.0e6, 'BB':919.0e6, 'BC':920.0e6, 'BD':921.0e6,
				'CA':922.0e6, 'CB':923.0e6, 'CC':907.0e6, 'CD':908.0e6,
				'DA':905.5e6, 'DB':909.0e6, 'DC':911.0e6, 'DD':910.0e6}

			frequency = freqs[options.channel]
			print "Channel: " + options.channel + " (" + str(frequency/1e6) + "MHz)"

			# Create a UHD device source
			src = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', "sc16", args=""))

			# Set the subdevice spec
			if(options.spec):
				src.set_subdev_spec(options.spec, 0)

			# Set the antenna
			if(options.antenna):
				src.set_antenna(options.antenna, 0)

			# Set receiver sample rate
			src.set_samp_rate(options.samp_rate)

			# Set receive daughterboard gain
			if options.gain is None:
				g = src.get_gain_range()
				options.gain = float(g.start()+g.stop())/2
				print "Using mid-point gain of", options.gain, "(", g.start(), "-", g.stop(), ")"
				src.set_gain(options.gain)

			# Set frequency (tune request takes lo_offset)
			treq = uhd.tune_request(frequency)
			tr = src.set_center_freq(treq)
			if tr == None:
				sys.stderr.write('Failed to set center frequency\n')
				raise SystemExit, 1

		self.connect(src, squelch, demod, cr, slicer, corr, sink)
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(
            self,
            'fossasat_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')

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

        self.slicer = digital.binary_slicer_fb()
        self.sync = sync_to_pdu_packed(
            packlen=255, sync=_syncword, threshold=syncword_threshold)
        self.reflect_1 = reflect_bytes()
        self.scrambler = pn9_scrambler()
        self.reflect_2 = reflect_bytes()
        self.crop = sx12xx_packet_crop(crc_len=2)
        self.crc = sx12xx_check_crc(
            verbose=self.options.verbose_crc, initial=0x1D0F, final=0xFFFF)
        self.remove_length = pdu_head_tail(3, 1)

        self.connect(self, self.slicer, self.sync)
        self.msg_connect((self.sync, 'out'), (self.reflect_1, 'in'))
        self.msg_connect((self.reflect_1, 'out'), (self.scrambler, 'in'))
        self.msg_connect((self.scrambler, 'out'), (self.reflect_2, 'in'))
        self.msg_connect((self.reflect_2, 'out'), (self.crop, 'in'))
        self.msg_connect((self.crop, 'out'), (self.crc, 'in'))
        self.msg_connect((self.crc, 'ok'), (self.remove_length, 'in'))
        self.msg_connect((self.remove_length, 'out'), (self, 'out'))
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, 'aalto1_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')

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

        self.slicer = digital.binary_slicer_fb()
        self.deframer = sync_to_pdu_packed(packlen=255,
                                           sync=syncword,
                                           threshold=syncword_threshold)
        self.scrambler = pn9_scrambler()
        self.crop = cc11xx_packet_crop(True)
        self.crc = check_crc16_ccitt(self.options.verbose_crc)
        self.crop2 = pdu_head_tail(3, 1)

        self.connect(self, self.slicer, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.scrambler, 'in'))
        self.msg_connect((self.scrambler, 'out'), (self.crop, 'in'))
        self.msg_connect((self.crop, 'out'), (self.crc, 'in'))
        self.msg_connect((self.crc, 'ok'), (self.crop2, 'in'))
        self.msg_connect((self.crop2, 'out'), (self, 'out'))
Example #24
0
	def __init__(self, samplerate, symbolrate = SYMRATE, channel_str = None,
		sendmsg = True, debug = False,
		samplepersymbol = SPS, fmdeviation = FM_DEVIATION
		):

		gr.hier_block2.__init__(self, "pocsag",
			gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, 1))

		self.samplerate = samplerate
		self.symbolrate = symbolrate
		self.sendmsg = sendmsg
		self.debug = debug
		self.samplepersymbol = samplepersymbol
		self.fmdeviation = fmdeviation

		self.fractional_interpolator = gr.fractional_interpolator_cc(0, 1.0 * samplerate / (symbolrate * samplepersymbol))
		self.quadrature_demod = gr.quadrature_demod_cf((symbolrate * samplepersymbol) / (fmdeviation * 4.0))
		self.low_pass_filter = gr.fir_filter_fff(1, gr.firdes.low_pass(1, symbolrate * samplepersymbol, symbolrate * 2, symbolrate / 2.0, gr.firdes.WIN_HAMMING, 6.76))
		self.digital_clock_recovery_mm = digital.clock_recovery_mm_ff(samplepersymbol, 0.03 * 0.03 * 0.3, 0.4, 0.03, 1e-4)
		self.digital_binary_slicer_fb = digital.binary_slicer_fb()
		self.pktdecoder = pocsag_pktdecoder(channel_str = channel_str, sendmsg = sendmsg, debug = debug)
		self.connect(self,
			self.fractional_interpolator,
			self.quadrature_demod,
			self.low_pass_filter,
			self.digital_clock_recovery_mm,
			self.digital_binary_slicer_fb,
			self.pktdecoder,
			self)
Example #25
0
    def __init__(self, ebn0, nbits):
        gr.hier_block2.__init__(self, 'BPSK',
            gr.io_signature(1, 1, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_char))

        samp_rate = 48e3
        sps = 5
        self.head = blocks.head(gr.sizeof_char, nbits)
        self.pack = blocks.pack_k_bits_bb(8)
        self.bpsk_constellation = digital.constellation_bpsk().base()
        self.modulator = digital.generic_mod(
            constellation = self.bpsk_constellation,
            differential = False,
            samples_per_symbol = sps,
            pre_diff_code = True,
            excess_bw = 0.35,
            verbose = False,
            log = False)
        
        spb = sps
        self.channel = channels.channel_model(np.sqrt(spb)/10**(ebn0/20), 0, 1.0, [1], RAND_SEED, False)

        self.demod = bpsk_demodulator(samp_rate/sps, samp_rate, iq = True)
        self.slice = digital.binary_slicer_fb()

        self.connect(self, self.head, self.pack, self.modulator, self.channel,
                         self.demod, self.slice, self)
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.variable_slider_0 = variable_slider_0 = .846
        self.test = test = .005
        self.shift = shift = .906
        self.samp_rate_0 = samp_rate_0 = 1.2e6
        self.samp_rate = samp_rate = 1.2e6/4
        self.pows = pows = 1.3
        self.lpf = lpf = .724
        self.go = go = 0.564
        self.gm = gm = 1.61
        self.centre_freq = centre_freq = 439.95e6

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.rtlsdr_source_0.set_sample_rate(samp_rate_0)
        self.rtlsdr_source_0.set_center_freq(439.9e6, 0)
        self.rtlsdr_source_0.set_freq_corr(0, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(2, 0)
        self.rtlsdr_source_0.set_gain_mode(False, 0)
        self.rtlsdr_source_0.set_gain(20, 0)
        self.rtlsdr_source_0.set_if_gain(10, 0)
        self.rtlsdr_source_0.set_bb_gain(10, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_1 = filter.fir_filter_fff(10, firdes.low_pass(
        	1, samp_rate, 2.56e3*lpf, (2.56e3/2)*lpf, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (firdes.low_pass_2(1,samp_rate_0,100e3,50e3,40)), 0, samp_rate_0)
        self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_ff(11.6439*(1+test), 0.25*0.175*0.175*go, 0.5, 0.175*gm, 0.005*variable_slider_0)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-12*shift, ))
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=9000,
        	server=False,
        )
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40*pows, .001, 0, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))    
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_1, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blks2_tcp_sink_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))    
Example #27
0
    def __init__(self):
        gr.top_block.__init__(self, "Quetzal-1 Receiver")

        ##################################################
        # Variables
        ##################################################
        self.symb_rate = symb_rate = 4800
        self.samp_rate = samp_rate = 48000
        self.samp_per_sym = samp_per_sym = int(samp_rate/symb_rate)
        self.log = log = 0
        self.homedir = homedir = ""
        self.hhmmss = hhmmss = ""
        self.gain_mu = gain_mu = 0.175*3
        self.filename_raw_beacon = filename_raw_beacon = ""
        self.filename_parsed_beacon = filename_parsed_beacon = ""
        self.filename_image_metadata = filename_image_metadata = ""
        self.filename_image = filename_image = ""
        self.do_once = do_once = 0
        self.data_rate = data_rate = 4800
        self.count = count = 0
        self.center_freq = center_freq = 437.2e6

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, 'tcp://127.0.0.1:1502', 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 = satellites.hdlc_deframer(check_fcs=True, max_length=10000)
        self.quetzal1_parse = quetzal1_parse.quetzal1_parse(filename_parsed_beacon='', filename_raw_beacon='')
        self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, 48000, 2400, 2000, firdes.WIN_HAMMING, 6.76))
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(10, 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('/home/dan/Documents/repos/gr-quetzal1/recordings/example_beacon_quetzal1.wav', False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, ))



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self.satellites_strip_ax25_header_0, 'in'))
        self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.quetzal1_parse, 'in'))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_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, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0), (self.satellites_hdlc_deframer_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0, 0))
Example #28
0
File: ec3k.py Project: asdil12/ec3k
	def _setup_top_block(self):

		self.tb = gr.top_block()

		samp_rate = 96000
		oversample = 10
		center_freq = 868.280e6

		# Radio receiver, initial downsampling
		args = str("nchan=1 rtl=%s,buffers=16,offset_tune=1" % self.device)
		osmosdr_source = osmosdr.source_c(args=args)
		osmosdr_source.set_sample_rate(samp_rate*oversample)
		osmosdr_source.set_center_freq(center_freq, 0)
		osmosdr_source.set_freq_corr(0, 0)
		osmosdr_source.set_gain_mode(1, 0)
		osmosdr_source.set_gain(0, 0)

		low_pass_filter = gr.fir_filter_ccf(oversample, 
				firdes.low_pass(1, samp_rate*oversample, 90e3, 8e3, firdes.WIN_HAMMING, 6.76))

		self.tb.connect((osmosdr_source, 0), (low_pass_filter, 0))

		# Squelch
		self.noise_probe = gr.probe_avg_mag_sqrd_c(0, 1.0/samp_rate/1e2)
		self.squelch = gr.simple_squelch_cc(self.noise_level, 1)

		noise_probe_thread = threading.Thread(target=self._noise_probe_thread)
		noise_probe_thread.start()
		self.threads.append(noise_probe_thread)

		self.tb.connect((low_pass_filter, 0), (self.noise_probe, 0))
		self.tb.connect((low_pass_filter, 0), (self.squelch, 0))

		# FM demodulation
		quadrature_demod = gr.quadrature_demod_cf(1)

		self.tb.connect((self.squelch, 0), (quadrature_demod, 0))

		# Binary slicing, transformation into capture-compatible format

		add_offset = gr.add_const_vff((-1e-3, ))

		binary_slicer = digital.binary_slicer_fb()

		char_to_float = gr.char_to_float(1, 1)

		multiply_const = gr.multiply_const_vff((255, ))

		float_to_uchar = gr.float_to_uchar()

		pipe_sink = gr.file_sink(gr.sizeof_char*1, self.pipe)
		pipe_sink.set_unbuffered(False)

		self.tb.connect((quadrature_demod, 0), (add_offset, 0))
		self.tb.connect((add_offset, 0), (binary_slicer, 0))
		self.tb.connect((binary_slicer, 0), (char_to_float, 0))
		self.tb.connect((char_to_float, 0), (multiply_const, 0))
		self.tb.connect((multiply_const, 0), (float_to_uchar, 0))
		self.tb.connect((float_to_uchar, 0), (pipe_sink, 0))
Example #29
0
    def __init__(self):
        gr.top_block.__init__(self, "Gotenna Rx Hackrf")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 500000
        self.fsk_deviation_hz = fsk_deviation_hz = 12500
        self.chan_spacing = chan_spacing = 500000
        self.baud_rate = baud_rate = 24000

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=1,
                decimation=4,
                taps=None,
                fractional_bw=None)
        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + ''
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(915000000, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_gain(1, 0)
        self.osmosdr_source_0.set_if_gain(16, 0)
        self.osmosdr_source_0.set_bb_gain(1, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(26000000, 0)
        self.gotenna_sink = gotenna_sink.blk()
        self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(
            digital.TED_DANDREA_AND_MENGALI_GEN_MSK,
            float(chan_spacing) / baud_rate / 4,
            0.05,
            1.5,
            1.0,
            0.001 * float(chan_spacing) / baud_rate / 4,
            1,
            digital.constellation_bpsk().base(),
            digital.IR_MMSE_8TAP,
            128,
            [])
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(512, True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(chan_spacing/(2*math.pi*fsk_deviation_hz))



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.gotenna_sink, 0))
        self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.osmosdr_source_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_symbol_sync_xx_0, 0))
Example #30
0
def test_binary_slicer_fb():
    top = gr.top_block()
    src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2))
    slicer = digital.binary_slicer_fb()
    probe = blocks.probe_rate(gr.sizeof_char)
    top.connect(src, slicer, probe)

    return top, probe
def test_binary_slicer_fb():
    top = gr.top_block()
    src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2))
    slicer = digital.binary_slicer_fb()
    probe = blocks.probe_rate(gr.sizeof_char)
    top.connect(src, slicer, probe)

    return top, probe
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000
        self.dec_rate = dec_rate = 2

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(1000000)
        self.uhd_usrp_source_0.set_center_freq(2400490000, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.low_pass_filter_0_0 = gr.interp_fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = gr.fir_filter_fff(
            1,
            firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING,
                            6.76))
        self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1)
        self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_cc(-100, 0.001, 0, True)
        self.flysky_dumpsync_0 = flysky.dumpsync()
        self.digital_correlate_access_code_bb_0_1 = digital.correlate_access_code_bb(
            "010101010101010101010101010101010101010001110101", 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2, 0.0076562, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.gr_quadrature_demod_cf_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_pwr_squelch_xx_0, 0),
                     (self.gr_quadrature_demod_cf_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.gr_pwr_squelch_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_correlate_access_code_bb_0_1, 0))
        self.connect((self.digital_correlate_access_code_bb_0_1, 0),
                     (self.flysky_dumpsync_0, 0))
Example #33
0
    def __init__(self):
        gr.top_block.__init__(self, "Afsk Csu")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100
        self.bps = bps = 1200
        self.window_len = window_len = (samp_rate / bps) * 2
        self.dec = dec = 4
        self.window_sync = window_sync = signal.windows.hann(116)
        self.window = window = signal.windows.cosine(window_len)
        self.dec_samp_rate = dec_samp_rate = samp_rate / dec
        self.bpf_width = bpf_width = bps + 200
        self.bpf_trans = bpf_trans = 200

        ##################################################
        # Blocks
        ##################################################
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_fcf(
            dec, (window), (2200 + 1200) / 2, samp_rate)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(
            9.1875, 0.28, 0, 0.024, 0.01)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/tmp/gs-sample.wav', False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.blocks_file_sink_1_0_1_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/tmp/gs-sample.binary', False)
        self.blocks_file_sink_1_0_1_0.set_unbuffered(True)
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, samp_rate, 1700 - bpf_width, 1700 + bpf_width,
                             bpf_trans, firdes.WIN_HAMMING, 6.76))
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            (dec_samp_rate / bps) / (math.pi * 0.5))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_file_sink_1_0_1_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
Example #34
0
	def __init__(self, source_data, sampling_rate, carrier_hz, symbol_rate, deviation, access_code):
		super(FSKDemodulator, self).__init__()

		self._decoded = {}

		self._carrier_hz = carrier_hz
		self._deviation = deviation
		self._access_code = access_code

		samp_rate = sampling_rate
		#symbol_rate = 9920
		self.samples_per_symbol = float(samp_rate) / symbol_rate

		omega = self.samples_per_symbol * 1.0
		mu = 0.0
		gain_mu = 0.2
		gain_omega = 0.25 * gain_mu * gain_mu
		omega_relative_limit = 0.001

		tap_count = int(math.floor(self.samples_per_symbol))

		hz_n = (carrier_hz - deviation)
		taps_n = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_n / samp_rate)
		hz_p = (carrier_hz + deviation)
		taps_p = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_p / samp_rate)

		#source = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False)
		# Concatenate data to compensate for correlate_access_code_bb latency
		source_data_padding_count = int(math.ceil(self.samples_per_symbol * 64))
		source_data = numpy.concatenate((source_data, numpy.zeros((source_data_padding_count,), dtype=numpy.complex64)))
		source = NumpySource(source_data)

		filter_n = filter.fir_filter_ccc(1, taps_n.tolist())
		self.connect(source, filter_n)
		filter_p = filter.fir_filter_ccc(1, taps_p.tolist())
		self.connect(source, filter_p)

		mag_n = blocks.complex_to_mag(1)
		self.connect(filter_n, mag_n)
		mag_p = blocks.complex_to_mag(1)
		self.connect(filter_p, mag_p)

		sub_pn = blocks.sub_ff()
		self.connect(mag_p, (sub_pn, 0))
		self.connect(mag_n, (sub_pn, 1))

		clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)
		self.connect(sub_pn, clock_recovery)

		slicer = digital.binary_slicer_fb()
		self.connect(clock_recovery, slicer)

		access_code_correlator = digital.correlate_access_code_bb(access_code, 0)
		self.connect(slicer, access_code_correlator)

		self.packetizer = Packetizer()
		self.connect(access_code_correlator, self.packetizer)
Example #35
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 40000
        self.tuner = tuner = 868.95e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing /
                                          2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 200000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0_1 = osmosdr.source(args="numchan=" + str(1) +
                                                 " " + '')
        self.osmosdr_source_0_1.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_0_1.set_center_freq(tuner + freq_offset, 0)
        self.osmosdr_source_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_0_1.set_gain_mode(False, 0)
        self.osmosdr_source_0_1.set_gain(10, 0)
        self.osmosdr_source_0_1.set_if_gain(24, 0)
        self.osmosdr_source_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_0_1.set_antenna('', 0)
        self.osmosdr_source_0_1.set_bandwidth(0, 0)
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            1,
            firdes.low_pass(1, samp_rate, cutoff, width, firdes.WIN_BLACKMAN,
                            6.76), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_char * 1,
            'capture_' + datetime.today().strftime('%Y%m%d%H%M%S'), False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_0_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 0))
Example #36
0
	def __init__(self, source_data, sampling_rate, carrier_hz, symbol_rate, deviation, access_code):
		super(FSKDemodulator, self).__init__()

		self._decoded = {}

		self._carrier_hz = carrier_hz
		self._deviation = deviation
		self._access_code = access_code

		samp_rate = sampling_rate
		#symbol_rate = 9920
		self.samples_per_symbol = float(samp_rate) / symbol_rate

		omega = self.samples_per_symbol * 1.0
		mu = 0.0
		gain_mu = 0.2
		gain_omega = 0.25 * gain_mu * gain_mu
		omega_relative_limit = 0.001

		tap_count = int(math.floor(self.samples_per_symbol))

		hz_n = (carrier_hz - deviation)
		taps_n = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_n / samp_rate)
		hz_p = (carrier_hz + deviation)
		taps_p = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_p / samp_rate)

		#source = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False)
		# Concatenate data to compensate for correlate_access_code_bb latency
		source_data_padding_count = int(math.ceil(self.samples_per_symbol * 64))
		source_data = numpy.concatenate((source_data, numpy.zeros((source_data_padding_count,), dtype=numpy.complex64)))
		source = NumpySource(source_data)

		filter_n = filter.fir_filter_ccc(1, taps_n.tolist())
		self.connect(source, filter_n)
		filter_p = filter.fir_filter_ccc(1, taps_p.tolist())
		self.connect(source, filter_p)

		mag_n = blocks.complex_to_mag(1)
		self.connect(filter_n, mag_n)
		mag_p = blocks.complex_to_mag(1)
		self.connect(filter_p, mag_p)

		sub_pn = blocks.sub_ff()
		self.connect(mag_p, (sub_pn, 0))
		self.connect(mag_n, (sub_pn, 1))

		clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)
		self.connect(sub_pn, clock_recovery)

		slicer = digital.binary_slicer_fb()
		self.connect(clock_recovery, slicer)

		access_code_correlator = digital.correlate_access_code_bb(access_code, 0)
		self.connect(slicer, access_code_correlator)

		self.packetizer = Packetizer()
		self.connect(access_code_correlator, self.packetizer)
Example #37
0
    def __init__(self,
                 samp_rate=1600000,
                 samp_per_sym=16,
                 freq_error=-0.0025000):
        gr.hier_block2.__init__(
            self,
            "Wireless M-Bus Demod",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_char * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.samp_rate = samp_rate
        self.samp_per_sym = samp_per_sym
        self.freq_error = freq_error

        ##################################################
        # Variables
        ##################################################
        self.cutoff = cutoff = 120e3
        self.chip_rate = chip_rate = samp_rate / samp_per_sym

        ##################################################
        # Blocks
        ##################################################
        self.low_pass_filter_0 = gnuradio.filter.fir_filter_ccf(
            1,
            gnuradio.filter.firdes.low_pass(1, samp_rate, cutoff, cutoff / 2,
                                            gnuradio.filter.firdes.WIN_HAMMING,
                                            6.76))
        self.gr_sub_xx_0 = blocks.sub_ff(1)
        self.gr_single_pole_iir_filter_xx_0 = gnuradio.filter.single_pole_iir_filter_ff(
            0.0512 / samp_per_sym, 1)
        self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samp_per_sym * (1 + freq_error), .25 * 0.06 * 0.06 * 4, 0.5,
            0.06 * 2, 0.002 * 2)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_quadrature_demod_cf_0, 0),
                     (self.gr_single_pole_iir_filter_xx_0, 0))
        self.connect((self.gr_single_pole_iir_filter_xx_0, 0),
                     (self.gr_sub_xx_0, 1))
        self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_sub_xx_0, 0))
        self.connect((self.gr_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.gr_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self, 0))
        self.connect((self, 0), (self.low_pass_filter_0, 0))
Example #38
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 200000
        self.width = width = 20000
        self.tuner = tuner = 434e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing /
                                          2) + (channel_spacing * .1)
        self.demodgain = demodgain = 4
        self.cutoff = cutoff = 134000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner + freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)

        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(
            1, (firdes.low_pass(1, samp_rate, cutoff, width,
                                firdes.WIN_BLACKMAN, 6.76)), -freq_offset,
            samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0),
                     (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
Example #39
0
    def __init__(self, callsign='', invert=1, ip='::', latitude=0, longitude=0, port=7355, recstart=''):
        gr.top_block.__init__(self, "TW-1B decoder")

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

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = 6
        self.gain_mu = gain_mu = 0.175*3
        self.access_code = access_code = "10010011000010110101000111011110"

        ##################################################
        # Blocks
        ##################################################
        self.sync_to_pdu_packed_0 = sync_to_pdu_packed(
            packlen=256,
            sync=access_code,
            threshold=threshold,
        )
        self.sids_submit_0 = sids.submit('http://tlm.pe0sat.nl/tlmdb/frame_db.php', 40927, callsign, longitude, latitude, recstart)
        self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, 48000, 2400, 2000, firdes.WIN_HAMMING, 6.76))
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10, 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short*1, ip, port, 1472, False)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert*10, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.ax100_gomx3_rs_decode_0 = ax100.gomx3_rs_decode(False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.sids_print_timestamp_0, 'in'))    
        self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.sids_submit_0, 'in'))    
        self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.msg_connect((self.sync_to_pdu_packed_0, 'out'), (self.ax100_gomx3_rs_decode_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.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_descrambler_bb_0, 0), (self.sync_to_pdu_packed_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
Example #40
0
    def __init__(self, freq, ppm, osmosdr_args):
        gr.top_block.__init__(self, "gr_omnicon")

        self.msgq_out = blocks_message_sink_0_msgq_out = gr.msg_queue(0)
        ##################################################
        # Variables
        ##################################################
        self.xlate_bandwidth = xlate_bandwidth = 15.0e3
        self.samp_rate = samp_rate = 1.2e6
        self.xlate_decimation = xlate_decimation = int(samp_rate/(xlate_bandwidth*3.2))
        self.baud_rate = baud_rate = 2400
        self.lowpass_decimation = lowpass_decimation = int((samp_rate/xlate_decimation)/(baud_rate*4))
        self.freq_offset = freq_offset = 250000
        self.sps = sps = (samp_rate/xlate_decimation/lowpass_decimation)/baud_rate
        self.omega_rel_limit = omega_rel_limit = ((2450.0-2400.0)/2400.0)
        self.gain_omega = gain_omega = 0
        self.gain_mu = gain_mu = 0.1
        self.freq_tune = freq_tune = freq-freq_offset

        ##################################################
        # Blocks
        ##################################################
        self.rtlsdr_source_0 = osmosdr.source(args=osmosdr_args)
        self.rtlsdr_source_0.set_sample_rate(samp_rate)
        self.rtlsdr_source_0.set_center_freq(freq_tune, 0)
        self.rtlsdr_source_0.set_freq_corr(ppm, 0)
        self.rtlsdr_source_0.set_dc_offset_mode(0, 0)
        self.rtlsdr_source_0.set_iq_balance_mode(0, 0)
        self.rtlsdr_source_0.set_gain_mode(True, 0)
        self.rtlsdr_source_0.set_gain(42, 0)
        self.rtlsdr_source_0.set_if_gain(10, 0)
        self.rtlsdr_source_0.set_bb_gain(10, 0)
        self.rtlsdr_source_0.set_antenna("", 0)
        self.rtlsdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_fff(lowpass_decimation, firdes.low_pass(
        	1, samp_rate/xlate_decimation, baud_rate, (baud_rate)/10, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decimation, (firdes.low_pass(1, samp_rate, xlate_bandwidth, xlate_bandwidth/20 )), freq_offset, samp_rate)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps, gain_omega, 0.5, gain_mu, omega_rel_limit)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(500, True)
        self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char*1, blocks_message_sink_0_msgq_out, False)
        self.analog_quadrature_demod_cf_0_0_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0_0_0, 0), (self.dc_blocker_xx_0, 0))
        #self.connect((self.blocks_message_sink_0, 'msg'), (self, 0))
        self.connect((self.dc_blocker_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "grc_cc1111_test_local_loop")

        ##################################################
        # Variables
        ##################################################
        self.symbole_rate = symbole_rate = 80000
        self.samp_rate = samp_rate = 2e6
        self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate)
        self.preamble = preamble = '0101010101010101'
        self.myqueue_out = myqueue_out = gr.msg_queue(2)
        self.myqueue_in = myqueue_in = gr.msg_queue(2)
        self.bit_per_sym = bit_per_sym = 1
        self.access_code = access_code = '11010011100100011101001110010001'

        ##################################################
        # Blocks
        ##################################################
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=int(samp_per_sym),
        	bt=0.5,
        	verbose=False,
        	log=False,
        )
        self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb(access_code, 1)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb()
        self.cc1111_cc1111_packet_encoder_0 = cc1111.cc1111_packet_mod_base(cc1111.cc1111_packet_encoder(
                        samples_per_symbol=samp_per_sym,
                        bits_per_symbol=bit_per_sym,
                        preamble=preamble,
                        access_code=access_code,
                        pad_for_usrp=True,
        		do_whitening=True,
        		add_crc=True
                ),
        	source_queue=myqueue_in
        	)
        self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder(myqueue_out,True, True, False, True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0))
        self.connect((self.digital_gmsk_mod_0, 0), (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0))
        self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.cc1111_cc1111_packet_encoder_0, 0), (self.blocks_throttle_0, 0))
	def __init__(self):
		gr.top_block.__init__(self, "FSK Demod Demo")

		# Variables
		self.symbol_rate = symbol_rate = 125e3
		self.samp_rate = samp_rate = symbol_rate
		self.f_center = f_center = 868e6
		self.sps = sps = 2
		self.sensitivity = sensitivity = (pi / 2) / sps
		self.alpha = alpha = 0.0512/sps
		self.bandwidth = bandwidth = 100e3

		# Blocks
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_source_0.set_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(f_center, 0)
		self.uhd_usrp_source_0.set_gain(0, 0)
		self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0)

		self.fm_demod = gr.quadrature_demod_cf(1 / sensitivity)
		
		self.freq_offset = gr.single_pole_iir_filter_ff(alpha)
		self.sub = gr.sub_ff()
		self.add = gr.add_ff()
		self.multiply = gr.multiply_ff()
		self.invert = gr.multiply_const_vff((-1, ))

		# recover the clock
		omega = sps
		gain_mu = 0.03
		mu = 0.5
		omega_relative_limit = 0.0002
		freq_error = 0.0
		gain_omega = .25 * gain_mu * gain_mu        # critically damped
		self.clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)

		self.slice = digital.binary_slicer_fb()
		self.sink = gr.vector_sink_b(1)
		self.file_sink = gr.file_sink(gr.sizeof_char, 'fsk_dump.log')

		# Connections
		self.connect(self.fm_demod, (self.add, 0))
		self.connect(self.fm_demod, self.freq_offset, (self.add, 1))
		self.connect(self.uhd_usrp_source_0, self.fm_demod)
		self.connect(self.add, self.clock_recovery, self.invert, self.slice, self.file_sink)
		self.connect(self.slice, self.sink)
Example #43
0
	def __init__(self, options):
		gr.hier_block2.__init__(self, "fsk_demod",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(1, 1, gr.sizeof_char)) # Output signature

		self._syms_per_sec = options.syms_per_sec # ditto
		self._samples_per_second = options.samples_per_second
		self._gain_mu = options.gain_mu # for the clock recovery block
		self._mu = options.mu
		self._omega_relative_limit = options.omega_relative_limit

		self._freqoffset = options.offset

		#first bring that input stream down to a manageable level, let's say 3 samples per bit.
		self._clockrec_oversample = 3

		self._downsampletaps = gr.firdes.low_pass(1, self._samples_per_second, 10000, 1000, firdes.WIN_HANN)

		self._decim = int(self._samples_per_second / (self._syms_per_sec * self._clockrec_oversample))

		print "Demodulator decimation: %i" % (self._decim,)
		self._downsample = gr.freq_xlating_fir_filter_ccf(self._decim, #decimation
														  self._downsampletaps, #taps
														  self._freqoffset, #freq offset
														  self._samples_per_second) #sampling rate

		#using a pll to demod gets you a nice IIR LPF response for free
		self._demod = gr.pll_freqdet_cf(2.0 / self._clockrec_oversample, #gain alpha, rad/samp
										 2*pi/self._clockrec_oversample,  #max freq, rad/samp
										-2*pi/self._clockrec_oversample)  #min freq, rad/samp

		self._sps = float(self._samples_per_second)/self._decim/self._syms_per_sec

		#band edge filter FLL with a low bandwidth is very good
		#at synchronizing to continuous FSK signals
		self._carriertrack = digital.fll_band_edge_cc(self._sps,
													  0.6, #rolloff factor
													  64,  #taps
													  1.0) #loop bandwidth

		print "Samples per symbol: %f" % (self._sps,)
		self._softbits = digital.clock_recovery_mm_ff(self._sps,
												 0.25*self._gain_mu*self._gain_mu, #gain omega, = mu/2 * mu_gain^2
												 self._mu, #mu (decision threshold)
												 self._gain_mu, #mu gain
												 self._omega_relative_limit) #omega relative limit

		self._subtract = gr.sub_ff()

		self._slicer = digital.binary_slicer_fb()

		self.connect(self, self._downsample, self._carriertrack, self._demod, self._softbits, self._slicer, self)
Example #44
0
    def __init__(self):
        gr.top_block.__init__(self, "CC1101 Burst Detector")

        def rx_callback():
            print "Callback Fired"

        # Variables
        self.samp_rate = samp_rate = 250e3
        self.f_center = f_center = 510e6
        self.bandwidth = bandwidth = 125e3
        self.gain = gain = 15
        self.sps = sps = 2

        # Blocks
        self.uhd_src = uhd.usrp_source(
            device_addr="serial=E8R10Z2B1", #cheetara
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )

        self.uhd_src.set_samp_rate(samp_rate)
        self.uhd_src.set_center_freq(f_center, 0)
        self.uhd_src.set_gain(gain, 0)
        self.uhd_src.set_antenna("TX/RX", 0)
        self.uhd_src.set_bandwidth(bandwidth, 0)

        self.uhd_src.set_samp_rate(self.samp_rate)
        self.uhd_src.set_center_freq(self.f_center, 0)
        self.uhd_src.set_gain(self.gain, 0)

        # change magic_num until abs(ratio) as close to 0 (when sending all A's) 
        # as possible (.000X or closer)
        # need to solve clock synchronization
        self.msk_demod = level.msk_demod_cf(ti_adj=False, magic_num=.022)

        self.agc = gr.agc2_cc()
        #self.clock_sync = digital.pfb_clock_sync_ccf(sps=2,)
        self.costas_loop = digital.costas_loop_cc(2*3.14/100.0, 4)

        self.packet_receiver = level.cc1k_demod_pkts(callback=rx_callback())

        self.vec_sink = gr.vector_sink_f(1)
        self.slicer = digital.binary_slicer_fb()
        self.bin_sink = gr.vector_sink_b(1)

        # Connections
        self.connect(self.uhd_src, self.agc, self.msk_demod, self.slicer, self.bin_sink)
        self.connect(self.msk_demod, self.vec_sink)
        self.connect(self.uhd_src, self.packet_receiver)
Example #45
0
    def __init__(self, sps, gain_mu):
        gr.hier_block2.__init__(self, "fsk_demod",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature(1, 1, gr.sizeof_char)) # Output signature

        self._sps = float(sps)
        self._gain_mu = gain_mu # for the clock recovery block
        self._mu = 0.5
        self._omega_relative_limit = 0.35

        #first bring that input stream down to a manageable level
        self._clockrec_oversample = 3.0
        self._decim = self._sps / self._clockrec_oversample
        print "Demodulator decimation: %f" % self._decim
        self._downsampletaps = filter.firdes.low_pass(1.0/self._decim,
                                                1.0, 0.4,
                                                0.05, filter.firdes.WIN_HANN)

#        self._downsample = filter.fft_filter_ccc(self._decim,
#                                                self._downsampletaps)

        #sure this works but it's a little heavy on the CPU at high rates
        self._downsample = pfb.arb_resampler_ccf(1/self._decim)

        self._clockrec_sps = self._sps / self._decim

        #using a pll to demod gets you a nice IIR LPF response for free
        self._demod = analog.pll_freqdet_cf(2.0 / self._clockrec_sps, #gain alpha, rad/samp
                                         2*pi/self._clockrec_sps,  #max freq, rad/samp
                                        -2*pi/self._clockrec_sps)  #min freq, rad/samp

        #band edge filter FLL with a low bandwidth is very good
        #at synchronizing to continuous FSK signals
        self._carriertrack = digital.fll_band_edge_cc(self._clockrec_sps,
                                                      0.6, #rolloff factor
                                                      64,  #taps
                                                      1.0) #loop bandwidth

        print "Samples per symbol: %f" % (self._clockrec_sps,)
        self._softbits = digital.clock_recovery_mm_ff(self._clockrec_sps,
                                                 0.25*self._gain_mu*self._gain_mu, #gain omega, = mu/2 * mu_gain^2
                                                 self._mu, #mu (decision threshold)
                                                 self._gain_mu, #mu gain
                                                 self._omega_relative_limit) #omega relative limit

        self._slicer = digital.binary_slicer_fb()

        if self._decim > 1:
            self.connect(self, self._downsample, self._carriertrack, self._demod, self._softbits, self._slicer, self)
        else:
            self.connect(self, self._carriertrack, self._demod, self._softbits, self._slicer, self)
	def __init__(self):
		gr.top_block.__init__(self, "MSK Demod Demo")

		# Variables
		self.samp_rate = samp_rate = 125e3
		self.f_center = f_center = 868e6
		self.bandwidth = bandwidth = 500e3
		self.gain = gain = 5
		self.decimation = decimation = 2

		# Blocks
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_source_0.set_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(f_center, 0)
		self.uhd_usrp_source_0.set_gain(gain, 0)
		self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0)

		self.msk_demod = msk.msk_demod_cf()

		self.slicer = digital.binary_slicer_fb()
		self.slicer2 = digital.binary_slicer_fb()

		self.offset = gr.add_const_vff((0, ))

		self.sink = gr.vector_sink_b(1)
		self.f_sink = gr.vector_sink_f(1)
		self.file_sink = gr.file_sink(gr.sizeof_char, 'fsk_dump.log')

		# Connections
		self.connect(self.uhd_usrp_source_0, self.msk_demod, self.offset, self.slicer, self.sink)
		self.connect(self.offset, self.f_sink)
		self.connect(self.offset, self.slicer2, self.file_sink)
Example #47
0
	def __init__(self, input_filename="usrp.dat", output_filename="frames.dat", decim=32, pll_alpha=0.01, clock_alpha=0.01):
		gr.top_block.__init__(self, "Hrpt Demod")

		##################################################
		# Parameters
		##################################################
		self.input_filename = input_filename
		self.output_filename = output_filename
		self.decim = decim
		self.pll_alpha = pll_alpha
		self.clock_alpha = clock_alpha

		##################################################
		# Variables
		##################################################
		self.sym_rate = sym_rate = 600*1109
		self.sample_rate = sample_rate = 4e6
		self.sps = sps = sample_rate/sym_rate
		self.max_clock_offset = max_clock_offset = 100e-6
		self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate
		self.hs = hs = int(sps/2.0)

		##################################################
		# Blocks
		##################################################
		self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset)
		self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer()
		self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000)
		self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename)
		self.gr_file_sink_0.set_unbuffered(False)
		self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False)
		self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset)
		self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
		self.decoder = noaa.hrpt_decoder(True,False)
		self.cs2cf = gr.interleaved_short_to_complex()
		self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0)

		##################################################
		# Connections
		##################################################
		self.connect((self.file_source, 0), (self.cs2cf, 0))
		self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0))
		self.connect((self.cs2cf, 0), (self.agc, 0))
		self.connect((self.agc, 0), (self.pll, 0))
		self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0))
		self.connect((self.noaa_hrpt_deframer_0, 0), (self.decoder, 0))
		self.connect((self.gr_moving_average_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
		self.connect((self.digital_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0))
Example #48
0
    def test_binary_slicer_fb(self):
        expected_result = ( 0, 1,  0,  0, 1, 1,  0,  0,  0, 1, 1, 1,  0, 1, 1, 1, 1)
        src_data =        (-1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1)
        src_data = [s + (1 - random.random()) for s in src_data] # add some noise
        src = blocks.vector_source_f(src_data)
        op = digital.binary_slicer_fb()
        dst = blocks.vector_sink_b()

        self.tb.connect(src, op)
        self.tb.connect(op, dst)
        self.tb.run()               # run the graph and wait for it to finish

        actual_result = dst.data()  # fetch the contents of the sink
        #print "actual result", actual_result
        #print "expected result", expected_result
        self.assertFloatTuplesAlmostEqual(expected_result, actual_result)
Example #49
0
	def __init__(self, input_rate, symbol_rate):
		super(clock_recovery, self).__init__(
			"clock_recovery",
			gr.io_signature(1, 1, gr.sizeof_float*1),
			gr.io_signature(1, 1, gr.sizeof_char*1),
		)

		samples_per_symbol = float(input_rate) / symbol_rate
		omega_relative_limit = 0.02
		gain_mu = 0.4 / samples_per_symbol

		self.clock_recovery = digital.clock_recovery_mm_ff(samples_per_symbol*(1+0.00), 0.25*gain_mu*gain_mu, 0.5, gain_mu, omega_relative_limit)
		self.slicer = digital.binary_slicer_fb()

		self.connect((self, 0), (self.clock_recovery, 0))
		self.connect((self.clock_recovery, 0), (self.slicer, 0))
		self.connect((self.slicer, 0), (self, 0))
Example #50
0
    def __init__(self):
        gr.top_block.__init__(self, "Elster Rx Nogui")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2400000
        self.rx_gain = rx_gain = 45
        self.corr = corr = 0
        self.channel_rate = channel_rate = 400000
        self.channel_decimation = channel_decimation = 4
        self.center_freq = center_freq = 904600000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(corr, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(0, 0)
        self.osmosdr_source_0.set_gain(rx_gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_1 = filter.fir_filter_fff(channel_decimation, firdes.low_pass(
        	1, channel_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76))
        self.elster_packetize_0 = elster.packetize(1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(channel_rate * 56.48E-6 / 2 / channel_decimation, 0.25*(0.05*0.05), 0.5, 0.05, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*1, samp_rate/channel_rate)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(-channel_rate/(115000*2*3.1416))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.elster_packetize_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
Example #51
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.channel_spacing = channel_spacing = 500000
        self.width = width = 40000
        self.tuner = tuner = 868.95e6
        self.squelch = squelch = -25
        self.samp_rate = samp_rate = 1.024e6
        self.freq_offset = freq_offset = (channel_spacing / 2) + (channel_spacing * .1)
        self.demodgain = demodgain = 24
        self.cutoff = cutoff = 200000

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_c_0_1 = osmosdr.source()
        self.osmosdr_source_c_0_1.set_sample_rate(samp_rate)
        self.osmosdr_source_c_0_1.set_center_freq(tuner+freq_offset, 0)
        self.osmosdr_source_c_0_1.set_freq_corr(21, 0)
        self.osmosdr_source_c_0_1.set_iq_balance_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain_mode(0, 0)
        self.osmosdr_source_c_0_1.set_gain(10, 0)
        self.osmosdr_source_c_0_1.set_if_gain(24, 0)
        self.osmosdr_source_c_0_1.set_bb_gain(20, 0)
        self.osmosdr_source_c_0_1.set_antenna("", 0)
        self.osmosdr_source_c_0_1.set_bandwidth(0, 0)
          
        self.freq_xlating_fir_filter_xxx_0_1 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, samp_rate,cutoff, width,  firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "capture", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(demodgain)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.freq_xlating_fir_filter_xxx_0_1, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.osmosdr_source_c_0_1, 0), (self.freq_xlating_fir_filter_xxx_0_1, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_binary_slicer_fb_0, 0))
Example #52
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000
        self.dec_rate = dec_rate = 2

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="", stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1))
        )
        self.uhd_usrp_source_0.set_samp_rate(1000000)
        self.uhd_usrp_source_0.set_center_freq(2400490000, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.low_pass_filter_0_0 = gr.interp_fir_filter_ccf(
            1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76)
        )
        self.low_pass_filter_0 = gr.fir_filter_fff(
            1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76)
        )
        self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1)
        self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_cc(-100, 0.001, 0, True)
        self.flysky_dumpsync_0 = flysky.dumpsync()
        self.digital_correlate_access_code_bb_0_1 = digital.correlate_access_code_bb(
            "010101010101010101010101010101010101010001110101", 1
        )
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.0076562, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.gr_pwr_squelch_xx_0, 0), (self.gr_quadrature_demod_cf_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.gr_pwr_squelch_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0_1, 0))
        self.connect((self.digital_correlate_access_code_bb_0_1, 0), (self.flysky_dumpsync_0, 0))
Example #53
0
    def test_001_t (self):
        chaos_values = (1+0j, 0+1j, -1+0j, 0-1j)
        expected_result = (0, 1, 0, 0, 1, 1)
        zero = chaos_values + tuple(map(lambda v: -v, chaos_values))
        one = 2 * chaos_values
        src_data = zero + one + zero + zero + one + one

        src = blocks.vector_source_c (src_data)
        demod = chaos.dcsk_demod_cf (len(chaos_values), 0)
        slicer = digital.binary_slicer_fb()
        dst = blocks.vector_sink_b ()

        self.tb.connect (src, demod, slicer, dst)

        self.tb.run ()

        result_data = dst.data ()

        self.assertEqual (expected_result, result_data)
    def __init__(self, src_file):
        gr.top_block.__init__(self)

        sample_rate = 11025
	ampl = 0.1
        print src_file
        # Audio source (.wav file)
        # TODO : Make the filename a VARIABLE
        # src_file = input("Enter .wav File PSK31 : ")
        src = blocks.wavfile_source(src_file, False)

        # Raw float data output file.
        # TODO : To make the raw file also a variable, for psk31decoder2.py to run
        dst = blocks.file_sink(1, "./output.raw")

        # Delay line. This delays the signal by 32ms
        dl = blocks.delay(gr.sizeof_float, int(round(sample_rate/31.25)))

        # Multiplier
        # Multiplying the source and the delayed version will give us
        # a negative output if there was a phase reversal and a positive output
        # if there was no phase reversal
        mul = blocks.multiply_ff(1)

        # Low Pass Filter. This leaves us with the envelope of the signal
        lpf_taps = filter.firdes.low_pass(
            5.0,
            sample_rate,
            15,
            600,
            filter.firdes.WIN_HAMMING)
        lpf = filter.fir_filter_fff(1, lpf_taps)

        # Binary Slicer (comparator)
        slc = digital.binary_slicer_fb()

        # Connect the blocks.
        self.connect(src, dl)
        self.connect(src, (mul, 0))
        self.connect(dl,  (mul, 1))
        self.connect(mul, lpf)
        self.connect(lpf, slc)
        self.connect(slc, dst)
Example #55
0
	def __init__(self, samp_rate=1600000, samp_per_sym=16, freq_error=-0.0025000):
		gr.hier_block2.__init__(
			self, "Wireless M-Bus Demod",
			gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
			gr.io_signature(1, 1, gr.sizeof_char*1),
		)

		##################################################
		# Parameters
		##################################################
		self.samp_rate = samp_rate
		self.samp_per_sym = samp_per_sym
		self.freq_error = freq_error

		##################################################
		# Variables
		##################################################
		self.cutoff = cutoff = 120e3
		self.chip_rate = chip_rate = samp_rate/samp_per_sym

		##################################################
		# Blocks
		##################################################
		self.low_pass_filter_0 = gnuradio.filter.fir_filter_ccf(1, gnuradio.filter.firdes.low_pass(
			1, samp_rate, cutoff, cutoff/2, gnuradio.filter.firdes.WIN_HAMMING, 6.76))
		self.gr_sub_xx_0 = blocks.sub_ff(1)
		self.gr_single_pole_iir_filter_xx_0 = gnuradio.filter.single_pole_iir_filter_ff(0.0512/samp_per_sym, 1)
		self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)
		self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+freq_error), .25 *0.06*0.06*4, 0.5, 0.06*2, 0.002*2)
		self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_single_pole_iir_filter_xx_0, 0))
		self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.gr_sub_xx_0, 1))
		self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_sub_xx_0, 0))
		self.connect((self.gr_sub_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
		self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
		self.connect((self.low_pass_filter_0, 0), (self.gr_quadrature_demod_cf_0, 0))
		self.connect((self.digital_binary_slicer_fb_0, 0), (self, 0))
		self.connect((self, 0), (self.low_pass_filter_0, 0))
Example #56
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))    
Example #57
0
    def __init__(self):
        """
        Hierarchical block for FSK demodulation.
    
        The input is the complex modulated signal at baseband
        and the output is a stream of floats.
        """
        # Initialize base class
        gr.hier_block2.__init__(
            self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)
        )

        # Variables
        self.sps = sps = 2
        self.sensitivity = sensitivity = (pi / 2) / sps
        self.alpha = alpha = 0.0512 / sps

        self.fm_demod = gr.quadrature_demod_cf(1 / sensitivity)

        self.freq_offset = gr.single_pole_iir_filter_ff(alpha)
        self.sub = gr.sub_ff()
        self.add = gr.add_ff()
        self.multiply = gr.multiply_ff()
        self.invert = gr.multiply_const_vff((-1,))

        # recover the clock
        omega = sps
        gain_mu = 0.03
        mu = 0.5
        omega_relative_limit = 0.0002
        freq_error = 0.0
        gain_omega = 0.25 * gain_mu * gain_mu  # critically damped
        self.clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit)

        self.slice = digital.binary_slicer_fb()

        # Connections
        self.connect(self.fm_demod, (self.add, 0))
        self.connect(self.fm_demod, self.freq_offset, (self.add, 1))
        self.connect(self, self.fm_demod)
        self.connect(self.add, self.clock_recovery, self.invert, self)
Example #58
0
    def __init__(self):
        """
        Hierarchical block for MSK demodulation.
    
        The input is the complex modulated signal at baseband
        and the output is a stream of floats.
        """
        # Initialize base class
        gr.hier_block2.__init__(
            self, "msk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)
        )

        self.sps = 2
        self.bt = 0.35
        self.mu = 0.5
        self.gain_mu = 0.175
        self.freq_error = 0.0
        self.omega_relative_limit = 0.005

        self.omega = self.sps * (1 + self.freq_error)
        self.gain_omega = 0.25 * self.gain_mu * self.gain_mu  # critically damped

        # Demodulate FM
        sensitivity = (pi / 2) / self.sps
        self.fmdemod = gr.quadrature_demod_cf(1.0 / sensitivity)
        self.invert = gr.multiply_const_vff((-1,))

        # TODO: this is hardcoded, how to figure out this value?
        self.offset = gr.add_const_vff((-1.2,))

        # the clock recovery block tracks the symbol clock and resamples as needed.
        # the output of the block is a stream of soft symbols (float)
        self.clock_recovery = digital.clock_recovery_mm_ff(
            self.omega, self.gain_omega, self.mu, self.gain_mu, self.omega_relative_limit
        )

        self.slicer = digital.binary_slicer_fb()

        self.connect(self, self.fmdemod, self.invert, self.clock_recovery, self.offset, self)
Example #59
0
 def __init__(self, input_rate, baud):
     gr.hier_block2.__init__(
         self, 'RTTY FSK demodulator',
         gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
         gr.io_signature(1, 1, gr.sizeof_float * 1),
     )
     
     self.bit_time = bit_time = input_rate / baud
     
     fsk_deviation_hz = 85  # TODO param or just don't care
     
     self.__dc_blocker = grfilter.dc_blocker_ff(int(bit_time * _HALF_BITS_PER_CODE * 10), False)
     self.__quadrature_demod = analog.quadrature_demod_cf(-input_rate / (2 * math.pi * fsk_deviation_hz))
     self.__freq_probe = blocks.probe_signal_f()
     
     self.connect(
         self,
         self.__quadrature_demod,
         self.__dc_blocker,
         digital.binary_slicer_fb(),
         blocks.char_to_float(scale=1),
         self)
     self.connect(self.__dc_blocker, self.__freq_probe)