comparison ater/tx_func.c @ 19:1e375472d5a5

ater: implement TRAU frame output
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Jun 2024 08:07:45 +0000
parents 61862af2247f
children 0d70444b5070
comparison
equal deleted inserted replaced
18:61862af2247f 19:1e375472d5a5
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 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include <osmocom/core/msgb.h>
12 #include <osmocom/core/select.h> 13 #include <osmocom/core/select.h>
13 #include <osmocom/isdn/i460_mux.h> 14 #include <osmocom/isdn/i460_mux.h>
14 15
15 #include "globals.h" 16 #include "globals.h"
16 #include "submux.h" 17 #include "submux.h"
17 18
19 void init_trau_ul_frame(int nr)
20 {
21 struct ater_subslot *at = &subslots[nr];
22 struct osmo_trau_frame *fr = &at->ul_frame;
23
24 fr->type = at->is_efr ? OSMO_TRAU16_FT_EFR : OSMO_TRAU16_FT_FR;
25 fr->dir = OSMO_TRAU_DIR_UL;
26 memset(fr->c_bits + 5, 0, 6);
27 memset(fr->c_bits + 15, 1, 6);
28 memset(fr->t_bits, 1, 4);
29 }
30
31 static void tx_service_subslot(int nr)
32 {
33 struct ater_subslot *at = &subslots[nr];
34 struct osmo_trau_frame *fr = &at->ul_frame;
35 struct msgb *msg;
36 int len;
37
38 if (!at->is_active)
39 return;
40 at->mfrm_count++;
41 if (at->mfrm_count >= 24) {
42 at->mfrm_count = 0;
43 fr->c_bits[14] = 1;
44 } else {
45 fr->c_bits[14] = 0;
46 }
47 msg = msgb_alloc_c(g_ctx, 640, "TRAU-UL-frame");
48 if (!msg)
49 return;
50 len = osmo_trau_frame_encode(msg->tail, msgb_tailroom(msg), fr);
51 msgb_put(msg, len);
52 osmo_i460_mux_enqueue(at->schan, msg);
53 }
54
18 void transmit_e1_ts(void) 55 void transmit_e1_ts(void)
19 { 56 {
20 uint8_t buf[160]; 57 uint8_t buf[160];
58 int nr;
21 59
60 for (nr = 0; nr < ATER_SUBSLOTS; nr++)
61 tx_service_subslot(nr);
22 osmo_i460_mux_out(&i460_ts, buf, 160); 62 osmo_i460_mux_out(&i460_ts, buf, 160);
23 write(ts_fd, buf, 160); 63 write(ts_fd, buf, 160);
24 } 64 }