discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] How do I know when my flow graph has finished in


From: Marcus Müller
Subject: Re: [Discuss-gnuradio] How do I know when my flow graph has finished in a non-blocking way?
Date: Wed, 02 Jul 2014 21:07:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Hi Eskil,

QT has its own threading library that you'll need to use to spawn a new thread to do the blocking calls in:
http://pyqt.sourceforge.net/Docs/PyQt4/qthread.html (sadly, that page is still C++ centric)

PyQT4 usually comes with a set of nice examples, which have been useful for me over the last days; for me, those installed to
/usr/share/doc/PyQt4-devel-4.10.1/examples
and for your threading intents, you might want to look at
/usr/share/doc/PyQt4-devel-4.10.1/examples/network/threadedfortuneserver.py

Greetings, and happy hacking,
Marcus

On 02.07.2014 20:27, Eskil Varenius wrote:
Dear friends of GNU Radio,
I have a question about blocking, threads and GUI. Thing is, I am writing
an GUI application (in PyQT4) where the user can start a GNU Radio
flowgraph by a button. The flowgraph records data from an USRP and some
additional blocks. Now, I want only a finite amount of data so I have added
a "head" block to my flowgraph. The obvious way to run this is as the
following pseudo code program:
# Define flowgraph
class USRP(gr.top_block)
...connect USRP -> head_block_> file_sink
# Define GUI
GUI__init__()
    gui.button.clicked.connect(startUSRP) ...
# Define action to be taken when button clicked, i.e. start flowgraph
startUSRP()
  tb=USRP()
  tb.start()
  tb.wait() # Will block everything until finished
#  define and run GUI
main()
    app = QtGui.QApplication(sys.argv)
    window = main_window()
    window.show()
    sys.exit(app.exec_())
if __name__ == '__main__':
    main()

My code runs as expected, in the sense data is produced, but tb.wait is a
blocking call. This means that my GUI will freeze until the flowgraph has
ended. The GUI must not be blocked during flowgraph execution. Also, I
would like to track the progress of the flowgraph (the number of elements
processed / total elements requested). I tried to search online, and there
is some related information, but unfortunately I have not managed to
understand how to put the pieces together yet. I imagine something like
using QTimer to periodically check the status of the flowgraph, by asking
the flowgraph in some way.
This flowgraph ends with writing to a file, after the head_block. Hence, I
suspect that just checking the head_block might not give me all data?
Either I need to add a small extra delay to make sure the file sink gets
all data, or check the number of items passed to the file sink itself? So I
guess the short question is:
How to periodically check if a started flowgraph has finished, without
using a blocking call such as tb.wait?

I would be very grateful for any hints. I don't know much about C++ and
threading, which makes finding clues from the C++ API more difficult.
However, I am eager to learn if anyone would enlighten me on this.

Best regards,
Eskil



_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


reply via email to

[Prev in Thread] Current Thread [Next in Thread]