aboutsummaryrefslogtreecommitdiffstats
path: root/python/qa_gsm_bcch_ccch_sdcch4_demapper.py
blob: 76f8ecc3ee83bf82ae28d2b5406b88907ef62ef5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @file
# @author (C) 2019 by Vasil Velichkov <vvvelichkov@gmail.com>
# @section LICENSE
#
# Gr-gsm is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Gr-gsm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gr-gsm; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
#

import unittest
import numpy as np
from gnuradio import gr, gr_unittest, blocks
import grgsm
import pmt
import qa_gsm_demapper_data as test_data

class qa_bcch_ccch_sdcch4_demapper (gr_unittest.TestCase):

    def setUp (self):
        self.tb = gr.top_block ()
        self.maxDiff = None

    def tearDown (self):
        self.tb = None

    def test_downlink (self):
        """
           BCCH_CCCH_SDCCH4 demapper downlink test
        """
        src = grgsm.burst_source(test_data.frames, test_data.timeslots, test_data.bursts)
        src.set_arfcn(0); # downlink
        demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=0)
        dst = grgsm.burst_sink()

        self.tb.msg_connect(src, "out", demapper, "bursts")
        self.tb.msg_connect(demapper, "bursts", dst, "in")
        self.tb.run ()

        b = test_data.bursts
        self.assertEqual([
            b[  2], b[  3], b[  4], b[  5], #BCCH
            b[  6], b[  7], b[  8], b[  9], #CCCH    skip 2
            b[ 12], b[ 13], b[ 14], b[ 15], #CCCH
            b[ 16], b[ 17], b[ 18], b[ 19], #CCCH    skip 2
            b[ 22], b[ 23], b[ 24], b[ 25], #SDCCH 0
            b[ 26], b[ 27], b[ 28], b[ 29], #SDCCH 1 skip 2
            b[ 32], b[ 33], b[ 34], b[ 35], #SDCCH 2
            b[ 36], b[ 37], b[ 38], b[ 39], #SDCCH 3 skip 2
            b[ 42], b[ 43], b[ 44], b[ 45], #SACCH 0
            b[ 46], b[ 47], b[ 48], b[ 49], #SACCH 1 skip 3
            b[ 53], b[ 54], b[ 55], b[ 56], #BCCH
            b[ 57], b[ 58], b[ 59], b[ 60], #CCCH    skip 2
            b[ 63], b[ 64], b[ 65], b[ 66], #CCCH
            b[ 67], b[ 68], b[ 69], b[ 70], #CCCH    skip 2
            b[ 73], b[ 74], b[ 75], b[ 76], #SDCCH 0
            b[ 77], b[ 78], b[ 79], b[ 80], #SDCCH 1 skip 2
            b[ 83], b[ 84], b[ 85], b[ 86], #SDCCH 2
            b[ 87], b[ 88], b[ 89], b[ 90], #SDCCH 3 skip 2
            b[ 93], b[ 94], b[ 95], b[ 96], #SACCH 1
            b[ 97], b[ 98], b[ 99], b[100], #SACCH 2 skip 3
            b[104], b[105], b[106], b[107]  #BCCH
            ], list(dst.get_burst_data()))

        self.assertEqual([
              1,   1,   1,   1, #BCCH
              2,   2,   2,   2, #CCCH
              2,   2,   2,   2, #CCCH
              2,   2,   2,   2, #CCCH
              7,   7,   7,   7, #SDCCH 0
              7,   7,   7,   7, #SDCCH 1
              7,   7,   7,   7, #SDCCH 2
              7,   7,   7,   7, #SDCCH 3
            135, 135, 135, 135, #SACCH 0
            135, 135, 135, 135, #SACCH 1
              1,   1,   1,   1, #BCCH
              2,   2,   2,   2, #CCCH
              2,   2,   2,   2, #CCCH
              2,   2,   2,   2, #CCCH
              7,   7,   7,   7, #SDCCH 0
              7,   7,   7,   7, #SDCCH 1
              7,   7,   7,   7, #SDCCH 2
              7,   7,   7,   7, #SDCCH 3
            135, 135, 135, 135, #SACCH 2
            135, 135, 135, 135, #SACCH 3
              1,   1,   1,   1, #BCCH
            ], list(dst.get_sub_types()))

        self.assertEqual([
            0, 0, 0, 0, #BCCH
            0, 0, 0, 0, #CCCH
            1, 1, 1, 1, #CCCH
            2, 2, 2, 2, #CCCH
            0, 0, 0, 0, #SDCCH 0
            1, 1, 1, 1, #SDCCH 1
            2, 2, 2, 2, #SDCCH 2
            3, 3, 3, 3, #SDCCH 3
            0, 0, 0, 0, #SACCH 0
            1, 1, 1, 1, #SACCH 1
            0, 0, 0, 0, #BCCH
            0, 0, 0, 0, #CCCH
            1, 1, 1, 1, #CCCH
            2, 2, 2, 2, #CCCH
            0, 0, 0, 0, #SDCCH 0
            1, 1, 1, 1, #SDCCH 1
            2, 2, 2, 2, #SDCCH 2
            3, 3, 3, 3, #SDCCH 3
            2, 2, 2, 2, #SACCH 2
            3, 3, 3, 3, #SACCH 3
            0, 0, 0, 0, #BCCH
            ], list(dst.get_sub_slots()))

    @unittest.expectedFailure
    def test_uplink (self):
        """
           BCCH_CCCH_SDCCH4 demapper uplink test
        """
        src = grgsm.burst_source(test_data.frames, test_data.timeslots, test_data.bursts)
        src.set_arfcn(0x2240); #uplink flag is 40
        demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=0)
        dst = grgsm.burst_sink()

        self.tb.msg_connect(src, "out", demapper, "bursts")
        self.tb.msg_connect(demapper, "bursts", dst, "in")
        self.tb.run ()

        b = test_data.bursts
        self.assertEqual(b, list(dst.get_burst_data()))

        self.assertEqual([
              7,   7,   7,   7, #SDCCH 3
              3,   3,           #RACCH
            135, 135, 135, 135, #SACCH 2
            135, 135, 135, 135, #SACCH 3
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,      #RACCH
              7,   7,   7,   7, #SDCCH 0
              7,   7,   7,   7, #SDCCH 1
              3,   3,           #RACCH
              7,   7,   7,   7, #SDCCH 2
              7,   7,   7,   7, #SDCCH 3
              3,   3,           #RACCH
            135, 135, 135, 135, #SACCH 0
            135, 135, 135, 135, #SACCH 1
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,   3, #RACCH
              3,   3,   3,      #RACCH
              7,   7,   7,   7, #SDCCH 0
              7,   7,   7,   7, #SDCCH 1
              3,   3,           #RACCH
              7,   7,   7,   7, #SDCCH 2
              7,   7,   7,   7, #SDCCH 3
              3,   3,           #RACCH
            ], list(dst.get_sub_types()))

        self.assertEqual([
            3, 3, 3, 3, #SDCCH 3
            0, 0,       #RACCH
            2, 2, 2, 2, #SACCH 2
            3, 3, 3, 3, #SACCH 3
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0,    #RACCH
            0, 0, 0, 0, #SDCCH 0
            1, 1, 1, 1, #SDCCH 1
            0, 0,       #RACCH
            2, 2, 2, 2, #SDCCH 2
            3, 3, 3, 3, #SDCCH 3
            0, 0,       #RACCH
            0, 0, 0, 0, #SACCH 0
            1, 1, 1, 1, #SACCH 1
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0, 0, #RACCH
            0, 0, 0,    #RACCH
            0, 0, 0, 0, #SDCCH 0
            1, 1, 1, 1, #SDCCH 1
            0, 0,       #RACCH
            2, 2, 2, 2, #SDCCH 2
            3, 3, 3, 3, #SDCCH 3
            0, 0,       #RACCH
            ], list(dst.get_sub_slots()))

if __name__ == '__main__':
    gr_unittest.run(qa_bcch_ccch_sdcch4_demapper, "qa_bcch_ccch_sdcch4_demapper.xml")