|
Hello list,
I am trying to write a simple unit test from a flow graph I'm writing. The problem is that the flowgraph dont finish. It hangs in the line "self.assertNotEqual(out, 0). The complete code is as follows: #### from gnuradio import gr_unittest # Project imports from usrpDevice import UsrpFlowGraph from usrpDevice import USRPDevice from time import sleep ## Test DeviceWrapper methods # class qa_device(gr_unittest.TestCase): ## Test USRP communication def test_001_usrp(self): uhd = USRPDevice() uhd.start() out = uhd.sense() self.assertNotEqual(out, 0) if __name__ == '__main__': gr_unittest.main() #### And the USRPDevice class: #### class USRPDevice(gr.top_block): ## CTOR def __init__(self): gr.top_block.__init__(self, "Energy Top Block") self.mUhd = uhd.usrp_source(device_addr=options.addr, stream_args=uhd.stream_args(cpu_format='fc32', otw_format='sc16')) self.ed = EnergyDetector(options.fft_size) self.mavg = gr.moving_average_ff(options.moving_avg_size, 1.0/options.moving_avg_size ) self.mOut = gr.probe_signal_f() self.connect(self.mUhd, self.ed, self.mavg, self.mOut) def sense(self): return self.mOut.level() #### I tried changed the code and verified that USRPDevice::sense is returning when its called. And if I remove the "start()" call in the Unit Test, it works fine. Any suggestion of whats happening ? |
|
Resolved.
Its necessary to call gr.top_block::wait() method before the "stop()". Anybody know why this is necessary? |
|
Hi,
You have to call tb.stop() before the tb.wait(), not the other way around like you mentioned: tb.stop() tb.wait() The tb.wait() is to make sure the flowgraph has fully stopped before doing anything else. Cheers, Mike Mike M0MIK On 6 February 2013 13:37, maiconkist <[hidden email]> wrote: Resolved. _______________________________________________ Discuss-gnuradio mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/discuss-gnuradio |
|
In reply to this post by maiconkist
On Wed, Feb 6, 2013 at 8:37 AM, maiconkist <[hidden email]> wrote:
Resolved. In the thread-per-block scheduler: void
gr_scheduler_tpb::stop() { d_threads.interrupt_all(); } void
gr_scheduler_tpb::wait() { d_threads.join_all(); } Tom
_______________________________________________ Discuss-gnuradio mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/discuss-gnuradio |
|
In reply to this post by Mike Jameson
you're correct. In the code I did in this order.
|
| Powered by Nabble | Edit this page |
