def __init__(self, access_code='', threshold=-1, callback=None): """ packet_demod constructor. @param access_code AKA sync vector @param threshold detect access_code with up to threshold bits wrong (0 -> use default) @param callback a function of args: ok, payload """ #access code if not access_code: #get access code access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) self._access_code = access_code #threshold if threshold < 0: threshold = DEFAULT_THRESHOLD self._threshold = threshold #blocks msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY correlator = digital.correlate_access_code_bb(self._access_code, self._threshold) framer_sink = gr.framer_sink_1(msgq) #initialize hier2 gr.hier_block2.__init__( self, "packet_decoder", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) #connect self.connect(self, correlator, framer_sink) #start thread _packet_decoder_thread(msgq, callback)
def __init__(self, access_code='', threshold=-1, callback=None): """ packet_demod constructor. @param access_code AKA sync vector @param threshold detect access_code with up to threshold bits wrong (0 -> use default) @param callback a function of args: ok, payload """ #access code if not access_code: #get access code access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % ( access_code, ) self._access_code = access_code #threshold if threshold < 0: threshold = DEFAULT_THRESHOLD self._threshold = threshold #blocks msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY correlator = digital.correlate_access_code_bb(self._access_code, self._threshold) framer_sink = gr.framer_sink_1(msgq) #initialize hier2 gr.hier_block2.__init__( self, "packet_decoder", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) #connect self.connect(self, correlator, framer_sink) #start thread _packet_decoder_thread(msgq, callback)
def __init__(self, access_code=None, threshold=-1): """ Create a new packet deframer. @param access_code: AKA sync vector @type access_code: string of 1's and 0's @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) @type threshold: int """ gr.hier_block2.__init__( self, "demod_pkts2", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1), ) if not access_code: access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) if threshold == -1: threshold = 12 # FIXME raise exception msgq = gr.msg_queue(4) # holds packets from the PHY self.correlator = gr_digital.correlate_access_code_bb(access_code, threshold) self.framer_sink = gr.framer_sink_1(msgq) self.connect(self, self.correlator, self.framer_sink) self._queue_to_blob = _queue_to_blob(msgq) self.connect(self._queue_to_blob, self)
def __init__(self, access_code=None, threshold=-1): """ Create a new packet deframer. @param access_code: AKA sync vector @type access_code: string of 1's and 0's @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) @type threshold: int """ gr.hier_block2.__init__( self, "demod_pkts2", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1), ) if not access_code: access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % ( access_code, ) if threshold == -1: threshold = 12 # FIXME raise exception msgq = gr.msg_queue(4) # holds packets from the PHY self.correlator = gr_digital.correlate_access_code_bb( access_code, threshold) self.framer_sink = gr.framer_sink_1(msgq) self.connect(self, self.correlator, self.framer_sink) self._queue_to_blob = _queue_to_blob(msgq) self.connect(self._queue_to_blob, self)
def __init__(self, demodulator, access_code=None, callback=None, threshold=-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 if threshold == -1: threshold = 12 # FIXME raise exception self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY self.correlator = digital_swig.correlate_access_code_bb( access_code, threshold) self.framer_sink = gr.framer_sink_1(self._rcvd_pktq) self.connect(self, self._demodulator, self.correlator, self.framer_sink) self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
def __init__(self, demodulator, access_code=None, callback=None, threshold=-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 = cat_packet_utils.default_access_code if not cat_packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) self._access_code = access_code if threshold == -1: threshold = 12 # FIXME raise exception self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY self.correlator = digital_swig.correlate_access_code_bb(access_code, threshold) self.framer_sink = gr.framer_sink_1(self._rcvd_pktq) self.framer_sink.setlen(1670) # Xu: set d_packetlen self.connect(self, self._demodulator, self.correlator, self.framer_sink) self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
def __init__(self, fg, demodulator, access_code=None, callback=None, threshold=-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 fg: flow graph @type fg: flow graph @param demodulator: instance of demodulator class (gr_block or hier_block) @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 """ 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 if threshold == -1: threshold = 12 # FIXME raise exception self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY self.correlator = gr.correlate_access_code_bb(access_code, threshold) self.framer_sink = gr.framer_sink_1(self._rcvd_pktq) fg.connect(self._demodulator, self.correlator, self.framer_sink) gr.hier_block.__init__(self, fg, self._demodulator, None) self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)