dol: initial dol commit
[jump.git] / dol / examples / exampleproducerconsumer / src / consumer.c
diff --git a/dol/examples/exampleproducerconsumer/src/consumer.c b/dol/examples/exampleproducerconsumer/src/consumer.c
new file mode 100644 (file)
index 0000000..c39157b
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+#include "consumer.h"
+
+void consumer_init(DOLProcess *p) {
+    sprintf(p->local->name, "consumer");
+}
+
+int consumer_fire(DOLProcess *p) {
+    char c;
+
+    if (DOL_rtest((void*)PORT_INB, 1, p)) {
+        DOL_read((void*)PORT_INA, &c, sizeof(char), p);
+        printf("from port B: %c\n", c);
+        DOL_read((void*)PORT_INA, &c, sizeof(char), p);
+        printf("from port A: %c\n", c);
+    }
+
+    return 0;
+}
+