comparison ft16/read_ts.c @ 2:5c18cd38c8ad

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