FreeCalypso > hg > e1-fake-trau
comparison ft16/tx_func.c @ 2:5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Aug 2024 13:07:16 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:e5527fc2050b | 2:5c18cd38c8ad |
---|---|
1 /* | |
2 * Here we are going to implement Tx on Abis toward the BTS. | |
3 */ | |
4 | |
5 #include <stdint.h> | |
6 #include <stdbool.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <unistd.h> | |
11 | |
12 #include <osmocom/core/msgb.h> | |
13 #include <osmocom/core/select.h> | |
14 #include <osmocom/isdn/i460_mux.h> | |
15 #include <osmocom/trau/trau_frame.h> | |
16 | |
17 #include "globals.h" | |
18 #include "submux.h" | |
19 #include "dl_frames.h" | |
20 | |
21 static void tx_service_subslot(int nr) | |
22 { | |
23 struct abis_subslot *ab = &subslots[nr]; | |
24 const uint8_t *srcbuf; | |
25 struct msgb *msg; | |
26 uint8_t *outbuf; | |
27 | |
28 if (!ab->got_sync) | |
29 return; | |
30 switch (ab->frame_type) { | |
31 case TRAU_FT_FR_UP: | |
32 srcbuf = dl_frame_fr; | |
33 break; | |
34 case TRAU_FT_EFR: | |
35 srcbuf = dl_frame_efr; | |
36 break; | |
37 default: | |
38 return; | |
39 } | |
40 msg = msgb_alloc_c(g_ctx, DL_OUTPUT_LEN, "TRAU-DL-frame"); | |
41 if (!msg) | |
42 return; | |
43 outbuf = msgb_put(msg, DL_OUTPUT_LEN); | |
44 memcpy(outbuf, srcbuf, DL_OUTPUT_LEN); | |
45 osmo_i460_mux_enqueue(ab->schan, msg); | |
46 } | |
47 | |
48 void transmit_e1_ts(void) | |
49 { | |
50 uint8_t buf[160]; | |
51 int nr; | |
52 | |
53 for (nr = 0; nr < ABIS_SUBSLOTS; nr++) | |
54 tx_service_subslot(nr); | |
55 osmo_i460_mux_out(&i460_ts, buf, 160); | |
56 write(ts_fd, buf, 160); | |
57 } |