summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorjblum2009-03-12 06:53:54 +0000
committerjblum2009-03-12 06:53:54 +0000
commit2c4a4e0c371b1cd0029901aa176915300a02f1b8 (patch)
treee251c87a4929b49e1695f4abb57dbbe1e1b0a000 /grc
parent48ecbf1162f9031ab7134bbb571efc345bc8d7bd (diff)
downloadgnuradio-2c4a4e0c371b1cd0029901aa176915300a02f1b8.tar.gz
gnuradio-2c4a4e0c371b1cd0029901aa176915300a02f1b8.tar.bz2
gnuradio-2c4a4e0c371b1cd0029901aa176915300a02f1b8.zip
Added OFDM Mod and Demod to GRC (cough cough... kludge).
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
Diffstat (limited to 'grc')
-rw-r--r--grc/data/platforms/python/block_tree.xml3
-rw-r--r--grc/data/platforms/python/blocks/Makefile.am2
-rw-r--r--grc/data/platforms/python/blocks/blks2_ofdm_demod.xml122
-rw-r--r--grc/data/platforms/python/blocks/blks2_ofdm_mod.xml135
-rw-r--r--grc/data/platforms/python/blocks/blks2_packet_decoder.xml32
-rw-r--r--grc/data/platforms/python/blocks/blks2_packet_encoder.xml39
-rw-r--r--grc/src/grc_gnuradio/blks2/__init__.py6
-rw-r--r--grc/src/grc_gnuradio/blks2/packet.py161
-rw-r--r--grc/todo.txt1
9 files changed, 401 insertions, 100 deletions
diff --git a/grc/data/platforms/python/block_tree.xml b/grc/data/platforms/python/block_tree.xml
index b56073bbf..bb2d681f0 100644
--- a/grc/data/platforms/python/block_tree.xml
+++ b/grc/data/platforms/python/block_tree.xml
@@ -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>
diff --git a/grc/data/platforms/python/blocks/Makefile.am b/grc/data/platforms/python/blocks/Makefile.am
index 3655b1311..6b09050f3 100644
--- a/grc/data/platforms/python/blocks/Makefile.am
+++ b/grc/data/platforms/python/blocks/Makefile.am
@@ -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
index 000000000..ac5ee4795
--- /dev/null
+++ b/grc/data/platforms/python/blocks/blks2_ofdm_demod.xml
@@ -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
index 000000000..2c54d10f4
--- /dev/null
+++ b/grc/data/platforms/python/blocks/blks2_ofdm_mod.xml
@@ -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>
diff --git a/grc/data/platforms/python/blocks/blks2_packet_decoder.xml b/grc/data/platforms/python/blocks/blks2_packet_decoder.xml
index d360bc177..07b0d1f2e 100644
--- a/grc/data/platforms/python/blocks/blks2_packet_decoder.xml
+++ b/grc/data/platforms/python/blocks/blks2_packet_decoder.xml
@@ -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>
diff --git a/grc/data/platforms/python/blocks/blks2_packet_encoder.xml b/grc/data/platforms/python/blocks/blks2_packet_encoder.xml
index ea9927225..b184ebd31 100644
--- a/grc/data/platforms/python/blocks/blks2_packet_encoder.xml
+++ b/grc/data/platforms/python/blocks/blks2_packet_encoder.xml
@@ -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,29 +79,23 @@
<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
diff --git a/grc/src/grc_gnuradio/blks2/__init__.py b/grc/src/grc_gnuradio/blks2/__init__.py
index 1705a3f9b..185230ab0 100644
--- a/grc/src/grc_gnuradio/blks2/__init__.py
+++ b/grc/src/grc_gnuradio/blks2/__init__.py
@@ -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
diff --git a/grc/src/grc_gnuradio/blks2/packet.py b/grc/src/grc_gnuradio/blks2/packet.py
index fcdfb9ae2..a305b961e 100644
--- a/grc/src/grc_gnuradio/blks2/packet.py
+++ b/grc/src/grc_gnuradio/blks2/packet.py
@@ -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
diff --git a/grc/todo.txt b/grc/todo.txt
index 845430d9d..904128872 100644
--- a/grc/todo.txt
+++ b/grc/todo.txt
@@ -1,7 +1,6 @@
##################################################
# Blocks
##################################################
--ofdm wrappers
-probe: also non-float outputs
-log slider gui control