changeset 5:7233c10af3ad

pcm: hook in stdin select mechanism
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 23 Jun 2024 18:33:09 +0000
parents 2ce0ed560a34
children 631f2db08538
files pcm/Makefile pcm/globals.h pcm/main.c pcm/user_cmd.c
diffstat 4 files changed, 27 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pcm/Makefile	Sun Jun 23 17:58:32 2024 +0000
+++ b/pcm/Makefile	Sun Jun 23 18:33:09 2024 +0000
@@ -1,5 +1,5 @@
 PROG=	itt-pcm-one
-OBJS=	main.o read_ts.o
+OBJS=	main.o read_ts.o user_cmd.o
 LIBUTIL=../libutil/libutil.a
 
 include ../config.defs
--- a/pcm/globals.h	Sun Jun 23 17:58:32 2024 +0000
+++ b/pcm/globals.h	Sun Jun 23 18:33:09 2024 +0000
@@ -7,3 +7,4 @@
 extern uint8_t readbuf[160];
 
 int ts_fd_cb(struct osmo_fd *ofd, unsigned int what);
+void handle_user_cmd(int argc, char **argv);
--- a/pcm/main.c	Sun Jun 23 17:58:32 2024 +0000
+++ b/pcm/main.c	Sun Jun 23 18:33:09 2024 +0000
@@ -19,6 +19,7 @@
 #include <osmocom/e1d/proto_clnt.h>
 
 #include "../libutil/open_ts.h"
+#include "../libutil/stdin_handler.h"
 #include "globals.h"
 
 struct osmo_e1dp_client *g_client;
@@ -27,7 +28,7 @@
 static const char *e1d_socket_path = E1DP_DEFAULT_SOCKET;
 static const char *timeslot_spec;
 static void *g_ctx;
-static struct osmo_fd ts_ofd;
+static struct osmo_fd ts_ofd, stdin_ofd;
 
 static void process_cmdline(int argc, char **argv)
 {
@@ -70,6 +71,10 @@
 	osmo_fd_setup(&ts_ofd, ts_fd, OSMO_FD_READ, ts_fd_cb, NULL, 0);
 	OSMO_ASSERT(osmo_fd_register(&ts_ofd) == 0);
 
+	osmo_fd_setup(&stdin_ofd, 0, OSMO_FD_READ, stdin_select_cb,
+			handle_user_cmd, 0);
+	OSMO_ASSERT(osmo_fd_register(&stdin_ofd) == 0);
+
 	while (1) {
 		osmo_select_main(0);
 	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pcm/user_cmd.c	Sun Jun 23 18:33:09 2024 +0000
@@ -0,0 +1,19 @@
+/*
+ * In this module we handle user-issued stdin commands during
+ * itt-pcm-one running session.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <osmocom/core/select.h>
+
+#include "globals.h"
+
+void handle_user_cmd(int argc, char **argv)
+{
+	/* to be filled */
+}