annotate ft16/read_ts.c @ 6:3ab5e2e17da2 default tip

add README
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 29 Aug 2024 14:56:30 +0000
parents 5c18cd38c8ad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The function in this module gets called from Osmocom select loop
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * whenever the data socket to osmo-e1d is ready for reading.
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdbool.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <osmocom/core/select.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <osmocom/isdn/i460_mux.h>
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "globals.h"
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 uint8_t readbuf[160];
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 FILE *record_file;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int ts_fd_cb(struct osmo_fd *ofd, unsigned int what)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 int rc;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 rc = read(ts_fd, readbuf, 160);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (rc != 160) {
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 fprintf(stderr,
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 "error: read from ts returned %d instead of 160\n",
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 rc);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (record_file)
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 fwrite(readbuf, 1, 160, record_file);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 osmo_i460_demux_in(&i460_ts, readbuf, 160);
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 transmit_e1_ts();
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 return 0;
5c18cd38c8ad ft16: import from ice1-trau-tester/abis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }