On Sat, Mar 8, 2008 at 11:20 PM, Manav Rohil <[EMAIL PROTECTED]> wrote: > > I am getting segmentation fault with the following... > > src_data = (0xff,) > src = gr.vector_source_b(src_data,False) > #expected_results = (1,0,0,0,0,0,0,0) > op = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) > op1= gr.head (gr.sizeof_char, 1) > tb.connect(src,op,op1) > dst = gr.vector_sink_b() > tb.connect(op,dst) > tb.connect(op, > gr.file_sink(gr.sizeof_char, > "tx_bytes2chunks.dat")) > tb.connect(op1, > gr.file_sink(gr.sizeof_char, "tx_bytes2bits.dat")) > > All that i m trying to do is extract the 1st bit of the vector. > Need help urgently.Am new to GNU radio > -- > Posted via http://www.ruby-forum.com/. > > > _______________________________________________ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > http://lists.gnu.org/mailman/listinfo/discuss-gnuradio >
This works for me (note the "del tb" line): from gnuradio import gr def print_data(d): """Debugging tool""" print 'Byte\tDec\tHex' for i in range(len(d)): b = ord(d[i]) print '%4d\t%3d\t %02X' % (i, b, b) class MyTopBlock(gr.top_block): def __init__(self): gr.top_block.__init__(self) src_data = (0xff,) src = gr.vector_source_b(src_data,False) op = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) op1= gr.head (gr.sizeof_char, 1) self.connect(src,op,op1) dst = gr.vector_sink_b() self.connect(op,dst) self.connect(op, gr.file_sink(gr.sizeof_char,"tx_bytes2chunks.dat")) self.connect(op1, gr.file_sink(gr.sizeof_char, "tx_bytes2bits.dat")) def main(): tb = MyTopBlock() tb.run() del tb #this makes sure files are flushed f = open("tx_bytes2chunks.dat") print_data(f.read()) f.close() f = open("tx_bytes2bits.dat") print_data(f.read()) f.close() if __name__ == '__main__': main() _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnuradio