blob: c71a2e134708d12bcd19fe8bc117fed61d1b444d [file] [log] [blame]
Vasil Velichkovff88ba42019-07-20 23:33:08 +03001#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# @file
4# @author (C) 2019 by Vasil Velichkov <vvvelichkov@gmail.com>
5# @section LICENSE
6#
7# Gr-gsm 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)
10# any later version.
11#
12# Gr-gsm 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.
16#
17# You should have received a copy of the GNU General Public License
18# along with gr-gsm; see the file COPYING. If not, write to
19# the Free Software Foundation, Inc., 51 Franklin Street,
20# Boston, MA 02110-1301, USA.
21#
22#
23
24import unittest
25import numpy as np
26from gnuradio import gr, gr_unittest, blocks
27import grgsm
28import pmt
29import qa_gsm_demapper_data as test_data
30
31class qa_bcch_ccch_sdcch4_demapper (gr_unittest.TestCase):
32
33 def setUp (self):
34 self.tb = gr.top_block ()
35 self.maxDiff = None
36
37 def tearDown (self):
38 self.tb = None
39
40 @unittest.expectedFailure
41 def test_downlink (self):
42 """
43 BCCH_CCCH_SDCCH4 demapper downlink test
44 """
45 src = grgsm.burst_source(test_data.frames, test_data.timeslots, test_data.bursts)
46 src.set_arfcn(0); # downlink
47 demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=0)
48 dst = grgsm.burst_sink()
49
50 self.tb.msg_connect(src, "out", demapper, "bursts")
51 self.tb.msg_connect(demapper, "bursts", dst, "in")
52 self.tb.run ()
53
54 b = test_data.bursts
55 self.assertEqual([
56 b[ 2], b[ 3], b[ 4], b[ 5], #BCCH
57 b[ 6], b[ 7], b[ 8], b[ 9], #CCCH skip 2
58 b[ 12], b[ 13], b[ 14], b[ 15], #CCCH
59 b[ 16], b[ 17], b[ 18], b[ 19], #CCCH skip 2
60 b[ 22], b[ 23], b[ 24], b[ 25], #SDCCH 0
61 b[ 26], b[ 27], b[ 28], b[ 29], #SDCCH 1 skip 2
62 b[ 32], b[ 33], b[ 34], b[ 35], #SDCCH 2
63 b[ 36], b[ 37], b[ 38], b[ 39], #SDCCH 3 skip 2
64 b[ 42], b[ 43], b[ 44], b[ 45], #SACCH 0
65 b[ 46], b[ 47], b[ 48], b[ 49], #SACCH 1 skip 3
66 b[ 53], b[ 54], b[ 55], b[ 56], #BCCH
67 b[ 57], b[ 58], b[ 59], b[ 60], #CCCH skip 2
68 b[ 63], b[ 64], b[ 65], b[ 66], #CCCH
69 b[ 67], b[ 68], b[ 69], b[ 70], #CCCH skip 2
70 b[ 73], b[ 74], b[ 75], b[ 76], #SDCCH 0
71 b[ 77], b[ 78], b[ 79], b[ 80], #SDCCH 1 skip 2
72 b[ 83], b[ 84], b[ 85], b[ 86], #SDCCH 2
73 b[ 87], b[ 88], b[ 89], b[ 90], #SDCCH 3 skip 2
74 b[ 93], b[ 94], b[ 95], b[ 96], #SACCH 1
75 b[ 97], b[ 98], b[ 99], b[100], #SACCH 2 skip 3
76 b[104], b[105], b[106], b[107] #BCCH
77 ], list(dst.get_burst_data()))
78
79 self.assertEqual([
80 1, 1, 1, 1, #BCCH
81 2, 2, 2, 2, #CCCH
82 2, 2, 2, 2, #CCCH
83 2, 2, 2, 2, #CCCH
84 7, 7, 7, 7, #SDCCH 0
85 7, 7, 7, 7, #SDCCH 1
86 7, 7, 7, 7, #SDCCH 2
87 7, 7, 7, 7, #SDCCH 3
88 135, 135, 135, 135, #SACCH 0
89 135, 135, 135, 135, #SACCH 1
90 1, 1, 1, 1, #BCCH
91 2, 2, 2, 2, #CCCH
92 2, 2, 2, 2, #CCCH
93 2, 2, 2, 2, #CCCH
94 7, 7, 7, 7, #SDCCH 0
95 7, 7, 7, 7, #SDCCH 1
96 7, 7, 7, 7, #SDCCH 2
97 7, 7, 7, 7, #SDCCH 3
98 135, 135, 135, 135, #SACCH 2
99 135, 135, 135, 135, #SACCH 3
100 1, 1, 1, 1, #BCCH
101 ], list(dst.get_sub_types()))
102
103 self.assertEqual([
104 0, 0, 0, 0, #BCCH
105 0, 0, 0, 0, #CCCH
106 1, 1, 1, 1, #CCCH
107 2, 2, 2, 2, #CCCH
108 0, 0, 0, 0, #SDCCH 0
109 1, 1, 1, 1, #SDCCH 1
110 2, 2, 2, 2, #SDCCH 2
111 3, 3, 3, 3, #SDCCH 3
112 0, 0, 0, 0, #SACCH 0
113 1, 1, 1, 1, #SACCH 1
114 0, 0, 0, 0, #BCCH
115 0, 0, 0, 0, #CCCH
116 1, 1, 1, 1, #CCCH
117 2, 2, 2, 2, #CCCH
118 0, 0, 0, 0, #SDCCH 0
119 1, 1, 1, 1, #SDCCH 1
120 2, 2, 2, 2, #SDCCH 2
121 3, 3, 3, 3, #SDCCH 3
122 2, 2, 2, 2, #SACCH 2
123 3, 3, 3, 3, #SACCH 3
124 0, 0, 0, 0, #BCCH
125 ], list(dst.get_sub_slots()))
126
127 @unittest.expectedFailure
128 def test_uplink (self):
129 """
130 BCCH_CCCH_SDCCH4 demapper uplink test
131 """
132 src = grgsm.burst_source(test_data.frames, test_data.timeslots, test_data.bursts)
133 src.set_arfcn(0x2240); #uplink flag is 40
134 demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=0)
135 dst = grgsm.burst_sink()
136
137 self.tb.msg_connect(src, "out", demapper, "bursts")
138 self.tb.msg_connect(demapper, "bursts", dst, "in")
139 self.tb.run ()
140
141 b = test_data.bursts
142 self.assertEqual(b, list(dst.get_burst_data()))
143
144 self.assertEqual([
145 7, 7, 7, 7, #SDCCH 3
146 3, 3, #RACCH
147 135, 135, 135, 135, #SACCH 2
148 135, 135, 135, 135, #SACCH 3
149 3, 3, 3, 3, #RACCH
150 3, 3, 3, 3, #RACCH
151 3, 3, 3, 3, #RACCH
152 3, 3, 3, 3, #RACCH
153 3, 3, 3, 3, #RACCH
154 3, 3, 3, #RACCH
155 7, 7, 7, 7, #SDCCH 0
156 7, 7, 7, 7, #SDCCH 1
157 3, 3, #RACCH
158 7, 7, 7, 7, #SDCCH 2
159 7, 7, 7, 7, #SDCCH 3
160 3, 3, #RACCH
161 135, 135, 135, 135, #SACCH 0
162 135, 135, 135, 135, #SACCH 1
163 3, 3, 3, 3, #RACCH
164 3, 3, 3, 3, #RACCH
165 3, 3, 3, 3, #RACCH
166 3, 3, 3, 3, #RACCH
167 3, 3, 3, 3, #RACCH
168 3, 3, 3, #RACCH
169 7, 7, 7, 7, #SDCCH 0
170 7, 7, 7, 7, #SDCCH 1
171 3, 3, #RACCH
172 7, 7, 7, 7, #SDCCH 2
173 7, 7, 7, 7, #SDCCH 3
174 3, 3, #RACCH
175 ], list(dst.get_sub_types()))
176
177 self.assertEqual([
178 3, 3, 3, 3, #SDCCH 3
179 0, 0, #RACCH
180 2, 2, 2, 2, #SACCH 2
181 3, 3, 3, 3, #SACCH 3
182 0, 0, 0, 0, #RACCH
183 0, 0, 0, 0, #RACCH
184 0, 0, 0, 0, #RACCH
185 0, 0, 0, 0, #RACCH
186 0, 0, 0, 0, #RACCH
187 0, 0, 0, #RACCH
188 0, 0, 0, 0, #SDCCH 0
189 1, 1, 1, 1, #SDCCH 1
190 0, 0, #RACCH
191 2, 2, 2, 2, #SDCCH 2
192 3, 3, 3, 3, #SDCCH 3
193 0, 0, #RACCH
194 0, 0, 0, 0, #SACCH 0
195 1, 1, 1, 1, #SACCH 1
196 0, 0, 0, 0, #RACCH
197 0, 0, 0, 0, #RACCH
198 0, 0, 0, 0, #RACCH
199 0, 0, 0, 0, #RACCH
200 0, 0, 0, 0, #RACCH
201 0, 0, 0, #RACCH
202 0, 0, 0, 0, #SDCCH 0
203 1, 1, 1, 1, #SDCCH 1
204 0, 0, #RACCH
205 2, 2, 2, 2, #SDCCH 2
206 3, 3, 3, 3, #SDCCH 3
207 0, 0, #RACCH
208 ], list(dst.get_sub_slots()))
209
210if __name__ == '__main__':
211 gr_unittest.run(qa_bcch_ccch_sdcch4_demapper, "qa_bcch_ccch_sdcch4_demapper.xml")