annotate pcm-br/xconn.c @ 37:26c9535df39e

rm abis subdir: moved to e1-fake-trau repository The present code repository is meant to contain code for talking to a TRAU DUT, hence the name ice1-trau-tester. The different and separate function of talking to an E1 BTS (Abis instead of Ater, and in the opposite role) was never in scope for this project, but that code got added here in a haste when the InSite BTS arrived while the TRAU bring-up was still blocked. Now that we have our Nokia TCSM2 system working and are doing TRAU experiments, let's keep the code clean.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Aug 2024 19:02:02 +0000
parents 499d065ee591
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
2 * The two functions in this module get called from Osmocom select loop
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
3 * whenever each timeslot data socket to osmo-e1d is ready for reading;
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
4 * the cross-connect of the two timeslots is implemented here.
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdint.h>
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdbool.h>
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <unistd.h>
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <osmocom/core/select.h>
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "globals.h"
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
17 uint8_t readbuf_a[160], readbuf_b[160];
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
18 FILE *rec_file_a, *rec_file_b;
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
20 int tsa_fd_cb(struct osmo_fd *ofd, unsigned int what)
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 int rc;
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
24 rc = read(tsa_fd, readbuf_a, 160);
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (rc != 160) {
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 fprintf(stderr,
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
27 "error: read from ts A returned %d instead of 160\n",
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 rc);
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
31 if (rec_file_a)
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
32 fwrite(readbuf_a, 1, 160, rec_file_a);
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
33 write(tsb_fd, readbuf_a, 160);
2
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return 0;
c03ec046471f pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
35
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
36
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
37 int tsb_fd_cb(struct osmo_fd *ofd, unsigned int what)
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
38 {
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
39 int rc;
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
40
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
41 rc = read(tsb_fd, readbuf_b, 160);
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
42 if (rc != 160) {
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
43 fprintf(stderr,
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
44 "error: read from ts B returned %d instead of 160\n",
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
45 rc);
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
46 exit(1);
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
47 }
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
48 if (rec_file_b)
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
49 fwrite(readbuf_b, 1, 160, rec_file_b);
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
50 write(tsa_fd, readbuf_b, 160);
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
51 return 0;
499d065ee591 new program itt-pcm-br (PCM bridge)
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
52 }