On Tue, Feb 18, 2014 at 12:50 PM, David Halls <david.ha...@toshiba-trel.com> wrote: > Hi All, > > I have implemented a python source block: > > def __init__(self, kA1=4,kB1=4,k2=4,NA1=8,NB1=8,N2=8,M=8): > gr.sync_block.__init__(self, > name="blsd_enc_b", > in_sig=None, > out_sig=[numpy.uint8,numpy.uint8]) > > > but I can't get it to output anything but 0's.... > > def work(self, input_items, output_items): > out_cA = output_items[0] > out_cB = output_items[1] > > out_cA = [ 5, 6, 7, 8, 9, 10 ] #cA[0] > out_cB = [ 5, 6, 7, 8, 9, 10 ] #cB[0] > self.produce(0,len(out_cA)) > self.produce(1,len(out_cB)) > print 'out_cA = ', out_cA, ', len(out_cA) = ', len(out_cA) > print 'out_cB = ', out_cB, ', len(out_cB) = ', len(out_cB) > return -1 #-2 > > > I connect both outputs to a file sync of type byte, and it stores 6 bytes > but its all "\00\00\00\00\00\00" > > The print lines give: > > out_cA = [5, 6, 7, 8, 9, 10] , len(out_cA) = 6 > out_cB = [5, 6, 7, 8, 9, 10] , len(out_cB) = 6 > > as expected. > > Any advice? > > Regards, > > David >
David, The problem here is that you're not inserting items in to the out_cA (and out_cB) arrays, you're actually reassigning out_cA to be this new list. Honestly, I've never written a python block, but my understanding is that you'd have to do something like this http://dpaste.com/1634971/ The items in the out_items list are actually numpy arrays, and they need to be indexed. The [:] indexing is a shortcut of indexing the entire array. Another thing I'm not really sure about is whether the -1 will work or not. I think you might have to return 6 so that the scheduler knows there are 6 items to work on, and then the next time work is called you return -1 ( assuming you're wanting to stop the flowgraph here?). Somebody else might chime in here if I'm wrong. Nathan _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio