Added OFDM Mod and Demod to GRC (cough cough... kludge).
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Thu, 12 Mar 2009 06:53:54 +0000 (06:53 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Thu, 12 Mar 2009 06:53:54 +0000 (06:53 +0000)
Generalized the packet mod and demod stuff to accept the OFDM blocks.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10585 221aa14e-8319-0410-a670-987f0aec2ac5

grc/data/platforms/python/block_tree.xml
grc/data/platforms/python/blocks/Makefile.am
grc/data/platforms/python/blocks/blks2_ofdm_demod.xml [new file with mode: 0644]
grc/data/platforms/python/blocks/blks2_ofdm_mod.xml [new file with mode: 0644]
grc/data/platforms/python/blocks/blks2_packet_decoder.xml
grc/data/platforms/python/blocks/blks2_packet_encoder.xml
grc/src/grc_gnuradio/blks2/__init__.py
grc/src/grc_gnuradio/blks2/packet.py
grc/todo.txt

index b56073bbfcd6dc78cb0b15c0b3a9299f737934b2..bb2d681f08761a8061fe4c63976b92e873ec4986 100644 (file)
                <block>blks2_qamx_mod</block>
                <block>blks2_qamx_demod</block>
 
+               <block>blks2_ofdm_mod</block>
+               <block>blks2_ofdm_demod</block>
+
                <block>blks2_synthesis_filterbank</block>
                <block>blks2_analysis_filterbank</block>
        </cat>
index 3655b1311c41ba690d416e2abc7c25731f241e3c..6b09050f39b5147d7079f24ad515a01dde91d36b 100644 (file)
@@ -42,6 +42,8 @@ dist_ourdata_DATA = \
        blks2_logpwrfft_x.xml \
        blks2_nbfm_rx.xml \
        blks2_nbfm_tx.xml \
+       blks2_ofdm_demod.xml \
+       blks2_ofdm_mod.xml \
        blks2_packet_decoder.xml \
        blks2_packet_encoder.xml \
        blks2_qamx_demod.xml \
diff --git a/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml b/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml
new file mode 100644 (file)
index 0000000..ac5ee47
--- /dev/null
@@ -0,0 +1,122 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##OFDM Demod
+###################################################
+ -->
+<block>
+       <name>OFDM Demod</name>
+       <key>blks2_ofdm_demod</key>
+       <import>from grc_gnuradio import blks2 as grc_blks2</import>
+       <import>from gnuradio import blks2</import>
+       <make>grc_blks2.packet_demod_$(type.fcn)(blks2.ofdm_demod(
+               options=grc_blks2.options(
+                       modulation="$modulation",
+                       fft_length=$fft_length,
+                       occupied_tones=$occupied_tones,
+                       cp_length=$cp_length,
+                       snr=$snr,
+                       log=None,
+                       verbose=None,
+               ),
+               callback=lambda ok, payload: self.$(id).recv_pkt(ok, payload),
+       ),
+)</make>
+       <param>
+               <name>Output Type</name>
+               <key>type</key>
+               <value>float</value>
+               <type>enum</type>
+               <option>
+                       <name>Complex</name>
+                       <key>complex</key>
+                       <opt>fcn:c</opt>
+               </option>
+               <option>
+                       <name>Float</name>
+                       <key>float</key>
+                       <opt>fcn:f</opt>
+               </option>
+               <option>
+                       <name>Int</name>
+                       <key>int</key>
+                       <opt>fcn:i</opt>
+               </option>
+               <option>
+                       <name>Short</name>
+                       <key>short</key>
+                       <opt>fcn:s</opt>
+               </option>
+               <option>
+                       <name>Byte</name>
+                       <key>byte</key>
+                       <opt>fcn:b</opt>
+               </option>
+       </param>
+       <param>
+               <name>Modulation</name>
+               <key>modulation</key>
+               <type>enum</type>
+               <option>
+                       <name>BPSK</name>
+                       <key>bpsk</key>
+               </option>
+               <option>
+                       <name>QPSK</name>
+                       <key>qpsk</key>
+               </option>
+               <option>
+                       <name>8PSK</name>
+                       <key>8psk</key>
+               </option>
+               <option>
+                       <name>QAM8</name>
+                       <key>qam8</key>
+               </option>
+               <option>
+                       <name>QAM16</name>
+                       <key>qam16</key>
+               </option>
+               <option>
+                       <name>QAM64</name>
+                       <key>qam64</key>
+               </option>
+               <option>
+                       <name>QAM256</name>
+                       <key>qam256</key>
+               </option>
+       </param>
+       <param>
+               <name>FFT Length</name>
+               <key>fft_length</key>
+               <value>512</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Occupied Tones</name>
+               <key>occupied_tones</key>
+               <value>200</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Cyclic Prefix Length</name>
+               <key>cp_length</key>
+               <value>128</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>SNR</name>
+               <key>snr</key>
+               <value>10</value>
+               <type>real</type>
+       </param>
+       <sink>
+               <name>in</name>
+               <type>complex</type>
+       </sink>
+       <source>
+               <name>out</name>
+               <type>$type</type>
+       </source>
+       <doc>Payload Length: 0 for automatic.</doc>
+</block>
diff --git a/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml b/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml
new file mode 100644 (file)
index 0000000..2c54d10
--- /dev/null
@@ -0,0 +1,135 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##OFDM Mod
+###################################################
+ -->
+<block>
+       <name>OFDM Mod</name>
+       <key>blks2_ofdm_mod</key>
+       <import>from grc_gnuradio import blks2 as grc_blks2</import>
+       <import>from gnuradio import blks2</import>
+       <make>grc_blks2.packet_mod_$(type.fcn)(blks2.ofdm_mod(
+               options=grc_blks2.options(
+                       modulation="$modulation",
+                       fft_length=$fft_length,
+                       occupied_tones=$occupied_tones,
+                       cp_length=$cp_length,
+                       pad_for_usrp=$pad_for_usrp,
+                       log=None,
+                       verbose=None,
+               ),
+       ),
+       payload_length=$payload_length,
+)</make>
+       <param>
+               <name>Input Type</name>
+               <key>type</key>
+               <value>float</value>
+               <type>enum</type>
+               <option>
+                       <name>Complex</name>
+                       <key>complex</key>
+                       <opt>fcn:c</opt>
+               </option>
+               <option>
+                       <name>Float</name>
+                       <key>float</key>
+                       <opt>fcn:f</opt>
+               </option>
+               <option>
+                       <name>Int</name>
+                       <key>int</key>
+                       <opt>fcn:i</opt>
+               </option>
+               <option>
+                       <name>Short</name>
+                       <key>short</key>
+                       <opt>fcn:s</opt>
+               </option>
+               <option>
+                       <name>Byte</name>
+                       <key>byte</key>
+                       <opt>fcn:b</opt>
+               </option>
+       </param>
+       <param>
+               <name>Modulation</name>
+               <key>modulation</key>
+               <type>enum</type>
+               <option>
+                       <name>BPSK</name>
+                       <key>bpsk</key>
+               </option>
+               <option>
+                       <name>QPSK</name>
+                       <key>qpsk</key>
+               </option>
+               <option>
+                       <name>8PSK</name>
+                       <key>8psk</key>
+               </option>
+               <option>
+                       <name>QAM8</name>
+                       <key>qam8</key>
+               </option>
+               <option>
+                       <name>QAM16</name>
+                       <key>qam16</key>
+               </option>
+               <option>
+                       <name>QAM64</name>
+                       <key>qam64</key>
+               </option>
+               <option>
+                       <name>QAM256</name>
+                       <key>qam256</key>
+               </option>
+       </param>
+       <param>
+               <name>FFT Length</name>
+               <key>fft_length</key>
+               <value>512</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Occupied Tones</name>
+               <key>occupied_tones</key>
+               <value>200</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Cyclic Prefix Length</name>
+               <key>cp_length</key>
+               <value>128</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>Pad for USRP</name>
+               <key>pad_for_usrp</key>
+               <type>enum</type>
+               <option>
+                       <name>Yes</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>No</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Payload Length</name>
+               <key>payload_length</key>
+               <value>0</value>
+               <type>int</type>
+       </param>
+       <sink>
+               <name>in</name>
+               <type>$type</type>
+       </sink>
+       <source>
+               <name>out</name>
+               <type>complex</type>
+       </source>
+       <doc>Payload Length: 0 for automatic.</doc>
+</block>
index d360bc1775af320661ca42830439f301c8f894fb..07b0d1f2eb09cf75dcdefe195062fa2244343565 100644 (file)
@@ -8,11 +8,11 @@
        <name>Packet Decoder</name>
        <key>blks2_packet_decoder</key>
        <import>from grc_gnuradio import blks2 as grc_blks2</import>
-       <import>from gnuradio import gr</import>
-       <make>grc_blks2.packet_decoder(
-       item_size_out=$type.size*$vlen,
-       access_code=$access_code,
-       threshold=$threshold,
+       <make>grc_blks2.packet_demod_$(type.fcn)(grc_blks2.packet_decoder(
+               access_code=$access_code,
+               threshold=$threshold,
+               callback=lambda ok, payload: self.$(id).recv_pkt(ok, payload),
+       ),
 )</make>
        <param>
                <name>Output Type</name>
                <option>
                        <name>Complex</name>
                        <key>complex</key>
-                       <opt>size:gr.sizeof_gr_complex</opt>
+                       <opt>fcn:c</opt>
                </option>
                <option>
                        <name>Float</name>
                        <key>float</key>
-                       <opt>size:gr.sizeof_float</opt>
+                       <opt>fcn:f</opt>
                </option>
                <option>
                        <name>Int</name>
                        <key>int</key>
-                       <opt>size:gr.sizeof_int</opt>
+                       <opt>fcn:i</opt>
                </option>
                <option>
                        <name>Short</name>
                        <key>short</key>
-                       <opt>size:gr.sizeof_short</opt>
+                       <opt>fcn:s</opt>
                </option>
                <option>
                        <name>Byte</name>
                        <key>byte</key>
-                       <opt>size:gr.sizeof_char</opt>
+                       <opt>fcn:b</opt>
                </option>
        </param>
        <param>
                <value>-1</value>
                <type>int</type>
        </param>
-       <param>
-               <name>Vec Length</name>
-               <key>vlen</key>
-               <value>1</value>
-               <type>int</type>
-       </param>
-       <check>$vlen &gt; 0</check>
        <sink>
                <name>in</name>
                <type>byte</type>
        <source>
                <name>out</name>
                <type>$type</type>
-               <vlen>$vlen</vlen>
        </source>
        <doc>
 Packet decoder block, for use with the gnuradio demodulator blocks: gmsk, psk, qam.
 
-Access Code: string of 1's and 0's, leave blank for default.
+Access Code: string of 1's and 0's, leave blank for automatic.
+
+Threshold: -1 for automatic.
        </doc>
 </block>
index ea9927225ec8c3fc8d695fb003872d4b79a9f60a..b184ebd31c057d7e758a5c49209be375682adc91 100644 (file)
@@ -8,13 +8,12 @@
        <name>Packet Encoder</name>
        <key>blks2_packet_encoder</key>
        <import>from grc_gnuradio import blks2 as grc_blks2</import>
-       <import>from gnuradio import gr</import>
-       <make>grc_blks2.packet_encoder(
-       item_size_in=$type.size*$vlen,
-       samples_per_symbol=$samples_per_symbol,
-       bits_per_symbol=$bits_per_symbol,
-       access_code=$access_code,
-       pad_for_usrp=$pad_for_usrp,
+       <make>grc_blks2.packet_mod_$(type.fcn)(grc_blks2.packet_encoder(
+               samples_per_symbol=$samples_per_symbol,
+               bits_per_symbol=$bits_per_symbol,
+               access_code=$access_code,
+               pad_for_usrp=$pad_for_usrp,
+       ),
        payload_length=$payload_length,
 )</make>
        <param>
                <option>
                        <name>Complex</name>
                        <key>complex</key>
-                       <opt>size:gr.sizeof_gr_complex</opt>
+                       <opt>fcn:c</opt>
                </option>
                <option>
                        <name>Float</name>
                        <key>float</key>
-                       <opt>size:gr.sizeof_float</opt>
+                       <opt>fcn:f</opt>
                </option>
                <option>
                        <name>Int</name>
                        <key>int</key>
-                       <opt>size:gr.sizeof_int</opt>
+                       <opt>fcn:i</opt>
                </option>
                <option>
                        <name>Short</name>
                        <key>short</key>
-                       <opt>size:gr.sizeof_short</opt>
+                       <opt>fcn:s</opt>
                </option>
                <option>
                        <name>Byte</name>
                        <key>byte</key>
-                       <opt>size:gr.sizeof_char</opt>
+                       <opt>fcn:b</opt>
                </option>
        </param>
        <param>
        <param>
                <name>Payload Length</name>
                <key>payload_length</key>
-               <value>-1</value>
+               <value>0</value>
                <type>int</type>
        </param>
-       <param>
-               <name>Vec Length</name>
-               <key>vlen</key>
-               <value>1</value>
-               <type>int</type>
-       </param>
-       <check>$vlen &gt; 0</check>
        <sink>
                <name>in</name>
                <type>$type</type>
-               <vlen>$vlen</vlen>
        </sink>
        <source>
                <name>out</name>
                <type>byte</type>
        </source>
        <doc>
-Packet encoder block, for use with the gnuradio modulator blocks: gmsk, psk, qam.
+Packet encoder block, for use with the gnuradio modulator blocks: gmsk, dpsk, qam.
+
+Access Code: string of 1's and 0's, leave blank for automatic.
 
-Access Code: string of 1's and 0's, leave blank for default.
+Payload Length: 0 for automatic.
 
 Bits/Symbol should be set accordingly:
        gmsk -> 1
index 1705a3f9bcee4a4acbe0a3841e698540bba21e00..185230ab002d41a7a07161c553e1b24740d95e6c 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -19,6 +19,8 @@
 #
 
 from selector import selector, valve
-from packet import packet_encoder, packet_decoder
+from packet import options, packet_encoder, packet_decoder, \
+       packet_mod_b, packet_mod_s, packet_mod_i, packet_mod_f, packet_mod_c, \
+       packet_demod_b, packet_demod_s, packet_demod_i, packet_demod_f, packet_demod_c
 from error_rate import error_rate
 from probe import probe_function, probe_avg_mag_sqrd_c, probe_avg_mag_sqrd_f, probe_density_b, probe_mpsk_snr_c
index fcdfb9ae2a9f2916311ce59826b7f0081934036e..a305b961ecb52d8f9828ab0c4e89c7512328a36f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -30,10 +30,16 @@ DEFAULT_MSGQ_LIMIT = 2
 ##threshold for unmaking packets
 DEFAULT_THRESHOLD = 12
 
-#######################################################################################
-## Packet Encoder
-#######################################################################################
+##################################################
+## Options Class for OFDM
+##################################################
+class options(object):
+       def __init__(self, **kwargs):
+               for key, value in kwargs.iteritems(): setattr(self, key, value)
 
+##################################################
+## Packet Encoder
+##################################################
 class _packet_encoder_thread(_threading.Thread):
 
        def __init__(self, msgq, payload_length, send):
@@ -51,7 +57,7 @@ class _packet_encoder_thread(_threading.Thread):
                        msg = self._msgq.delete_head() #blocking read of message queue
                        sample = sample + msg.to_string() #get the body of the msg as a string
                        while len(sample) >= self._payload_length:
-                               payload = sample[0:self._payload_length]
+                               payload = sample[:self._payload_length]
                                sample = sample[self._payload_length:]
                                self._send(payload)
 
@@ -60,10 +66,9 @@ class packet_encoder(gr.hier_block2):
        Hierarchical block for wrapping packet-based modulators.
        """
 
-       def __init__(self, item_size_in, samples_per_symbol, bits_per_symbol, access_code='', pad_for_usrp=True, payload_length=-1):
+       def __init__(self, samples_per_symbol, bits_per_symbol, access_code='', pad_for_usrp=True):
                """
                packet_mod constructor.
-               @param item_size_in the size of the input data stream in bytes
                @param samples_per_symbol number of samples per symbol
                @param bits_per_symbol number of bits per symbol
                @param access_code AKA sync vector
@@ -71,7 +76,6 @@ class packet_encoder(gr.hier_block2):
                @param payload_length number of bytes in a data-stream slice
                """
                #setup parameters
-               self._item_size_in = item_size_in
                self._samples_per_symbol = samples_per_symbol
                self._bits_per_symbol = bits_per_symbol
                self._pad_for_usrp = pad_for_usrp
@@ -81,30 +85,20 @@ class packet_encoder(gr.hier_block2):
                        raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
                self._access_code = access_code
                self._pad_for_usrp = pad_for_usrp
-               if payload_length < 0: #get payload length
-                       payload_length = DEFAULT_PAYLOAD_LEN
-               if payload_length%self._item_size_in != 0:      #verify that packet length is a multiple of the stream size
-                       raise ValueError, 'The packet length: "%d" is not a mutiple of the stream size: "%d".'%(payload_length, self._item_size_in)
-               self._payload_length = payload_length
                #create blocks
                msg_source = gr.message_source(gr.sizeof_char, DEFAULT_MSGQ_LIMIT)
                self._msgq_out = msg_source.msgq()
-               self._msgq_in = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
-               msg_sink = gr.message_sink(self._item_size_in, self._msgq_in, False) #False -> blocking
                #initialize hier2
                gr.hier_block2.__init__(
                        self,
                        "packet_encoder",
-                       gr.io_signature(1, 1, self._item_size_in), # Input signature
+                       gr.io_signature(0, 0, 0), # Input signature
                        gr.io_signature(1, 1, gr.sizeof_char) # Output signature
                )
                #connect
-               self.connect(self, msg_sink)
                self.connect(msg_source, self)
-               #start thread
-               _packet_encoder_thread(self._msgq_in, self._payload_length, self._send_packet)
 
-       def _send_packet(self, payload):
+       def send_pkt(self, payload):
                """
                Wrap the payload in a packet and push onto the message queue.
                @param payload string, data to send
@@ -119,41 +113,38 @@ class packet_encoder(gr.hier_block2):
                msg = gr.message_from_string(packet)
                self._msgq_out.insert_tail(msg)
 
-#######################################################################################
+##################################################
 ## Packet Decoder
-#######################################################################################
-
+##################################################
 class _packet_decoder_thread(_threading.Thread):
 
-    def __init__(self, msgq, callback):
-        _threading.Thread.__init__(self)
-        self.setDaemon(1)
-        self._msgq = msgq
-        self.callback = callback
-        self.keep_running = True
-        self.start()
-
-    def run(self):
-        while self.keep_running:
-            msg = self._msgq.delete_head()
-            ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()))
-            if self.callback:
-                self.callback(ok, payload)
+       def __init__(self, msgq, callback):
+               _threading.Thread.__init__(self)
+               self.setDaemon(1)
+               self._msgq = msgq
+               self.callback = callback
+               self.keep_running = True
+               self.start()
+
+       def run(self):
+               while self.keep_running:
+                       msg = self._msgq.delete_head()
+                       ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1()))
+                       if self.callback:
+                               self.callback(ok, payload)
 
 class packet_decoder(gr.hier_block2):
        """
        Hierarchical block for wrapping packet-based demodulators.
        """
 
-       def __init__(self, item_size_out, access_code='', threshold=-1):
+       def __init__(self, access_code='', threshold=-1, callback=None):
                """
                packet_demod constructor.
-               @param item_size_out the size of the output data stream in bytes
                @param access_code AKA sync vector
-               @param threshold detect access_code with up to threshold bits wrong (-1 -> use default)
+               @param threshold detect access_code with up to threshold bits wrong (0 -> use default)
+               @param callback a function of args: ok, payload
                """
-               #setup
-               self._item_size_out = item_size_out
                #access code
                if not access_code: #get access code
                        access_code = packet_utils.default_access_code
@@ -164,29 +155,89 @@ class packet_decoder(gr.hier_block2):
                if threshold < 0: threshold = DEFAULT_THRESHOLD
                self._threshold = threshold
                #blocks
-               self._msgq_in = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY
+               msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY
                correlator = gr.correlate_access_code_bb(self._access_code, self._threshold)
-               framer_sink = gr.framer_sink_1(self._msgq_in)
-               msg_source = gr.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
-               self._msgq_out = msg_source.msgq()
+               framer_sink = gr.framer_sink_1(msgq)
                #initialize hier2
                gr.hier_block2.__init__(
                        self,
                        "packet_decoder",
                        gr.io_signature(1, 1, gr.sizeof_char), # Input signature
-                       gr.io_signature(1, 1, self._item_size_out) # Output signature
+                       gr.io_signature(0, 0, 0) # Output signature
                )
                #connect
                self.connect(self, correlator, framer_sink)
-               self.connect(msg_source, self)
                #start thread
-               _packet_decoder_thread(self._msgq_in, self._recv_packet)
+               _packet_decoder_thread(msgq, callback)
 
-       def _recv_packet(self, ok, payload):
-               """
-               Extract the payload from the packet and push onto message queue.
-               @param ok boolean ok
-               @param payload data received
-               """
+##################################################
+## Packet Mod for OFDM Mod and Packet Encoder
+##################################################
+class packet_mod_base(gr.hier_block2):
+       """
+       Hierarchical block for wrapping packet source block.
+       """
+
+       def __init__(self, packet_source=None, payload_length=0):
+               if not payload_length: #get payload length
+                       payload_length = DEFAULT_PAYLOAD_LEN
+               if payload_length%self._item_size_in != 0:      #verify that packet length is a multiple of the stream size
+                       raise ValueError, 'The payload length: "%d" is not a mutiple of the stream size: "%d".'%(payload_length, self._item_size_in)
+               #initialize hier2
+               gr.hier_block2.__init__(
+                       self,
+                       "ofdm_mod",
+                       gr.io_signature(1, 1, self._item_size_in), # Input signature
+                       gr.io_signature(1, 1, packet_source._hb.output_signature().sizeof_stream_item(0)) # Output signature
+               )
+               #create blocks
+               msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT)
+               msg_sink = gr.message_sink(self._item_size_in, msgq, False) #False -> blocking
+               copy = gr.kludge_copy(packet_source._hb.output_signature().sizeof_stream_item(0))
+               #connect
+               self.connect(self, msg_sink)
+               self.connect(packet_source, copy, self)
+               #start thread
+               _packet_encoder_thread(msgq, payload_length, packet_source.send_pkt)
+
+class packet_mod_b(packet_mod_base): _item_size_in = gr.sizeof_char
+class packet_mod_s(packet_mod_base): _item_size_in = gr.sizeof_short
+class packet_mod_i(packet_mod_base): _item_size_in = gr.sizeof_int
+class packet_mod_f(packet_mod_base): _item_size_in = gr.sizeof_float
+class packet_mod_c(packet_mod_base): _item_size_in = gr.sizeof_gr_complex
+
+##################################################
+## Packet Demod for OFDM Demod and Packet Decoder
+##################################################
+class packet_demod_base(gr.hier_block2):
+       """
+       Hierarchical block for wrapping packet sink block.
+       """
+
+       def __init__(self, packet_sink=None):
+               #initialize hier2
+               gr.hier_block2.__init__(
+                       self,
+                       "ofdm_mod",
+                       gr.io_signature(1, 1, packet_sink._hb.input_signature().sizeof_stream_item(0)), # Input signature
+                       gr.io_signature(1, 1, self._item_size_out) # Output signature
+               )
+               #create blocks
+               msg_source = gr.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT)
+               self._msgq_out = msg_source.msgq()
+               copy = gr.kludge_copy(packet_sink._hb.input_signature().sizeof_stream_item(0))
+               #connect
+               self.connect(self, copy, packet_sink)
+               self.connect(msg_source, self)
+               if packet_sink._hb.output_signature().sizeof_stream_item(0):
+                       self.connect(packet_sink, gr.null_sink(packet_sink._hb.output_signature().sizeof_stream_item(0)))
+
+       def recv_pkt(self, ok, payload):
                msg = gr.message_from_string(payload, 0, self._item_size_out, len(payload)/self._item_size_out)
                if ok: self._msgq_out.insert_tail(msg)
+
+class packet_demod_b(packet_demod_base): _item_size_out = gr.sizeof_char
+class packet_demod_s(packet_demod_base): _item_size_out = gr.sizeof_short
+class packet_demod_i(packet_demod_base): _item_size_out = gr.sizeof_int
+class packet_demod_f(packet_demod_base): _item_size_out = gr.sizeof_float
+class packet_demod_c(packet_demod_base): _item_size_out = gr.sizeof_gr_complex
index 845430d9d71ba1e9c4976e38938b80085d79b954..904128872eb4a0b64202d480e1385b1941d88772 100644 (file)
@@ -1,7 +1,6 @@
 ##################################################
 # Blocks
 ##################################################
--ofdm wrappers
 -probe: also non-float outputs
 -log slider gui control