FreeCalypso > hg > ice1-trau-tester
annotate pcm/read_ts.c @ 18:61862af2247f
ater: E1 timeslot output (osmo_i460 mux)
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 24 Jun 2024 07:26:20 +0000 |
parents | ca351324187a |
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> |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "globals.h" |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 uint8_t readbuf[160]; |
6
631f2db08538
pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
17 FILE *record_file; |
2
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 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
|
20 { |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 int rc; |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 rc = read(ts_fd, readbuf, 160); |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (rc != 160) { |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 fprintf(stderr, |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 "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
|
27 rc); |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 exit(1); |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
6
631f2db08538
pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
30 if (record_file) |
631f2db08538
pcm: implement print-rx and record commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
31 fwrite(readbuf, 1, 160, record_file); |
7
ca351324187a
pcm: implement Tx on the E1 timeslot
Mychaela Falconia <falcon@freecalypso.org>
parents:
6
diff
changeset
|
32 transmit_pcm_20ms(); |
2
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return 0; |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |