diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pcm/read_ts.c	Sun Jun 23 08:35:46 2024 +0000
@@ -0,0 +1,30 @@
+/*
+ * The function in this module gets called from Osmocom select loop
+ * whenever the data socket to osmo-e1d is ready for reading.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <osmocom/core/select.h>
+
+#include "globals.h"
+
+uint8_t readbuf[160];
+
+int ts_fd_cb(struct osmo_fd *ofd, unsigned int what)
+{
+	int rc;
+
+	rc = read(ts_fd, readbuf, 160);
+	if (rc != 160) {
+		fprintf(stderr,
+			"error: read from ts returned %d instead of 160\n",
+			rc);
+		exit(1);
+	}
+	return 0;
+}