1

I'm working with gnuradio 3.10.4 and usrp B200mini.
My flowgraph is very simple:

usrp source -> head block -> file sink

I want to store a fixed amount of data to file sink, then reconfigure usrp and start it to store again.
My Python program likes:

tb.start()
tb.wait()
tb.lock()
...reconfigure usrp...
tb.unlock()
tb.start()
...

But the second time when tb.start() is used, the file can be created successfully but no data is written to it. Can anyone tell me what's wrong with the program or provide any relevant docmutation becaouse I find little about it.
Thanks for your support.

Cines
  • 11
  • 3

1 Answers1

0

When you're not sure how to get a block to do what you want, or if it can, it can be useful to consult the source code of the block, because GNU Radio blocks are not always thoroughly documented.

Starting from this wiki page on Head we can see all the code. It's C++, but fairly simple, and you can ignore all the setup and just look at the lines that seem to be doing the work.

In head_impl::work in head_impl.cc, we can see that the way the block works is counting the number of items it has passed in d_ncopied_items and comparing that against d_nitems (the value you provided). There's nothing here that restarts the count.

We have to also check the header file, head_impl.h, because code may be there too. And there we find what you need:

    void reset() override { d_ncopied_items = 0; }

So, call reset() on the head block and it will forget about how many items it has already copied.

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
  • Thanks a lot, after resetting head block, it does work and each file has data. I definitely should learn to study the source code. :) – Cines Nov 14 '22 at 02:58