[OSADL-svn-commits] r111 - trunks/fddi-trunk/tests

OSADL repository commits osadl-svn-commits at lists.osadl.org
Tue Oct 2 11:48:20 CEST 2007


Author: robert
Date: Sat Sep  8 21:52:08 2007
New Revision: 111

Log:


Added:
   trunks/fddi-trunk/tests/usecase_streaming.c
Modified:
   trunks/fddi-trunk/tests/usecase_controller.c

Modified: trunks/fddi-trunk/tests/usecase_controller.c
==============================================================================
--- trunks/fddi-trunk/tests/usecase_controller.c	(original)
+++ trunks/fddi-trunk/tests/usecase_controller.c	Sat Sep  8 21:52:08 2007
@@ -112,6 +112,7 @@
 	PV_CREATE(Ki, uint32);
 	PV_CREATE(Kd, uint32);
 
+	/* incoming tpu containing variable 'input' is a trigger */
 	PV_TRIGGER_CREATE(input);
 
 	/* control loop */

Added: trunks/fddi-trunk/tests/usecase_streaming.c
==============================================================================
--- (empty file)
+++ trunks/fddi-trunk/tests/usecase_streaming.c	Sat Sep  8 21:52:08 2007
@@ -0,0 +1,110 @@
+#include <signal.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+//#include <osadl/ldi.h>
+
+/* FIXME put into header file */
+
+	typedef struct ldi_attr {
+	} ldi_attr_t;
+
+	typedef struct ldi {
+	} ldi_t;
+	typedef struct pv {
+	} pv_t;
+	typedef struct tpu {
+	} tpu_t;
+
+	/* pv */
+	int pv_uint32_create(pv_t *pv, ldi_t *ldi, const char *name);
+	int pv_uint32_destroy(pv_t *pv);
+	uint32_t pv_uint32_get(pv_t *pv);
+	void pv_uint32_set(pv_t *pv, uint32_t val);
+
+	/* tpu */
+	int tpu_create(tpu_t *tpu /*, FIXME */);
+	int tpu_destroy(tpu_t *tpu);
+
+	/* ldi_attr */
+	int ldi_attr_init_from_cmdline(ldi_attr_t *attr, int argc, char *argv[]);
+	int ldi_attr_destroy(ldi_attr_t *attr);
+
+	/* ldi */
+	int ldi_create(ldi_t *ldi, ldi_attr_t *attr);
+	int ldi_destroy(ldi_t *ldi);
+	int ldi_trigger_define(ldi_t *ldi, pv_t *pv);
+	int ldi_trigger_wait(ldi_t *ldi, uint64_t timeout_ns);
+	int ldi_tpu_trigger_define(ldi_t *ldi, tpu_t *tpu);
+
+
+static int shutdown = 0;
+
+void
+signalhandler(int sig)
+{
+	if ((sig == SIGPIPE) || (sig == SIGHUP))
+		return;
+	if (sig == SIGTERM || sig == SIGINT)
+		shutdown = 1;
+}
+
+int main(int argc, char *argv[])
+{
+	struct sigaction action;
+	ldi_attr_t ldi_attr;
+	ldi_t ldi;
+	int ret;
+
+	tpu_t tpu;
+
+	/* setup signal handler */
+	action.sa_handler = signalhandler;
+	sigemptyset (&action.sa_mask);
+	action.sa_flags = 0;
+	sigaction (SIGTERM, &action, 0);        /* catches kill from the shell   */
+	sigaction (SIGINT,  &action, 0);        /* catches Ctrl-C from the shell */
+	sigaction (SIGPIPE, &action, 0);        /* catches Broken Pipe exception */
+	sigaction (SIGHUP,  &action, 0);        /* catches HUP                   */
+
+	/* initialize ldi */
+	ret = ldi_attr_init_from_cmdline(&ldi_attr, argc, argv);
+	if (ret) {
+		fprintf(stderr, "error: could not init ldi_attr\n");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = ldi_create(&ldi, &ldi_attr);
+	if (ret) {
+		fprintf(stderr, "error: couldn't create ldi\n");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = tpu_create(&tpu); /* FIXME: how to find out which one? */
+	if (ret) {
+		fprintf(stderr, "error: could not register tpu\n");
+		exit(EXIT_FAILURE);
+	}
+
+	/* this TPU is our trigger */
+	ret = ldi_tpu_trigger_define(&ldi, &tpu);
+
+	/* control loop */
+	while (!shutdown) {
+
+		ret = ldi_trigger_wait(&ldi, 100*1000*1000); /* wait until trigger fires, with timeout in ns */
+		if (ret)
+			continue;
+
+		/* FIXME now what to do with the tpu payload? */
+		/* FIXME how to decide when TPUs are pushed back to the pool? */
+
+	}
+
+	tpu_destroy(&tpu);
+
+	ldi_destroy(&ldi);
+	ldi_attr_destroy(&ldi_attr);
+	return ret;
+}


More information about the OSADL-svn-commits mailing list