diff options
Diffstat (limited to 'gr-digital/python/pkt.py')
-rw-r--r-- | gr-digital/python/pkt.py | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/gr-digital/python/pkt.py b/gr-digital/python/pkt.py index aa720d1a5..8650bdbb0 100644 --- a/gr-digital/python/pkt.py +++ b/gr-digital/python/pkt.py @@ -20,8 +20,10 @@ # from math import pi -from gnuradio import gr, packet_utils +from gnuradio import gr import gnuradio.gr.gr_threading as _threading +import packet_utils +import digital_swig # ///////////////////////////////////////////////////////////////////////////// @@ -34,8 +36,8 @@ class mod_pkts(gr.hier_block2): Send packets by calling send_pkt """ - def __init__(self, modulator, access_code=None, msgq_limit=2, pad_for_usrp=True, use_whitener_offset=False, - modulate=True): + def __init__(self, modulator, access_code=None, msgq_limit=2, pad_for_usrp=True, + use_whitener_offset=False, modulate=True): """ Hierarchical block for sending packets @@ -50,18 +52,13 @@ class mod_pkts(gr.hier_block2): @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 - @param modulate: If false, no modulation will be performed. See gmsk_mod for remaining parameters """ - if modulate: - output_size = gr.sizeof_gr_complex - else: - output_size = gr.sizeof_char gr.hier_block2.__init__(self, "mod_pkts", gr.io_signature(0, 0, 0), # Input signature - gr.io_signature(1, 1, output_size)) # Output signature + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._modulator = modulator self._pad_for_usrp = pad_for_usrp @@ -76,10 +73,7 @@ class mod_pkts(gr.hier_block2): # accepts messages from the outside world self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit) - if modulate: - self.connect(self._pkt_input, self._modulator, self) - else: - self.connect(self._pkt_input, self) + self.connect(self._pkt_input, self._modulator, self) def send_pkt(self, payload='', eof=False): """ @@ -115,15 +109,13 @@ class demod_pkts(gr.hier_block2): app via the callback. """ - def __init__(self, demodulator, access_code=None, callback=None, threshold=-1, demodulate=True): + 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. - If demodulator is None it is assumed the input is already demodulated. - @param demodulator: instance of demodulator class (gr_block or hier_block2) @type demodulator: complex baseband in @param access_code: AKA sync vector @@ -134,14 +126,9 @@ class demod_pkts(gr.hier_block2): @type threshold: int """ - if demodulator is not None: - input_size = gr.sizeof_gr_complex - else: - input_size = gr.sizeof_char - gr.hier_block2.__init__(self, "demod_pkts", - gr.io_signature(1, 1, input_size), # Input signature - gr.io_signature(0, 0, 0)) # Output signature + 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: @@ -154,16 +141,12 @@ class demod_pkts(gr.hier_block2): 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.correlator = digital_swig.correlate_access_code_bb(access_code, threshold) self.framer_sink = gr.framer_sink_1(self._rcvd_pktq) - if self._demodulator is not None: - self.connect(self, self._demodulator, self.correlator, self.framer_sink) - else: - self.connect(self, self.correlator, self.framer_sink) + self.connect(self, self._demodulator, self.correlator, self.framer_sink) - if callback is not None: - self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) + self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback) class _queue_watcher_thread(_threading.Thread): |