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 Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio