On Tue, Jan 29, 2013 at 7:40 AM, Nemanja Savic <vlasi...@gmail.com> wrote:
> 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" > > I have no idea what files these are from. Are they part of the GNU Radio source code? I can't find references to them. > when I try to run test or flowgraph, I get this error: > > in <module> >> class helper_block(gr.basic_block): >> >> AttributeError: 'module' object has no attribute 'basic_block' >> -- Process completed >> ***Failed >> >> 0% tests passed, 1 tests failed out of 1 > > Sounds like you don't have something installed correctly. You wouldn't normally be inheriting straight from gr_basic_block, but you should be able to. > And in tutorial on how to write signal processing block, it is stated to > use gr.basic_block. > Which tutorial? Again, I don't think this is in the main GNU Radio source, so please point out where you are getting this from. Tom
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio