FreeCalypso > hg > ice1-trau-tester
annotate ater/read_ts.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 | 61862af2247f |
children |
rev | line source |
---|---|
2
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * The function in this module gets called from Osmocom select loop |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * whenever the data socket to osmo-e1d is ready for reading. |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
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 #include <stdint.h> |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdbool.h> |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <unistd.h> |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <osmocom/core/select.h> |
16
4ffe22f5b4b5
ater: initial osmo_i460 framework
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
13 #include <osmocom/isdn/i460_mux.h> |
2
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 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 uint8_t readbuf[160]; |
6
631f2db08538
pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
18 FILE *record_file; |
2
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 int ts_fd_cb(struct osmo_fd *ofd, unsigned int what) |
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 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 rc = read(ts_fd, readbuf, 160); |
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, |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 "error: read from ts returned %d instead of 160\n", |
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 } |
6
631f2db08538
pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
31 if (record_file) |
631f2db08538
pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
32 fwrite(readbuf, 1, 160, record_file); |
16
4ffe22f5b4b5
ater: initial osmo_i460 framework
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
33 osmo_i460_demux_in(&i460_ts, readbuf, 160); |
18
61862af2247f
ater: E1 timeslot output (osmo_i460 mux)
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
34 transmit_e1_ts(); |
2
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 return 0; |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |