blob: b57ef224e2874e7c20e83e99d521049f8eb21b84 [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
Vasil Velichkovff88ba42019-07-20 23:33:08 +030040 def test_downlink (self):
41 """
42 BCCH_CCCH_SDCCH4 demapper downlink test
43 """
44 src = grgsm.burst_source(test_data.frames, test_data.timeslots, test_data.bursts)
45 src.set_arfcn(0); # downlink
46 demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=0)
47 dst = grgsm.burst_sink()
48
49 self.tb.msg_connect(src, "out", demapper, "bursts")
50 self.tb.msg_connect(demapper, "bursts", dst, "in")
51 self.tb.run ()
52
53 b = test_data.bursts
54 self.assertEqual([
55 b[ 2], b[ 3], b[ 4], b[ 5], #BCCH
56 b[ 6], b[ 7], b[ 8], b[ 9], #CCCH skip 2
57 b[ 12], b[ 13], b[ 14], b[ 15], #CCCH
58 b[ 16], b[ 17], b[ 18], b[ 19], #CCCH skip 2
59 b[ 22], b[ 23], b[ 24], b[ 25], #SDCCH 0
60 b[ 26], b[ 27], b[ 28], b[ 29], #SDCCH 1 skip 2
61 b[ 32], b[ 33], b[ 34], b[ 35], #SDCCH 2
62 b[ 36], b[ 37], b[ 38], b[ 39], #SDCCH 3 skip 2
63 b[ 42], b[ 43], b[ 44], b[ 45], #SACCH 0
64 b[ 46], b[ 47], b[ 48], b[ 49], #SACCH 1 skip 3
65 b[ 53], b[ 54], b[ 55], b[ 56], #BCCH
66 b[ 57], b[ 58], b[ 59], b[ 60], #CCCH skip 2
67 b[ 63], b[ 64], b[ 65], b[ 66], #CCCH
68 b[ 67], b[ 68], b[ 69], b[ 70], #CCCH skip 2
69 b[ 73], b[ 74], b[ 75], b[ 76], #SDCCH 0
70 b[ 77], b[ 78], b[ 79], b[ 80], #SDCCH 1 skip 2
71 b[ 83], b[ 84], b[ 85], b[ 86], #SDCCH 2
72 b[ 87], b[ 88], b[ 89], b[ 90], #SDCCH 3 skip 2
73 b[ 93], b[ 94], b[ 95], b[ 96], #SACCH 1
74 b[ 97], b[ 98], b[ 99], b[100], #SACCH 2 skip 3
75 b[104], b[105], b[106], b[107] #BCCH
76 ], list(dst.get_burst_data()))
77
78 self.assertEqual([
79 1, 1, 1, 1, #BCCH
80 2, 2, 2, 2, #CCCH
81 2, 2, 2, 2, #CCCH
82 2, 2, 2, 2, #CCCH
83 7, 7, 7, 7, #SDCCH 0
84 7, 7, 7, 7, #SDCCH 1
85 7, 7, 7, 7, #SDCCH 2
86 7, 7, 7, 7, #SDCCH 3
87 135, 135, 135, 135, #SACCH 0
88 135, 135, 135, 135, #SACCH 1
89 1, 1, 1, 1, #BCCH
90 2, 2, 2, 2, #CCCH
91 2, 2, 2, 2, #CCCH
92 2, 2, 2, 2, #CCCH
93 7, 7, 7, 7, #SDCCH 0
94 7, 7, 7, 7, #SDCCH 1
95 7, 7, 7, 7, #SDCCH 2
96 7, 7, 7, 7, #SDCCH 3
97 135, 135, 135, 135, #SACCH 2
98 135, 135, 135, 135, #SACCH 3
99 1, 1, 1, 1, #BCCH
100 ], list(dst.get_sub_types()))
101
102 self.assertEqual([
103 0, 0, 0, 0, #BCCH
104 0, 0, 0, 0, #CCCH
105 1, 1, 1, 1, #CCCH
106 2, 2, 2, 2, #CCCH
107 0, 0, 0, 0, #SDCCH 0
108 1, 1, 1, 1, #SDCCH 1
109 2, 2, 2, 2, #SDCCH 2
110 3, 3, 3, 3, #SDCCH 3
111 0, 0, 0, 0, #SACCH 0
112 1, 1, 1, 1, #SACCH 1
113 0, 0, 0, 0, #BCCH
114 0, 0, 0, 0, #CCCH
115 1, 1, 1, 1, #CCCH
116 2, 2, 2, 2, #CCCH
117 0, 0, 0, 0, #SDCCH 0
118 1, 1, 1, 1, #SDCCH 1
119 2, 2, 2, 2, #SDCCH 2
120 3, 3, 3, 3, #SDCCH 3
121 2, 2, 2, 2, #SACCH 2
122 3, 3, 3, 3, #SACCH 3
123 0, 0, 0, 0, #BCCH
124 ], list(dst.get_sub_slots()))
125
Vasil Velichkovff88ba42019-07-20 23:33:08 +0300126 def test_uplink (self):
127 """
128 BCCH_CCCH_SDCCH4 demapper uplink test
129 """
130 src = grgsm.burst_source(test_data.frames, test_data.timeslots, test_data.bursts)
131 src.set_arfcn(0x2240); #uplink flag is 40
132 demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=0)
133 dst = grgsm.burst_sink()
134
135 self.tb.msg_connect(src, "out", demapper, "bursts")
136 self.tb.msg_connect(demapper, "bursts", dst, "in")
137 self.tb.run ()
138
139 b = test_data.bursts
140 self.assertEqual(b, list(dst.get_burst_data()))
141
142 self.assertEqual([
143 7, 7, 7, 7, #SDCCH 3
144 3, 3, #RACCH
145 135, 135, 135, 135, #SACCH 2
146 135, 135, 135, 135, #SACCH 3
147 3, 3, 3, 3, #RACCH
148 3, 3, 3, 3, #RACCH
149 3, 3, 3, 3, #RACCH
150 3, 3, 3, 3, #RACCH
151 3, 3, 3, 3, #RACCH
152 3, 3, 3, #RACCH
153 7, 7, 7, 7, #SDCCH 0
154 7, 7, 7, 7, #SDCCH 1
155 3, 3, #RACCH
156 7, 7, 7, 7, #SDCCH 2
157 7, 7, 7, 7, #SDCCH 3
158 3, 3, #RACCH
159 135, 135, 135, 135, #SACCH 0
160 135, 135, 135, 135, #SACCH 1
161 3, 3, 3, 3, #RACCH
162 3, 3, 3, 3, #RACCH
163 3, 3, 3, 3, #RACCH
164 3, 3, 3, 3, #RACCH
165 3, 3, 3, 3, #RACCH
166 3, 3, 3, #RACCH
167 7, 7, 7, 7, #SDCCH 0
168 7, 7, 7, 7, #SDCCH 1
169 3, 3, #RACCH
170 7, 7, 7, 7, #SDCCH 2
171 7, 7, 7, 7, #SDCCH 3
172 3, 3, #RACCH
173 ], list(dst.get_sub_types()))
174
175 self.assertEqual([
176 3, 3, 3, 3, #SDCCH 3
177 0, 0, #RACCH
178 2, 2, 2, 2, #SACCH 2
179 3, 3, 3, 3, #SACCH 3
180 0, 0, 0, 0, #RACCH
181 0, 0, 0, 0, #RACCH
182 0, 0, 0, 0, #RACCH
183 0, 0, 0, 0, #RACCH
184 0, 0, 0, 0, #RACCH
185 0, 0, 0, #RACCH
186 0, 0, 0, 0, #SDCCH 0
187 1, 1, 1, 1, #SDCCH 1
188 0, 0, #RACCH
189 2, 2, 2, 2, #SDCCH 2
190 3, 3, 3, 3, #SDCCH 3
191 0, 0, #RACCH
192 0, 0, 0, 0, #SACCH 0
193 1, 1, 1, 1, #SACCH 1
194 0, 0, 0, 0, #RACCH
195 0, 0, 0, 0, #RACCH
196 0, 0, 0, 0, #RACCH
197 0, 0, 0, 0, #RACCH
198 0, 0, 0, 0, #RACCH
199 0, 0, 0, #RACCH
200 0, 0, 0, 0, #SDCCH 0
201 1, 1, 1, 1, #SDCCH 1
202 0, 0, #RACCH
203 2, 2, 2, 2, #SDCCH 2
204 3, 3, 3, 3, #SDCCH 3
205 0, 0, #RACCH
206 ], list(dst.get_sub_slots()))
207
208if __name__ == '__main__':
209 gr_unittest.run(qa_bcch_ccch_sdcch4_demapper, "qa_bcch_ccch_sdcch4_demapper.xml")