diff options
author | eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5> | 2006-09-27 05:14:03 +0000 |
---|---|---|
committer | eb <eb@221aa14e-8319-0410-a670-987f0aec2ac5> | 2006-09-27 05:14:03 +0000 |
commit | f1c41f807cb29472d0924149e39d6ec8ad90e6a2 (patch) | |
tree | 47e42f8cdfc83aaa3b706e06862c3efa4ba16745 /gnuradio-core/src/python/gnuradio/packet_utils.py | |
parent | 04bb51ec4f1539c51c861b7fcad2ca8047a872a3 (diff) |
Merged changes from eb/digital-wip into trunk.
This includes:
* renaming gnuradio-examples/python/gmsk2 to gnuradio-examples/python/digital
* refactoring the digital data tx and rx test code into benchmark_tx
and benchmark_rx. These accept a -m <modulation> argument.
<modulation> can currently be selected from gmsk, dbpsk, dqpsk
* Two new AGC blocks: gr_agc2: separate attack and delay rates;
gr_feedforward_agc: FIR-ish compressor. Normalizes to peak envelope.
* Working DBPSK mod/demod (works fine)
* Working DQPSK mod/demod (works, but still needs more work)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@3662 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src/python/gnuradio/packet_utils.py')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/packet_utils.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/gnuradio-core/src/python/gnuradio/packet_utils.py b/gnuradio-core/src/python/gnuradio/packet_utils.py index 7d4871473c..1dab48ab42 100644 --- a/gnuradio-core/src/python/gnuradio/packet_utils.py +++ b/gnuradio-core/src/python/gnuradio/packet_utils.py @@ -71,7 +71,8 @@ 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 = \ + conv_packed_binary_string_to_1_0_string('\xAA\xAA\xAA\xAB') def is_1_0_string(s): if not isinstance(s, str): @@ -97,16 +98,17 @@ def dewhiten(s): def make_header(payload_len): return struct.pack('!HH', payload_len, payload_len) -def make_packet(payload, spb, bits_per_baud, access_code=default_access_code, pad_for_usrp=True): +def make_packet(payload, samples_per_symbol, bits_per_symbol, + access_code=default_access_code, pad_for_usrp=True): """ Build a packet, given access code and payload. - @param payload: packet payload, len [0, 4096] - @param spb: samples per baud (needed for padding calculation) - @type spb: int - @param bits_per_baud: (needed for padding calculation) - @type bits_per_baud: int - @param access_code: string of ascii 0's and 1's + @param payload: packet payload, len [0, 4096] + @param samples_per_symbol: samples per symbol (needed for padding calculation) + @type samples_per_symbol: int + @param bits_per_symbol: (needed for padding calculation) + @type bits_per_symbol: int + @param access_code: string of ascii 0's and 1's Packet will have access code at the beginning, followed by length, payload and finally CRC-32. @@ -115,6 +117,7 @@ def make_packet(payload, spb, bits_per_baud, access_code=default_access_code, pa raise ValueError, "access_code must be a string containing only 0's and 1's (%r)" % (access_code,) (packed_access_code, padded) = conv_1_0_string_to_packed_binary_string(access_code) + (packed_preamble, ignore) = conv_1_0_string_to_packed_binary_string(preamble) payload_with_crc = gru.gen_and_append_crc32(payload) #print "outbound crc =", string_to_hex_list(payload_with_crc[-4:]) @@ -124,14 +127,14 @@ def make_packet(payload, spb, bits_per_baud, access_code=default_access_code, pa if L > MAXLEN: raise ValueError, "len(payload) must be in [0, %d]" % (MAXLEN,) - pkt = ''.join((packed_access_code, make_header(L), whiten(payload_with_crc), '\x55')) + pkt = ''.join((packed_preamble, packed_access_code, make_header(L), whiten(payload_with_crc), '\x55')) if pad_for_usrp: - pkt = pkt + (_npadding_bytes(len(pkt), spb, bits_per_baud) * '\x55') + pkt = pkt + (_npadding_bytes(len(pkt), samples_per_symbol, bits_per_symbol) * '\x55') #print "make_packet: len(pkt) =", len(pkt) return pkt -def _npadding_bytes(pkt_byte_len, spb, bits_per_baud): +def _npadding_bytes(pkt_byte_len, samples_per_symbol, bits_per_symbol): """ Generate sufficient padding such that each packet ultimately ends up being a multiple of 512 bytes when sent across the USB. We @@ -140,13 +143,13 @@ def _npadding_bytes(pkt_byte_len, spb, bits_per_baud): is a multiple of 128 samples. @param ptk_byte_len: len in bytes of packet, not including padding. - @param spb: samples per baud == samples per bit (1 bit / baud with GMSK) - @type spb: int + @param samples_per_symbol: samples per bit (1 bit / symbolwith GMSK) + @type samples_per_symbol: int @returns number of bytes of padding to append. """ modulus = 128 - byte_modulus = gru.lcm(modulus/8, spb) * bits_per_baud / spb + byte_modulus = gru.lcm(modulus/8, samples_per_symbol) * bits_per_symbol / samples_per_symbol r = pkt_byte_len % byte_modulus if r == 0: return 0 |