From e2ae0852c82ae1d15dc09d434e75b1f95e4297a5 Mon Sep 17 00:00:00 2001
From: Michael Berman <michael@gpstoo.com>
Date: Wed, 2 Oct 2013 15:56:23 -0700
Subject: digital/packet_utils: adding parameter to take a user input preamble
 to the packet encoder

---
 gr-digital/python/digital/packet_utils.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'gr-digital/python/digital/packet_utils.py')

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,)
 
-- 
cgit v1.2.3