3 # Copyright 2008,2010 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, gr_unittest
24 from threading import Timer
26 class test_sink_source(gr_unittest.TestCase):
29 self.tb_snd = gr.top_block()
30 self.tb_rcv = gr.top_block()
40 src_data = [float(x) for x in range(n_data)]
41 expected_result = tuple(src_data)
42 src = gr.vector_source_f(src_data)
43 udp_snd = gr.udp_sink( gr.sizeof_float, 'localhost', port )
44 self.tb_snd.connect( src, udp_snd )
46 udp_rcv = gr.udp_source( gr.sizeof_float, 'localhost', port )
47 dst = gr.vector_sink_f()
48 self.tb_rcv.connect( udp_rcv, dst )
54 q = Timer(3.0,self.stop_rcv)
59 result_data = dst.data()
60 self.assertEqual(expected_result, result_data)
61 self.assert_(not self.timeout)
64 udp_rcv = gr.udp_source( gr.sizeof_float, '0.0.0.0', 0, eof=False )
65 rcv_port = udp_rcv.get_port()
67 udp_snd = gr.udp_sink( gr.sizeof_float, '127.0.0.1', 65500 )
68 udp_snd.connect( 'localhost', rcv_port )
71 src_data = [float(x) for x in range(n_data)]
72 expected_result = tuple(src_data)
73 src = gr.vector_source_f(src_data)
74 dst = gr.vector_sink_f()
76 self.tb_snd.connect( src, udp_snd )
77 self.tb_rcv.connect( udp_rcv, dst )
83 q = Timer(3.0,self.stop_rcv)
88 result_data = dst.data()
89 self.assertEqual(expected_result, result_data)
90 self.assert_(self.timeout) # source ignores EOF?
95 #print "tb_rcv stopped by Timer"
97 if __name__ == '__main__':