|
From: | Tom Rondeau |
Subject: | Re: [Discuss-gnuradio] Problem loading Python block |
Date: | Tue, 29 Jan 2013 08:16:06 -0500 |
I'm not sure what you mean by "load gr.basic_block." Do you mean inherit from?I want to make my block which very similar to packet deframer. Here is th code: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)in the same file is also defined class helper_block in this way: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"
when I try to run test or flowgraph, I get this error:in <module>
class helper_block(gr.basic_block):-- Process completed
AttributeError: 'module' object has no attribute 'basic_block'
***Failed
0% tests passed, 1 tests failed out of 1
And in tutorial on how to write signal processing block, it is stated to use gr.basic_block.
[Prev in Thread] | Current Thread | [Next in Thread] |