diff options
author | Robert Gustafsson <robg@student.chalmers.se> | 2017-10-12 10:09:56 +0200 |
---|---|---|
committer | Robert Gustafsson <robg@student.chalmers.se> | 2017-10-12 10:11:23 +0200 |
commit | 8664b4c13a215221a1c26a6bc1de47226949b35d (patch) | |
tree | 61fa722a085d29618de9c154ba00e8ad1dda87ad | |
parent | 51048c85dd437d501ca82cdc7bb4edc4bb686100 (diff) | |
download | midbro-8664b4c13a215221a1c26a6bc1de47226949b35d.tar.gz midbro-8664b4c13a215221a1c26a6bc1de47226949b35d.tar.bz2 |
Add debug mode
-rw-r--r-- | broccoli/Makefile | 7 | ||||
-rw-r--r-- | broccoli/src/broevent.c | 7 | ||||
-rw-r--r-- | broccoli/src/fifoqueue.c | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/broccoli/Makefile b/broccoli/Makefile index a3bc87a..8e39783 100644 --- a/broccoli/Makefile +++ b/broccoli/Makefile @@ -3,22 +3,23 @@ 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 +DEBUG = SRC = midbropasad.c broevent.c fifoqueue.c OBJ = $(patsubst %.c, build/%.o, $(SRC)) -all: dirs bin/midbropasad +all: dirs lib/midbropasad dirs: mkdir -p build bin lib -bin/midbropasad: $(OBJ) +lib/midbropasad: $(OBJ) $(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) $(LIBCFLAGS) $(INC) $< -o $@ + $(CC) $(LIBCFLAGS) $(DEBUG) $(INC) $< -o $@ bin/tests: build/fifoqueue.o build/tests.o $(CC) $^ -o bin/tests $(LDFLAGS) diff --git a/broccoli/src/broevent.c b/broccoli/src/broevent.c index 8a74881..206ce17 100644 --- a/broccoli/src/broevent.c +++ b/broccoli/src/broevent.c @@ -26,12 +26,15 @@ pasad_register_received(BroConn *conn, void *data, BroRecord *record) // TODO: handle error return; } - + #ifdef DEBUG printf("Received value %"PRIu64" from uid=%"PRIu64"\n",*value,*address); + #endif add_to_queue(q, create_sensor_object(*value, *address)); + #ifdef DEBUG printf("Added to queue.\n"); + #endif } void * @@ -71,7 +74,7 @@ bro_event_listener(void * args) FD_ZERO(&rfds); FD_SET(fd,&rfds); if(select(fd+1,&rfds,NULL,NULL,NULL) == -1){ - perror("select()"); + printf("select(): Bad file descriptor"); break; } diff --git a/broccoli/src/fifoqueue.c b/broccoli/src/fifoqueue.c index 7e30e37..aeeced9 100644 --- a/broccoli/src/fifoqueue.c +++ b/broccoli/src/fifoqueue.c @@ -67,7 +67,9 @@ pop_from_queue(Fifo_q * q) { int semStat; if(is_empty(q)){ + #ifdef DEBUG printf("Waiting for sensor data\n"); + #endif sem_wait(&q->bufferEmptyBlock); } sem_wait(&q->lock); |