From 9c87ed9c965847ee784c4bae092e9d27ee2ffed7 Mon Sep 17 00:00:00 2001 From: Robert Gustafsson Date: Sat, 14 Oct 2017 11:18:03 +0200 Subject: Rename midbropasad -> midbro in C impl.. * files in script/ are not changed --- broccoli/src/broevent.c | 4 ++-- broccoli/src/midbro.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ broccoli/src/midbropasad.c | 47 --------------------------------------------- 3 files changed, 50 insertions(+), 49 deletions(-) create mode 100644 broccoli/src/midbro.c delete mode 100644 broccoli/src/midbropasad.c (limited to 'broccoli/src') diff --git a/broccoli/src/broevent.c b/broccoli/src/broevent.c index 206ce17..362ed5e 100644 --- a/broccoli/src/broevent.c +++ b/broccoli/src/broevent.c @@ -9,7 +9,7 @@ char *port_default = "47760"; Fifo_q * q; static void -pasad_register_received(BroConn *conn, void *data, BroRecord *record) +modbus_register_received(BroConn *conn, void *data, BroRecord *record) { int type = BRO_TYPE_COUNT; uint64 *address = NULL; @@ -56,7 +56,7 @@ bro_event_listener(void * args) bro_debug_messages = 0; bro_event_registry_add(bc, "pasad_register_received", - (BroEventFunc) pasad_register_received, NULL); + (BroEventFunc) modbus_register_received, NULL); if (! bro_conn_connect(bc)) { diff --git a/broccoli/src/midbro.c b/broccoli/src/midbro.c new file mode 100644 index 0000000..6c83207 --- /dev/null +++ b/broccoli/src/midbro.c @@ -0,0 +1,48 @@ +#include +#include +#include "fifoqueue.h" +#include "broevent.h" +#include "midbro.h" +#ifdef BROCCOLI +#include +#endif + +Fifo_q * queue; + + void +request_n_values(int number, int arrayOfValues[]) +{ + int i; + Sensor_t * sensor; + for(i=0; ivalue; + free(sensor); + } + printf("Release %d sensor data values\n", number); +} + int +request_value() +{ + int value; + Sensor_t * sensor; + sensor = pop_from_queue(queue); + value = sensor->value; + free(sensor); + printf("Release 1 sensor data value\n"); + return value; +} + + void +start_data_capture() +{ + int res; + queue = init_queue(500000); /* Initiate queue with fixed size */ + pthread_t event_listener; + /* Create producer thread that listen for bro events */ + res = pthread_create(&event_listener, NULL, bro_event_listener, queue); + if(res){ + perror("Unable to create thread"); + exit(-1); + } +} diff --git a/broccoli/src/midbropasad.c b/broccoli/src/midbropasad.c deleted file mode 100644 index a745091..0000000 --- a/broccoli/src/midbropasad.c +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include "fifoqueue.h" -#include "broevent.h" -#ifdef BROCCOLI -#include -#endif - -Fifo_q * queue; - - void -request_n_values(int number, int arrayOfValues[]) -{ - int i; - Sensor_t * sensor; - for(i=0; ivalue; - free(sensor); - } - printf("Release %d sensor data values\n", number); -} - int -request_value() -{ - int value; - Sensor_t * sensor; - sensor = pop_from_queue(queue); - value = sensor->value; - free(sensor); - printf("Release 1 sensor data value\n"); - return value; -} - - void -start_data_capture() -{ - int res; - queue = init_queue(500000); /* Initiate queue with fixed size */ - pthread_t event_listener; - /* Create producer thread that listen for bro events */ - res = pthread_create(&event_listener, NULL, bro_event_listener, queue); - if(res){ - perror("Unable to create thread"); - exit(-1); - } -} -- cgit v1.2.3