annotate pcm/read_ts.c @ 52:626180a15857 default tip

ater play-d144: emit E-data frames manually, osmo_trau_frame_encode() is currently broken for this frame type
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 25 Sep 2024 06:40:43 +0000
parents ca351324187a
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 /*
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 }