-1

Is there a way to print (in the terminal or to a file) the input items passed to the work function and the output items produced there? I have written a GNU radio block (in Python) and I need to access the above information.

Any help is appreciated! :)

user1190937
  • 69
  • 2
  • 8
  • Do you mean *the number of items* or *the value of these items*? – Marcus Müller Jul 15 '16 at 10:22
  • How proficient are you with python? The input items are simply a normal numpy array... things should be pretty straightforward. – Marcus Müller Jul 15 '16 at 10:22
  • I need the value of these items. – user1190937 Jul 16 '16 at 07:31
  • Yes they are simple numpy arrays. But I need to know from where these values are passed. & printing them inside the work function did not work. – user1190937 Jul 16 '16 at 07:32
  • "from where"? Can you be more descriptive? The values you get in your block are the output of the upstream block! Also "printing them did not work": I don't understand. What did you expect, what did you get instead? Add all this info by [editing](http://stackoverflow.com/posts/38388041/edit) your question! – Marcus Müller Jul 16 '16 at 09:20

1 Answers1

2

Assuming you're using a sync_block as block type, your work function will look like this:

def work(self, input_items, output_items):

where input_items is a 2D-array. First axis is the input ports (you might have only one) and second axis is the input items. So, if you just want to print the input items of the first input port in the terminal, you can do something like:

for i in range(len(input_items[0])):
    print input_items[0][i]

Since you are producing the output items yourself within the work function, you can print them in the same manner after creating them.

Still, I think you try to solve something with this question that could be solved in another (better) way. Can you specify what you're trying to do with the information gathered by the printed input/output items?

Sbmueller
  • 83
  • 6