Esempio n. 1
0
    def __init__(self, demodulator, options, access_code=None, callback=None, threshold=-1, use_coding=0, logging=-1):
        """
	Hierarchical block for demodulating and deframing packets.

	The input is the complex modulated signal at baseband.
        Demodulated packets are sent to the handler.

        @param demodulator: instance of demodulator class (gr_block or hier_block2)
        @type demodulator: complex baseband in
        @param access_code: AKA sync vector
        @type access_code: string of 1's and 0's
        @param callback:  function of two args: ok, payload
        @type callback: ok: bool; payload: string
        @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default)
        @type threshold: int
	"""

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

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

        #just added to take coding from benchmark_rx
        self._use_coding = use_coding
        self._logging = logging
        self._options = options
        
        
            
        
        # added to simplify logging
        self._threshold = options.access_code_threshold


        if threshold == -1:
            threshold = 4              # FIXME raise exception

        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
        self._time_pktq = gr.msg_queue()          # holds packet timestamps from the PHY
        self._chan_pktq = gr.msg_queue()          # holds packet channels from the PHY
        
        self.correlator = digital.correlate_access_code_bb(access_code, threshold)

        self.framer_sink = framer_sink_1(self._rcvd_pktq, self._time_pktq, self._chan_pktq)
        self.connect(self, self._demodulator, self.correlator, self.framer_sink)
        
        self._watcher = _queue_watcher_thread(self._rcvd_pktq, self._time_pktq, self._chan_pktq, callback, self._use_coding, self._logging, self._options)
Esempio n. 2
0
    def __init__(self, modulator, options, access_code=None, msgq_limit=2, pad_for_usrp=True,
                 use_whitener_offset=False, modulate=True, use_coding=0, logging=-1):
        """
    Hierarchical block for sending packets

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

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

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

        self._modulator = modulator
        self._pad_for_usrp = pad_for_usrp
        self._use_whitener_offset = use_whitener_offset
        self._whitener_offset = 0
        
        #just added to take coding from benchmark_tx
        self._use_coding = use_coding
        self._logging = logging
        self._options = options

        if access_code is None:
            access_code = packet_utils.default_access_code
        if not packet_utils.is_1_0_string(access_code):
            raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
        self._access_code = access_code
        
        # accepts messages from the outside world
        self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
        self.null_sink = gr.null_sink(gr.sizeof_char)
        
        self.connect(self._pkt_input, self._modulator, self)
        self.connect(self,self.null_sink)