3 # Copyright 2004 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
27 return math.cos(x) + math.sin(x) * 1j
29 class test_bytes_to_syms (gr_unittest.TestCase):
32 self.fg = gr.flow_graph ()
37 def test_bytes_to_syms_001 (self):
38 src_data = (0x01, 0x80, 0x03)
39 expected_result = (-1, -1, -1, -1, -1, -1, -1, +1,
40 +1, -1, -1, -1, -1, -1, -1, -1,
41 -1, -1, -1, -1, -1, -1, +1, +1)
42 src = gr.vector_source_b (src_data)
43 op = gr.bytes_to_syms ()
44 dst = gr.vector_sink_f ()
45 self.fg.connect (src, op)
46 self.fg.connect (op, dst)
48 result_data = dst.data ()
49 self.assertEqual (expected_result, result_data)
51 def test_simple_framer (self):
52 src_data = (0x00, 0x11, 0x22, 0x33,
53 0x44, 0x55, 0x66, 0x77,
54 0x88, 0x99, 0xaa, 0xbb,
55 0xcc, 0xdd, 0xee, 0xff)
58 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x00, 0x00, 0x11, 0x22, 0x33, 0x55,
59 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x01, 0x44, 0x55, 0x66, 0x77, 0x55,
60 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x02, 0x88, 0x99, 0xaa, 0xbb, 0x55,
61 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc, 0x03, 0xcc, 0xdd, 0xee, 0xff, 0x55)
63 src = gr.vector_source_b (src_data)
64 op = gr.simple_framer (4)
65 dst = gr.vector_sink_b ()
66 self.fg.connect (src, op)
67 self.fg.connect (op, dst)
69 result_data = dst.data ()
70 self.assertEqual (expected_result, result_data)
73 if __name__ == '__main__':