summaryrefslogtreecommitdiff
path: root/gr-digital/python/digital/packet_utils.py
diff options
context:
space:
mode:
authorMichael Berman <michael@gpstoo.com>2013-10-02 15:56:23 -0700
committerMichael Berman <michael@gpstoo.com>2013-10-02 15:56:23 -0700
commite2ae0852c82ae1d15dc09d434e75b1f95e4297a5 (patch)
tree86a45a765f4ffaef34f7fa04364c02f79d41c219 /gr-digital/python/digital/packet_utils.py
parent1aa07b3640ccf43a7ccdc8d610449f51c0f38b91 (diff)
digital/packet_utils: adding parameter to take a user input preamble to the packet encoder
Diffstat (limited to 'gr-digital/python/digital/packet_utils.py')
-rw-r--r--gr-digital/python/digital/packet_utils.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/gr-digital/python/digital/packet_utils.py b/gr-digital/python/digital/packet_utils.py
index 2929758ef0..865f3adbb4 100644
--- a/gr-digital/python/digital/packet_utils.py
+++ b/gr-digital/python/digital/packet_utils.py
@@ -71,7 +71,7 @@ def conv_1_0_string_to_packed_binary_string(s):
default_access_code = \
conv_packed_binary_string_to_1_0_string('\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC')
-preamble = \
+default_preamble = \
conv_packed_binary_string_to_1_0_string('\xA4\xF2')
def is_1_0_string(s):
@@ -102,8 +102,8 @@ def make_header(payload_len, whitener_offset=0):
return struct.pack('!HH', val, val)
def make_packet(payload, samples_per_symbol, bits_per_symbol,
- access_code=default_access_code, pad_for_usrp=True,
- whitener_offset=0, whitening=True):
+ preamble=default_preamble, access_code=default_access_code,
+ pad_for_usrp=True, whitener_offset=0, whitening=True):
"""
Build a packet, given access code, payload, and whitener offset
@@ -111,12 +111,16 @@ def make_packet(payload, samples_per_symbol, bits_per_symbol,
payload: packet payload, len [0, 4096]
samples_per_symbol: samples per symbol (needed for padding calculation) (int)
bits_per_symbol: (needed for padding calculation) (int)
+ preamble: string of ascii 0's and 1's
access_code: string of ascii 0's and 1's
whitener_offset: offset into whitener string to use [0-16)
Packet will have access code at the beginning, followed by length, payload
and finally CRC-32.
"""
+ if not is_1_0_string(preamble):
+ raise ValueError, "preamble must be a string containing only 0's and 1's (%r)" % (preamble,)
+
if not is_1_0_string(access_code):
raise ValueError, "access_code must be a string containing only 0's and 1's (%r)" % (access_code,)