commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r10585 - in gnuradio/trunk/grc: . data/platforms/pytho


From: jblum
Subject: [Commit-gnuradio] r10585 - in gnuradio/trunk/grc: . data/platforms/python data/platforms/python/blocks src/grc_gnuradio/blks2
Date: Thu, 12 Mar 2009 00:53:55 -0600 (MDT)

Author: jblum
Date: 2009-03-12 00:53:54 -0600 (Thu, 12 Mar 2009)
New Revision: 10585

Added:
   gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml
   gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml
Modified:
   gnuradio/trunk/grc/data/platforms/python/block_tree.xml
   gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am
   gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_decoder.xml
   gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_encoder.xml
   gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py
   gnuradio/trunk/grc/src/grc_gnuradio/blks2/packet.py
   gnuradio/trunk/grc/todo.txt
Log:
Added OFDM Mod and Demod to GRC (cough cough... kludge).
Generalized the packet mod and demod stuff to accept the OFDM blocks.



Modified: gnuradio/trunk/grc/data/platforms/python/block_tree.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/block_tree.xml     2009-03-12 
01:31:31 UTC (rev 10584)
+++ gnuradio/trunk/grc/data/platforms/python/block_tree.xml     2009-03-12 
06:53:54 UTC (rev 10585)
@@ -213,6 +213,9 @@
                <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>

Modified: gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am 2009-03-12 
01:31:31 UTC (rev 10584)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am 2009-03-12 
06:53:54 UTC (rev 10585)
@@ -42,6 +42,8 @@
        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 \

Added: gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml        
                        (rev 0)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml        
2009-03-12 06:53:54 UTC (rev 10585)
@@ -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>

Added: gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml          
                (rev 0)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml  
2009-03-12 06:53:54 UTC (rev 10585)
@@ -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>

Modified: 
gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_decoder.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_decoder.xml    
2009-03-12 01:31:31 UTC (rev 10584)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_decoder.xml    
2009-03-12 06:53:54 UTC (rev 10585)
@@ -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>
@@ -22,27 +22,27 @@
                <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>
@@ -57,13 +57,6 @@
                <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>
@@ -71,11 +64,12 @@
        <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>

Modified: 
gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_encoder.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_encoder.xml    
2009-03-12 01:31:31 UTC (rev 10584)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/blks2_packet_encoder.xml    
2009-03-12 06:53:54 UTC (rev 10585)
@@ -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>
@@ -25,27 +24,27 @@
                <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>
@@ -80,30 +79,24 @@
        <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 default.
+Access Code: string of 1's and 0's, leave blank for automatic.
 
+Payload Length: 0 for automatic.
+
 Bits/Symbol should be set accordingly:
        gmsk -> 1
        dbpsk -> 1

Modified: gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py       2009-03-12 
01:31:31 UTC (rev 10584)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py       2009-03-12 
06:53:54 UTC (rev 10585)
@@ -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

Modified: gnuradio/trunk/grc/src/grc_gnuradio/blks2/packet.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/packet.py 2009-03-12 01:31:31 UTC 
(rev 10584)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/packet.py 2009-03-12 06:53:54 UTC 
(rev 10585)
@@ -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 @@
 ##threshold for unmaking packets
 DEFAULT_THRESHOLD = 12
 
-#######################################################################################
+##################################################
+## 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 @@
                        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 @@
        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 @@
                @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 @@
                        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 @@
                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 __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 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 @@
                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

Modified: gnuradio/trunk/grc/todo.txt
===================================================================
--- gnuradio/trunk/grc/todo.txt 2009-03-12 01:31:31 UTC (rev 10584)
+++ gnuradio/trunk/grc/todo.txt 2009-03-12 06:53:54 UTC (rev 10585)
@@ -1,7 +1,6 @@
 ##################################################
 # Blocks
 ##################################################
--ofdm wrappers
 -probe: also non-float outputs
 -log slider gui control
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]