summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-07-15 21:38:12 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2023-07-15 21:38:12 +0200
commitfe62b113653199d0678024b5126a17166b6bf5b0 (patch)
treec5168382070b6a06d755e5e3dc3fe531dedf2c96
parent8f6bf2c440444b3dbb900fd5a8319cacfa0f3730 (diff)
Minor changes
-rw-r--r--Makefile10
-rw-r--r--config.mk6
-rw-r--r--src/publisher.c1
-rw-r--r--src/utils.h9
4 files changed, 18 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 7d032f4..692f123 100644
--- a/Makefile
+++ b/Makefile
@@ -3,16 +3,20 @@ include $(CONF)
CC="gcc"
CFLAGS=
+MACROS=\
+-DZMQ_TOKEN=\"$(ZMQ_TOKEN)\" \
+-DZMQ_MSG_SIZE=$(ZMQ_MSG_SIZE)
+
all: publisher subscriber logger
publisher: src/publisher.c src/utils.c
- $(CC) -lzmq $^ -o $@
+ $(CC) -lzmq $^ -o $@ $(MACROS)
subscriber: src/subscriber.c src/utils.c
- $(CC) -lzmq $^ -o $@
+ $(CC) -lzmq $^ -o $@ $(MACROS)
logger: src/logger.c src/utils.c
- $(CC) $^ -o $@
+ $(CC) $^ -o $@ $(MACROS)
publish: publisher logger
[ -f pid ] && { kill $(shell cat pid); rm pid; }
diff --git a/config.mk b/config.mk
index 40409b2..020550b 100644
--- a/config.mk
+++ b/config.mk
@@ -1,6 +1,12 @@
##### ZeroMQ
ZMQ_PORT=5556
SUBSCRIBER_ADDR=localhost
+# ZMQ_TOKEN is used by ZeroMQ to detect
+# messages from publishers. Leave as is if not sure.
+ZMQ_TOKEN="ina260-zmq-publisher"
+# ZMQ_MSG_SIZE max number of bytes per ZeroMQ messages
+# be careful with this parameter
+ZMQ_MSG_SIZE=2550
##### Logger/Publisher
# LOGGERS_DIR will contains all the data generated by the loggers
diff --git a/src/publisher.c b/src/publisher.c
index 7c401c4..56fea78 100644
--- a/src/publisher.c
+++ b/src/publisher.c
@@ -17,6 +17,7 @@ void publish(void *publisher, char *filepath, char* client, long int interval);
int main (int argc, char *argv [])
{
+ printf("%d\n",ZMQ_MSG_SIZE);
if(argc != 6){
printf("Usage: %s <abslogdir> <loginterval> <ip> <port> <key>",argv[0]);
exit(1);
diff --git a/src/utils.h b/src/utils.h
index 4fd6b68..d427d01 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -8,25 +8,24 @@
#define MIN_INTERVAL 30
#define INA260_SYSFS "/sys/kernel/ina260"
#define INA260_POWER_REGISTER "registers/power"
+
#ifndef ZMQ_TOKEN
#define ZMQ_TOKEN "ina260-zmq-publisher"
#endif
+
+#ifndef ZMQ_MSG_SIZE
#define ZMQ_MSG_SIZE 255*10
+#endif
#define STR(symbol) #symbol
#define STRINGIFY(symbol) STR(symbol)
-
#define TIMESTAMP() (time(NULL))
-
#define INTERVAL(duration)\
((TIMESTAMP()) - ((TIMESTAMP())%(duration)))
-
#define INTERVAL_NEXT(duration)\
((INTERVAL(duration))+(duration))
-
#define INTERVAL_LAST(duration)\
(INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))
-
#define FILE_EXISTS(path) (access((path), F_OK) == 0)
void mkdirp(char *path); \ No newline at end of file