aboutsummaryrefslogtreecommitdiff
path: root/broccoli
diff options
context:
space:
mode:
Diffstat (limited to 'broccoli')
-rw-r--r--broccoli/Makefile12
-rw-r--r--broccoli/includes/midbropasad.h6
-rw-r--r--broccoli/src/midbropasad.c18
-rw-r--r--broccoli/test/pasad_test.c11
4 files changed, 28 insertions, 19 deletions
diff --git a/broccoli/Makefile b/broccoli/Makefile
index d115d95..a3bc87a 100644
--- a/broccoli/Makefile
+++ b/broccoli/Makefile
@@ -1,20 +1,24 @@
CC=gcc
+LIBCFLAGS =-c -fPIC -DBROCCOLI
CFLAGS =-c -DBROCCOLI
INC =-I/usr/local/include -I/usr/local/include -I./includes
LDFLAGS = -L/usr/local/lib -lbroccoli -pthread
SRC = midbropasad.c broevent.c fifoqueue.c
OBJ = $(patsubst %.c, build/%.o, $(SRC))
-all: dirs bin/midbropasad bin/tests
+all: dirs bin/midbropasad
dirs:
- mkdir -p build bin
+ mkdir -p build bin lib
bin/midbropasad: $(OBJ)
- $(CC) $^ -o bin/midbropasad $(LDFLAGS)
+ $(CC) -shared $^ -o lib/libmidbropasad.so $(LDFLAGS)
+
+pasad_test:
+ $(CC) test/pasad_test.c -I./includes -o bin/pasad_test -L./lib -lmidbropasad
build/%.o: src/%.c
- $(CC) $(CFLAGS) $(INC) $< -o $@
+ $(CC) $(LIBCFLAGS) $(INC) $< -o $@
bin/tests: build/fifoqueue.o build/tests.o
$(CC) $^ -o bin/tests $(LDFLAGS)
diff --git a/broccoli/includes/midbropasad.h b/broccoli/includes/midbropasad.h
new file mode 100644
index 0000000..73e3bec
--- /dev/null
+++ b/broccoli/includes/midbropasad.h
@@ -0,0 +1,6 @@
+#ifndef MIDBROPASAD_H
+#define MIDBROPASAD_H
+void request_n_values(int number, int arrayOfValues[]);
+int request_value();
+void start_data_capture();
+#endif
diff --git a/broccoli/src/midbropasad.c b/broccoli/src/midbropasad.c
index 04da7a0..cc93e7f 100644
--- a/broccoli/src/midbropasad.c
+++ b/broccoli/src/midbropasad.c
@@ -33,8 +33,10 @@ request_value()
}
void
-start_data_capture(Fifo_q * q)
+start_data_capture()
{
+
+ q = init_queue(50);
int res;
pthread_t event_listener;
res = pthread_create(&event_listener, NULL, bro_event_listener, q);
@@ -43,17 +45,3 @@ start_data_capture(Fifo_q * q)
exit(-1);
}
}
-
- int
-main(int argc, char **argv)
-{
- Fifo_q * q = init_queue(50);
- start_data_capture(q);
- sleep(10);
- while(true){
- print_queue(q);
- request_value();
- }
- free(q);
- return 0;
-}
diff --git a/broccoli/test/pasad_test.c b/broccoli/test/pasad_test.c
new file mode 100644
index 0000000..5ed3481
--- /dev/null
+++ b/broccoli/test/pasad_test.c
@@ -0,0 +1,11 @@
+#include "midbropasad.h"
+
+ int
+main(int argc, char **argv)
+{
+ start_data_capture();
+ while(1){
+ request_value();
+ }
+ return 0;
+}