Philipp Maier | 69e00cc | 2019-10-09 13:38:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2019 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 3 | * Author: Philipp Maier <pmaier@sysmocom.de> |
| 4 | * All Rights Reserved |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <string.h> |
| 25 | #include <stdio.h> |
| 26 | #include <stdint.h> |
| 27 | #include <osmocom/core/utils.h> |
| 28 | #include <osmocom/gsm/gsm0502.h> |
| 29 | |
| 30 | /* TCH-F, block endings, 3x 104-frame cycles */ |
| 31 | uint32_t tch_f_fn_samples[] = { 1036987, 1036991, 1036995, 1037000, 1037004, 1037008, 1037013, 1037017, |
| 32 | 1037021, 1037026, 1037030, 1037034, 1037039, 1037043, 1037047, 1037052, |
| 33 | 1037056, 1037060, 1037065, |
| 34 | 1037069, 1037073, 1037078, 1037082, 1037086, 1037091, 1037095, 1037099, |
| 35 | 1037104, 1037108, 1037112, |
| 36 | 1037117, 1037121, 1037125, 1037130, 1037134, 1037138, 1037143, 1037147, |
| 37 | 1037151, 1037156, 1037160, |
| 38 | 1037164, 1037169, 1037173, 1037177, 1037182, 1037186, 1037190, 1037195, |
| 39 | 1037199, 1037203, 1037208, |
| 40 | 1037212, 1037216, 1037221, 1037225, 1037229, 1037234, 1037238, 1037242, |
| 41 | 1037247, 1037251, 1037255, |
| 42 | 1037260, 1037264, 1037268, 1037273, 1037277, 1037281, 1037286, 1037290, |
| 43 | 1037294 |
| 44 | }; |
| 45 | |
| 46 | /* TCH-H0, block endings, 3x 104-frame cycles */ |
| 47 | uint32_t tch_h0_fn_samples[] = { 1175826, 1175830, 1175834, 1175839, 1175843, 1175847, 1175852, 1175856, |
| 48 | 1175860, 1175865, 1175869, 1175873, 1175878, 1175882, 1175886, 1175891, |
| 49 | 1175895, 1175899, 1175904, |
| 50 | 1175908, 1175912, 1175917, 1175921, 1175925, 1175930, 1175934, 1175938, |
| 51 | 1175943, 1175947, 1175951, |
| 52 | 1175956, 1175960, 1175964, 1175969, 1175973, 1175977, 1175982, 1175986, |
| 53 | 1175990, 1175995, 1175999, |
| 54 | 1176003, 1176008, 1176012, 1176016, 1176021, 1176025, 1176029, 1176034, |
| 55 | 1176038, 1176042, 1176047, |
| 56 | 1176051, 1176055, 1176060, 1176064, 1176068, 1176073, 1176077, 1176081, |
| 57 | 1176086, 1176090, 1176094, |
| 58 | 1176099, 1176103, 1176107, 1176112, 1176116, 1176120, 1176125, 1176129, |
| 59 | 1176133 |
| 60 | }; |
| 61 | |
| 62 | /* TCH-H1, block endings, 3x 104-frame cycles */ |
| 63 | unsigned int tch_h1_fn_samples[] = { 1175827, 1175831, 1175835, 1175840, 1175844, 1175848, 1175853, 1175857, |
| 64 | 1175861, 1175866, 1175870, 1175874, 1175879, 1175883, 1175887, 1175892, |
| 65 | 1175896, 1175900, 1175905, |
| 66 | 1175909, 1175913, 1175918, 1175922, 1175926, 1175931, 1175935, 1175939, |
| 67 | 1175944, 1175948, 1175952, |
| 68 | 1175957, 1175961, 1175965, 1175970, 1175974, 1175978, 1175983, 1175987, |
| 69 | 1175991, 1175996, 1176000, |
| 70 | 1176004, 1176009, 1176013, 1176017, 1176022, 1176026, 1176030, 1176035, |
| 71 | 1176039, 1176043, 1176048, |
| 72 | 1176052, 1176056, 1176061, 1176065, 1176069, 1176074, 1176078, 1176082, |
| 73 | 1176087, 1176091, 1176095, |
| 74 | 1176100, 1176104, 1176108, 1176113, 1176117, 1176121, 1176126, 1176130, |
| 75 | 1176134 |
| 76 | }; |
| 77 | |
| 78 | /* FACCH-F, block endings */ |
| 79 | uint32_t facch_f_fn_samples[] = { 177275, 177314, 177336, 177375, 177396, 177435, 178328, 178367, 178393, |
| 80 | 180014, 180053, 180079, 180113, 180144, 180183 |
| 81 | }; |
| 82 | |
| 83 | /* FACCH-H0, block endings */ |
| 84 | uint32_t facch_h0_fn_samples[] = { 499956, 499999, 500034, 500077, 500952, 501836, 501880, 502850, 502894, |
| 85 | 502937, 503006, 503050 |
| 86 | }; |
| 87 | |
| 88 | /* FACCH-H1, block endings */ |
| 89 | uint32_t facch_h1_fn_samples[] = { 500728, 500771, 500797, 500841, 500875, 500919, 501751, 501794, 501837, |
| 90 | 502782, 502825, 502869, 502903, 502955, 502999 |
| 91 | }; |
| 92 | |
| 93 | static void test_gsm0502_fn_remap() |
| 94 | { |
| 95 | unsigned int i; |
| 96 | uint32_t fn_begin; |
| 97 | uint32_t fn_end; |
| 98 | |
| 99 | printf("Testing gsm0502_fn_remap()\n"); |
| 100 | printf("TCH/F\n"); |
| 101 | for (i = 0; i < ARRAY_SIZE(tch_h1_fn_samples); i++) { |
| 102 | fn_end = tch_f_fn_samples[i]; |
| 103 | fn_begin = gsm0502_fn_remap(fn_end, FN_REMAP_TCH_F); |
| 104 | printf("fn_end=%u, fn_end%%104=%u, fn_begin=%u, fn_begin%%104=%u\n", fn_end, fn_end % 104, fn_begin, |
| 105 | fn_begin % 104); |
| 106 | } |
| 107 | printf("\n"); |
| 108 | |
| 109 | printf("TCH/H0\n"); |
| 110 | for (i = 0; i < ARRAY_SIZE(tch_h0_fn_samples); i++) { |
| 111 | fn_end = tch_h0_fn_samples[i]; |
| 112 | fn_begin = gsm0502_fn_remap(fn_end, FN_REMAP_TCH_H0); |
| 113 | printf("fn_end=%u, fn_end%%104=%u, fn_begin=%u, fn_begin%%104=%u\n", fn_end, fn_end % 104, fn_begin, |
| 114 | fn_begin % 104); |
| 115 | } |
| 116 | printf("\n"); |
| 117 | |
| 118 | printf("TCH/H1\n"); |
| 119 | for (i = 0; i < ARRAY_SIZE(tch_h1_fn_samples); i++) { |
| 120 | fn_end = tch_h1_fn_samples[i]; |
| 121 | fn_begin = gsm0502_fn_remap(fn_end, FN_REMAP_TCH_H1); |
| 122 | printf("fn_end=%u, fn_end%%104=%u, fn_begin=%u, fn_begin%%104=%u\n", fn_end, fn_end % 104, fn_begin, |
| 123 | fn_begin % 104); |
| 124 | } |
| 125 | printf("\n"); |
| 126 | |
| 127 | printf("FACCH/F\n"); |
| 128 | for (i = 0; i < ARRAY_SIZE(facch_f_fn_samples); i++) { |
| 129 | fn_end = facch_f_fn_samples[i]; |
| 130 | fn_begin = gsm0502_fn_remap(fn_end, FN_REMAP_FACCH_F); |
| 131 | printf("fn_end=%u, fn_end%%104=%u, fn_begin=%u, fn_begin%%104=%u\n", fn_end, fn_end % 104, fn_begin, |
| 132 | fn_begin % 104); |
| 133 | } |
| 134 | printf("\n"); |
| 135 | |
| 136 | printf("FACCH/H0\n"); |
| 137 | for (i = 0; i < ARRAY_SIZE(facch_h0_fn_samples); i++) { |
| 138 | fn_end = facch_h0_fn_samples[i]; |
| 139 | fn_begin = gsm0502_fn_remap(fn_end, FN_REMAP_FACCH_H0); |
| 140 | printf("fn_end=%u, fn_end%%104=%u, fn_begin=%u, fn_begin%%104=%u\n", fn_end, fn_end % 104, fn_begin, |
| 141 | fn_begin % 104); |
| 142 | } |
| 143 | printf("\n"); |
| 144 | |
| 145 | printf("FACCH/H1\n"); |
| 146 | for (i = 0; i < ARRAY_SIZE(facch_h1_fn_samples); i++) { |
| 147 | fn_end = facch_h1_fn_samples[i]; |
| 148 | fn_begin = gsm0502_fn_remap(fn_end, FN_REMAP_FACCH_H1); |
| 149 | printf("fn_end=%u, fn_end%%104=%u, fn_begin=%u, fn_begin%%104=%u\n", fn_end, fn_end % 104, fn_begin, |
| 150 | fn_begin % 104); |
| 151 | } |
| 152 | printf("\n"); |
| 153 | } |
| 154 | |
| 155 | int main(int argc, char **argv) |
| 156 | { |
| 157 | test_gsm0502_fn_remap(); |
| 158 | return EXIT_SUCCESS; |
| 159 | } |