0

I am trying to write a custom GNU Radio block in Python. I have an array of bytes which I am trying to output so it can be written to the file via the file sink block.

When I simply set the output_items to be the data I want to be outputted:

output_items[0] = np.array(data,dtype=np.int8)

It does not work, the file is not the output.

When I do a loop over the size of the output_items, it works fine:

for i in range(len(output_items[0])):
       output_items[0][i] = 0

This works. Is there a way to specify the size of the output_items array I want? I thought I could accomplish this by returning the output size of the array but it did not work.

jsttn
  • 1,495
  • 3
  • 16
  • 21

1 Answers1

0

You need to fill in the values in the output buffer, which means overwriting the contents of output_items[0], not overwriting the python element itself.

What'll work is:

 output_items[0][:] = np.array(data,dtype=np.int8)
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • When I do this I get an error "could not broadcast input array from shape (184) into shape (6964)." This makes sense to me as the data I want to output is 184 bits while the input data is 6964 bits – jsttn Sep 06 '18 at 18:55
  • indeed. And that's by design! – Marcus Müller May 15 '23 at 17:01