summaryrefslogtreecommitdiff
path: root/gr-digital/python/pkt.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-digital/python/pkt.py')
-rw-r--r--gr-digital/python/pkt.py43
1 files changed, 21 insertions, 22 deletions
diff --git a/gr-digital/python/pkt.py b/gr-digital/python/pkt.py
index 8650bdbb02..434548906e 100644
--- a/gr-digital/python/pkt.py
+++ b/gr-digital/python/pkt.py
@@ -23,8 +23,12 @@ from math import pi
from gnuradio import gr
import gnuradio.gr.gr_threading as _threading
import packet_utils
-import digital_swig
+import digital_swig as digital
+try:
+ from gnuradio import blocks
+except ImportError:
+ import blocks_swig as blocks
# /////////////////////////////////////////////////////////////////////////////
# mod/demod with packets as i/o
@@ -44,14 +48,12 @@ class mod_pkts(gr.hier_block2):
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
+ Args:
+ modulator: instance of modulator class (gr_block or hier_block2) (complex baseband out)
+ access_code: AKA sync vector (string of 1's and 0's between 1 and 64 long)
+ msgq_limit: maximum number of messages in message queue (int)
+ pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples
+ use_whitener_offset: If true, start of whitener XOR string is incremented each packet
See gmsk_mod for remaining parameters
"""
@@ -72,15 +74,15 @@ class mod_pkts(gr.hier_block2):
self._access_code = access_code
# accepts messages from the outside world
- self._pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
+ self._pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit)
self.connect(self._pkt_input, self._modulator, self)
def send_pkt(self, payload='', eof=False):
"""
Send the payload.
- @param payload: data to send
- @type payload: string
+ Args:
+ payload: data to send (string)
"""
if eof:
msg = gr.message(1) # tell self._pkt_input we're not sending any more packets
@@ -116,14 +118,11 @@ class demod_pkts(gr.hier_block2):
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
+ Args:
+ demodulator: instance of demodulator class (gr_block or hier_block2) (complex baseband in)
+ access_code: AKA sync vector (string of 1's and 0's)
+ callback: function of two args: ok, payload (ok: bool; payload: string)
+ threshold: detect access_code with up to threshold bits wrong (-1 -> use default) (int)
"""
gr.hier_block2.__init__(self, "demod_pkts",
@@ -141,9 +140,9 @@ class demod_pkts(gr.hier_block2):
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.correlator = digital.correlate_access_code_bb(access_code, threshold)
- self.framer_sink = gr.framer_sink_1(self._rcvd_pktq)
+ self.framer_sink = digital.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)