FreeCalypso > hg > ice1-trau-tester
annotate pcm/read_ts.c @ 2:c03ec046471f
pcm: initial version compiles and links
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 23 Jun 2024 08:35:46 +0000 |
parents | |
children | 631f2db08538 |
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]; |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 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
|
19 { |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 int rc; |
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 rc = read(ts_fd, readbuf, 160); |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (rc != 160) { |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 fprintf(stderr, |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 "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
|
26 rc); |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 exit(1); |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 return 0; |
c03ec046471f
pcm: initial version compiles and links
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |