OK, I'll try to explain everything.
I want to design block responsible for decoding messages, calculating
crc, etc ... In order to do that I investigated packet_demod_base block
from main gnuradio branch,
and also
packet_deframer from gr_extras group of blocks. I realized that such
kind of blocks consists of correlator, framer sink which acts like
message sink, and finally of some kind of message source. Framer sink
sends messages to message
source and message source then does packet checking and everything.
I also wanted to design my block in that fashion, so I used correlator and framer sink and I wanted to design my own block which is able to receive messages from packet framer and to check it. The code I provided in the last post is my own, and not the part of gnuradio. Here is complete source file of my block:
import numpy
from math import pi
from gnuradio import gr
from gruel import pmt
from gnuradio.digital import packet_utils
import gnuradio.digital as gr_digital
class packet_tst(gr.hier_block2):
def __init__(self, access_code=None, threshold=-1):
gr.hier_block2.__init__(
self,
"packet_tst",
gr.io_signature(1, 1, 1), # Input signature
gr.io_signature(0, 0, 0) # Output signature
)
if not access_code:
access_code = packet_utils.default_access_code
if not packet_utils.is_1_0_string(access_code):
raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,)
if threshold == -1:
threshold = 12 # FIXME raise exception
msgq = gr.msg_queue(4) # holds packets from the PHY
self.correlator = gr_digital.correlate_access_code_bb(access_code, threshold)
self.framer_sink = gr.framer_sink_1(msgq)
self.connect(self, self.correlator, self.framer_sink)
self.hlp_blk = helper_block(msgq)
class helper_block(gr.basic_block):
def __init__(self, msgq):
gr.basic_block.__init__(
self, name = "helper_block",
in_sig = None, out_sig = None
# num_msg_outputs = 1
)
self._msgq = msgq
def work(self, input_items, output_items): while True:
try: msg = self._msgq.delete_head() except: return -1
print "Message received"At the moment the block is designed only to write something to standard output if it receives a message. The problem is gr.basic_block as I described in previous post. Python interpreter doesn't complain about gr.hier_block2, but only about gr.basic_block.