FreeCalypso > hg > ice1-trau-tester
comparison abis/subslot_rx.c @ 33:351bd801cdce
abis: should be complete now
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Aug 2024 22:53:42 +0000 |
parents | 94f11dc0d474 |
children |
comparison
equal
deleted
inserted
replaced
32:94f11dc0d474 | 33:351bd801cdce |
---|---|
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include <osmocom/core/select.h> | 11 #include <osmocom/core/select.h> |
12 #include <osmocom/core/utils.h> | |
12 #include <osmocom/isdn/i460_mux.h> | 13 #include <osmocom/isdn/i460_mux.h> |
13 #include <osmocom/trau/trau_sync.h> | 14 #include <osmocom/trau/trau_sync.h> |
14 | 15 |
15 #include "globals.h" | 16 #include "globals.h" |
16 #include "submux.h" | 17 #include "submux.h" |
21 struct abis_subslot *ab = user_data; | 22 struct abis_subslot *ab = user_data; |
22 | 23 |
23 osmo_trau_sync_rx_ubits(ab->sync, bits, num_bits); | 24 osmo_trau_sync_rx_ubits(ab->sync, bits, num_bits); |
24 } | 25 } |
25 | 26 |
27 static void sync_lost(struct abis_subslot *ab) | |
28 { | |
29 if (!ab->got_sync) | |
30 return; | |
31 printf("Subslot %d lost frame sync\n", ab->nr); | |
32 ab->got_sync = false; | |
33 } | |
34 | |
35 /* function copied from libosmo-abis/src/trau/trau_frame.c */ | |
36 static uint32_t get_bits(const ubit_t *bitbuf, int offset, int num) | |
37 { | |
38 int i; | |
39 uint32_t ret = 0; | |
40 | |
41 for (i = offset; i < offset + num; i++) { | |
42 ret = ret << 1; | |
43 if (bitbuf[i]) | |
44 ret |= 1; | |
45 } | |
46 return ret; | |
47 } | |
48 | |
26 void sync_rx_func(void *user_data, const ubit_t *bits, unsigned int num_bits) | 49 void sync_rx_func(void *user_data, const ubit_t *bits, unsigned int num_bits) |
27 { | 50 { |
28 struct abis_subslot *ab = user_data; | 51 struct abis_subslot *ab = user_data; |
52 uint8_t ft; | |
29 | 53 |
30 | 54 if (!bits) { |
55 sync_lost(ab); | |
56 return; | |
57 } | |
58 OSMO_ASSERT(num_bits == 320); | |
59 ft = get_bits(bits, 17, 5); | |
60 if (!ab->got_sync) { | |
61 printf("Subslot %d got frame sync with FT=0x%02X\n", | |
62 ab->nr, ft); | |
63 ab->got_sync = true; | |
64 ab->frame_type = ft; | |
65 return; | |
66 } | |
67 if (ft == ab->frame_type) | |
68 return; | |
69 printf("Subslot %d changed frame type from 0x%02X to 0x%02X\n", ab->nr, | |
70 ab->frame_type, ft); | |
71 ab->frame_type = ft; | |
31 } | 72 } |