예제 #1
0
 def test_bytes_to_syms_001(self):
     src_data = (0x01, 0x80, 0x03)
     expected_result = (-1, -1, -1, -1, -1, -1, -1, +1, +1, -1, -1, -1, -1,
                        -1, -1, -1, -1, -1, -1, -1, -1, -1, +1, +1)
     src = gr.vector_source_b(src_data)
     op = gr.bytes_to_syms()
     dst = gr.vector_sink_f()
     self.tb.connect(src, op)
     self.tb.connect(op, dst)
     self.tb.run()
     result_data = dst.data()
     self.assertEqual(expected_result, result_data)
예제 #2
0
 def test_bytes_to_syms_001 (self):
     src_data = (0x01, 0x80, 0x03)
     expected_result = (-1, -1, -1, -1, -1, -1, -1, +1,
                        +1, -1, -1, -1, -1, -1, -1, -1,
                        -1, -1, -1, -1, -1, -1, +1, +1)
     src = gr.vector_source_b (src_data)
     op = gr.bytes_to_syms ()
     dst = gr.vector_sink_f ()
     self.tb.connect (src, op)
     self.tb.connect (op, dst)
     self.tb.run ()
     result_data = dst.data ()
     self.assertEqual (expected_result, result_data)
예제 #3
0
    def __init__(self):
        gr.top_block.__init__(self)
        
        self.src = gr.message_source(gr.sizeof_char, msgq_limit)
        src = self.src
        
        b_to_syms = gr.bytes_to_syms()
        
        self.mult = gr.multiply_const_ff(MULTIPLIER)
    
        add = gr.add_const_ff(CENTER_FREQ)
                    
        repeater = gr.repeat(gr.sizeof_float,REPEAT_TIME)
    
        fsk_f = gr.vco_f(AUDIO_RATE, 2*pi,0.5)

	speaker = audio.sink(AUDIO_RATE, "plughw:0,0");
	
        self.connect(src,b_to_syms,self.mult,add,repeater,fsk_f,speaker)
예제 #4
0
    def __init__(self, fg, spb = 8, bt = 0.3):
        """
	Hierarchical block for cc1k FSK modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

	@param fg: flow graph
	@type fg: flow graph
	@param spb: samples per baud >= 2
	@type spb: integer
	@param bt: Gaussian filter bandwidth * symbol time
	@type bt: float
	"""
        if not isinstance(spb, int) or spb < 2:
            raise TypeError, "sbp must be an integer >= 2"
        self.spb = spb

	#sensitivity = (pi / 2) / spb	# phase change per bit = pi / 2
        sensitivity = 3.5*pi / spb
        
	# Turn it into NRZ data.
	self.nrz = gr.bytes_to_syms()

        # Manchester Encode the whole thing and upsample by 8
        self.manchester = ucla.manchester_ff()

	# FM modulation
	self.fmmod = gr.frequency_modulator_fc(sensitivity)
		
	# Connect
	fg.connect(self.nrz, self.manchester)
        fg.connect(self.manchester, self.fmmod)

        #filesink1 = gr.file_sink(gr.sizeof_float, 'nrz.dat')
        #fg.connect(self.nrz, filesink1)
        #filesink = gr.file_sink(gr.sizeof_float, 'manchester.dat')
        #fg.connect(self.manchester, filesink)
        
	# Initialize base class
	gr.hier_block.__init__(self, fg, self.nrz, self.fmmod)
예제 #5
0
    def __init__(self, fg, spb=8, bt=0.3):
        """
	Hierarchical block for cc1k FSK modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

	@param fg: flow graph
	@type fg: flow graph
	@param spb: samples per baud >= 2
	@type spb: integer
	@param bt: Gaussian filter bandwidth * symbol time
	@type bt: float
	"""
        if not isinstance(spb, int) or spb < 2:
            raise TypeError, "sbp must be an integer >= 2"
        self.spb = spb

        #sensitivity = (pi / 2) / spb	# phase change per bit = pi / 2
        sensitivity = 3.5 * pi / spb

        # Turn it into NRZ data.
        self.nrz = gr.bytes_to_syms()

        # Manchester Encode the whole thing and upsample by 8
        self.manchester = ucla.manchester_ff()

        # FM modulation
        self.fmmod = gr.frequency_modulator_fc(sensitivity)

        # Connect
        fg.connect(self.nrz, self.manchester)
        fg.connect(self.manchester, self.fmmod)

        #filesink1 = gr.file_sink(gr.sizeof_float, 'nrz.dat')
        #fg.connect(self.nrz, filesink1)
        #filesink = gr.file_sink(gr.sizeof_float, 'manchester.dat')
        #fg.connect(self.manchester, filesink)

        # Initialize base class
        gr.hier_block.__init__(self, fg, self.nrz, self.fmmod)
예제 #6
0
    def __init__(self):
        gr.top_block.__init__(self)
        audio_rate =48000 # audio rate changed
	
        self.src = gr.message_source(gr.sizeof_char, msgq_limit)
    
        src = self.src
        
        b_to_syms = gr.bytes_to_syms()
        
        mult = gr.multiply_const_ff(1000)
	
    
        add = gr.add_const_ff(CentreFreq)
                    
        repeater = gr.repeat(gr.sizeof_float,RepeatTime)
    
        fsk_f = gr.vco_f(audio_rate, 2*pi,0.5)   # Sensitivity is rad/sec/volt ( e.g 2*pi*f/sec = 1Khz) and here f = volts (input amplitude of VCO)
    	attenuator = gr.multiply_const_ff(0.05)   # multiply
        speaker = audio.sink(audio_rate, "plughw:0,0");
        dst = gr.wavfile_sink("tx-signal.wav",1, audio_rate, 16)
        
        self.connect(src,b_to_syms,mult,add,repeater,fsk_f,attenuator,speaker)
        self.connect(fsk_f,dst)
    def __init__(self, fg,
                 samples_per_symbol=_def_samples_per_symbol,
                 bt=_def_bt,
                 verbose=_def_verbose,
                 log=_def_log):
        """
	Hierarchical block for Gaussian Minimum Shift Key (GMSK)
	modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

	@param fg: flow graph
	@type fg: flow graph
	@param samples_per_symbol: samples per baud >= 2
	@type samples_per_symbol: integer
	@param bt: Gaussian filter bandwidth * symbol time
	@type bt: float
        @param verbose: Print information about modulator?
        @type verbose: bool
        @param debug: Print modualtion data to files?
        @type debug: bool       
	"""

        self._fg = fg
        self._samples_per_symbol = samples_per_symbol
        self._bt = bt

        if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
            raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,))

	ntaps = 4 * samples_per_symbol			# up to 3 bits in filter at once
	sensitivity = (pi / 2) / samples_per_symbol	# phase change per bit = pi / 2

	# Turn it into NRZ data.
	self.nrz = gr.bytes_to_syms()

	# Form Gaussian filter
        # Generate Gaussian response (Needs to be convolved with window below).
	self.gaussian_taps = gr.firdes.gaussian(
		1,		       # gain
		samples_per_symbol,    # symbol_rate
		bt,		       # bandwidth * symbol time
		ntaps	               # number of taps
		)

	self.sqwave = (1,) * samples_per_symbol       # rectangular window
	self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave))
	self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps)

	# FM modulation
	self.fmmod = gr.frequency_modulator_fc(sensitivity)
		
        if verbose:
            self._print_verbage()
         
        if log:
            self._setup_logging()

	# Connect & Initialize base class
	self._fg.connect(self.nrz, self.gaussian_filter, self.fmmod)
	gr.hier_block.__init__(self, self._fg, self.nrz, self.fmmod)
예제 #8
0
    def __init__(self,
                 samples_per_symbol=_def_samples_per_symbol,
                 sensitivity=_def_sensitivity,
                 bt=_def_bt,
                 verbose=_def_verbose,
                 log=_def_log):
        """
	Hierarchical block for Gaussian Frequency Shift Key (GFSK)
	modulation.

	The input is a byte stream (unsigned char) and the
	output is the complex modulated signal at baseband.

	@param samples_per_symbol: samples per baud >= 2
	@type samples_per_symbol: integer
	@param bt: Gaussian filter bandwidth * symbol time
	@type bt: float
        @param verbose: Print information about modulator?
        @type verbose: bool
        @param debug: Print modualtion data to files?
        @type debug: bool       
	"""

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

        samples_per_symbol = int(samples_per_symbol)
        self._samples_per_symbol = samples_per_symbol
        self._bt = bt
        self._differential = False

        if not isinstance(samples_per_symbol, int) or samples_per_symbol < 2:
            raise TypeError, ("samples_per_symbol must be an integer >= 2, is %r" % (samples_per_symbol,))

	ntaps = 4 * samples_per_symbol			# up to 3 bits in filter at once
	#sensitivity = (pi / 2) / samples_per_symbol	# phase change per bit = pi / 2

	# Turn it into NRZ data.
	self.nrz = gr.bytes_to_syms()

	# Form Gaussian filter
        # Generate Gaussian response (Needs to be convolved with window below).
	self.gaussian_taps = gr.firdes.gaussian(
		1.0,		       # gain
		samples_per_symbol,    # symbol_rate
		bt,		       # bandwidth * symbol time
		ntaps	               # number of taps
		)

	self.sqwave = (1,) * samples_per_symbol       # rectangular window
	self.taps = numpy.convolve(numpy.array(self.gaussian_taps),numpy.array(self.sqwave))
	self.gaussian_filter = gr.interp_fir_filter_fff(samples_per_symbol, self.taps)

	# FM modulation
	self.fmmod = gr.frequency_modulator_fc(sensitivity)

	# small amount of output attenuation to prevent clipping USRP sink
	self.amp = gr.multiply_const_cc(0.999)
		
        if verbose:
            self._print_verbage()
         
        if log:
            self._setup_logging()

	# Connect & Initialize base class
	self.connect(self, self.nrz, self.gaussian_filter, self.fmmod, self.amp, self)
예제 #9
0
    def __init__(self, options, parent):
        '''
        See below for what options should hold
        '''
        gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0), # Input signature
                				gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        options = copy.copy(options)    # make a copy so we can destructively modify

        self._bitrate            = options.bitrate         # desired bit rate
        #self._inter              = options.inter           # Decimating rate for the USRP (prelim)
        self._samples_per_symbol  = options.samples_per_symbol  # desired samples/symbol
        self._down_sample_rate    = options.down_sample_rate


        self._verbose            = options.verbose
        self._tx_amplitude       = options.tx_amplitude    # digital amplitude sent to USRP
        
        self._use_whitener_offset = options.use_whitener_offset # increment start of whitener XOR data
        self._access_code        = packet_utils.conv_packed_binary_string_to_1_0_string(default_ola_spade_code)
        self._subchannel          = options.subchannel
        self._msgq_limit         = 4
        
        self.parent = parent

        # Turn it into NRZ data.
        self.nrz = gr.bytes_to_syms()
        self.sqwave = (1,) * self._samples_per_symbol       # rectangular window
        self.gaussian_filter = gr.interp_fir_filter_fff(self._samples_per_symbol, self.sqwave)

        #Sensitivity will be seletected by set_sensitivity function in main loop
        self.sensitivity_a = (2 *pi * self._subchannel) / self._samples_per_symbol	# phase change per bit = pi / 2 (for BFSK)
        self.sensitivity_b = (2 *pi * (self._subchannel)) / self._samples_per_symbol	# phase change per bit = pi / 2 (for BFSK)

        self._pad_for_usrp = True
        self._use_whitener_offset = False
        self._whitener_offset = 0
 
        # TODO 
        # BUG : Improve or Implement Stream Selector!!!! (Check the new GNU Radio blocks!!!)
               
        # =============================================================================
        # The first flowgraph for Digital Only Modulation
        # =============================================================================
        self._pkt_input = gr.message_source(gr.sizeof_char, self._msgq_limit)   # accepts messages from the outside world
        self.fmmod = gtlib.bfsk_modulator_fc(self.sensitivity_a,self.sensitivity_b)          # BFSK modulation
       
        self.amp = gr.multiply_const_cc(1)          # (Note that on the RFX cards this is a nop.)
        self.amp_2 = gr.multiply_const_cc(1)        # (Sub channel correction)

        if self._subchannel >= 1 and self._subchannel <= 4:
            self.amp_2.set_k(pow(1.2,(float(self._subchannel)-1)))

        #self.timetag_inserter = gtlib.usrp_timetag_insert()     

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

        self.connect(self._pkt_input, self.nrz, self.gaussian_filter,self.fmmod,self.amp, self.amp_2, self)
       
        self.set_tx_amplitude(self._tx_amplitude)