Project

General

Profile

Bug #3803 ยป main.c

dexter, 09/27/2019 10:04 AM

 
1
#include <stdio.h>
2
#include <errno.h>
3
#include <string.h>
4
#include <stdint.h>
5
#include <osmocom/core/talloc.h>
6
#include <osmocom/core/utils.h>
7

    
8
unsigned int tch_f_fn_samples[] =
9
    { 1036987, 1036991, 1036995, 1037000, 1037004, 1037008, 1037013, 1037017,
10
	1037021, 1037026, 1037030, 1037034, 1037039, 1037043, 1037047, 1037052,
11
	    1037056, 1037060, 1037065,
12
	1037069, 1037073, 1037078, 1037082, 1037086, 1037091, 1037095, 1037099,
13
	    1037104, 1037108, 1037112,
14
	1037117, 1037121, 1037125, 1037130, 1037134, 1037138, 1037143, 1037147,
15
	    1037151, 1037156, 1037160,
16
	1037164, 1037169, 1037173, 1037177, 1037182, 1037186, 1037190, 1037195,
17
	    1037199, 1037203, 1037208,
18
	1037212, 1037216, 1037221, 1037225, 1037229, 1037234, 1037238, 1037242,
19
	    1037247, 1037251, 1037255,
20
	1037260, 1037264, 1037268, 1037273, 1037277, 1037281, 1037286, 1037290,
21
	    1037294
22
};
23

    
24
#define GSM_SUPERFRAME	(26*51)	/* 1326 TDMA frames */
25
#define GSM_HYPERFRAME	(2048*GSM_SUPERFRAME)	/* GSM_HYPERFRAME frames */
26

    
27
/* beginn, distance */
28
int8_t tch_f_fn_remap_table[3][2] = {
29
	{3, 8},
30
	{7, 7},
31
	{11, 7},
32
};
33

    
34
void remap_fn(unsigned int fn)
35
{
36
	uint8_t fn13;
37
	uint8_t i;
38
	uint8_t sub;
39
	unsigned int fn_map;
40

    
41
	fn13 = fn % 13;
42

    
43
	for (i = 0; i < 2; i++) {
44
		if (tch_f_fn_remap_table[i][0] == fn13)
45
			sub = tch_f_fn_remap_table[i][1];
46
	}
47

    
48
	fn_map = (fn + GSM_HYPERFRAME - sub) % GSM_HYPERFRAME;
49

    
50
	printf("fn=%u, fn104=%u, fn13=%u, sub=%u, fn_map=%u, fn_map104=%u\n",
51
	       fn, fn % 104, fn13, sub, fn_map, fn_map % 104);
52
}
53

    
54
int main(void)
55
{
56
	unsigned int i;
57

    
58
	printf("FN EXPERIMENT\n");
59

    
60
	printf("GSM_HYPERFRAME=%u\n", GSM_HYPERFRAME);
61

    
62
	for (i = 0; i < ARRAY_SIZE(tch_f_fn_samples); i++) {
63
		remap_fn(tch_f_fn_samples[i]);
64
	}
65

    
66
	return 0;
67
}
    (1-1/1)
    Add picture from clipboard (Maximum size: 48.8 MB)