comparison abis/read_ts.c @ 30:5dd30224b70a

abis: starting new program
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Aug 2024 21:38:55 +0000
parents ater/read_ts.c@61862af2247f
children
comparison
equal deleted inserted replaced
29:1dda11905e85 30:5dd30224b70a
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 }