0

I'm trying to display "number of items on the output stream" in the flowgraph.

Is there a way to access the function: block__nitems_written(unsigned int which_output) from the flowgraph?

So far I have tried "from gnuradio import gr" and then use gr.block__nitems_written(0) as a value in a variable. The error I get is:

module object has no attribute block__nitems_written.

I think I am not calling the function properly. Any help will be appreciated!

player0
  • 124,011
  • 12
  • 67
  • 124
pratikc
  • 1
  • 1

1 Answers1

0

You're confusing things! That's not a property of a flow graph.

Each block has its own number of items that it's written to its output ports.

Hence, it's a method of gr.block, which you can only call with a block instance, i.e. typically as self.nitems_written(0) within a block's work method.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • Full question: Thanks that clarifies things. I have one follow up question on the point Each block has its own number of items: Let's say I have Block A -----> Block B ------> Block C and all of them are sync blocks, will each of them write different number of items on the output port or the scheduler decides how many items to be written for all the blocks at the beginning? Thanks – pratikc Jun 20 '18 at 14:56
  • the question is *when*? These blocks don't run synchronously, nor are they forced to consume all the input they get at once; so your question has no clear answer. When the flowgraph is done running because Block A decided it has no more items to produce, and then Block B consumed the last item and produced its last output item, and C then consumed all these, they'll have all the same numbers. – Marcus Müller Jun 20 '18 at 15:01
  • Thanks. Appreciate your help – pratikc Jun 20 '18 at 15:03
  • might clarify things: [https://www.gnuradio.org/blog/buffers](https://web.archive.org/web/20170118181415/http://gnuradio.org:80/blog/buffers/) – Marcus Müller Jun 20 '18 at 15:06
  • Thank you very much! I think this is very good explanation of the way buffers work – pratikc Jun 21 '18 at 03:28