mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-07 04:16:26 +02:00
Minor changes
This commit is contained in:
parent
8f6bf2c440
commit
fe62b11365
4 changed files with 18 additions and 8 deletions
10
Makefile
10
Makefile
|
@ -3,16 +3,20 @@ include $(CONF)
|
||||||
CC="gcc"
|
CC="gcc"
|
||||||
CFLAGS=
|
CFLAGS=
|
||||||
|
|
||||||
|
MACROS=\
|
||||||
|
-DZMQ_TOKEN=\"$(ZMQ_TOKEN)\" \
|
||||||
|
-DZMQ_MSG_SIZE=$(ZMQ_MSG_SIZE)
|
||||||
|
|
||||||
all: publisher subscriber logger
|
all: publisher subscriber logger
|
||||||
|
|
||||||
publisher: src/publisher.c src/utils.c
|
publisher: src/publisher.c src/utils.c
|
||||||
$(CC) -lzmq $^ -o $@
|
$(CC) -lzmq $^ -o $@ $(MACROS)
|
||||||
|
|
||||||
subscriber: src/subscriber.c src/utils.c
|
subscriber: src/subscriber.c src/utils.c
|
||||||
$(CC) -lzmq $^ -o $@
|
$(CC) -lzmq $^ -o $@ $(MACROS)
|
||||||
|
|
||||||
logger: src/logger.c src/utils.c
|
logger: src/logger.c src/utils.c
|
||||||
$(CC) $^ -o $@
|
$(CC) $^ -o $@ $(MACROS)
|
||||||
|
|
||||||
publish: publisher logger
|
publish: publisher logger
|
||||||
[ -f pid ] && { kill $(shell cat pid); rm pid; }
|
[ -f pid ] && { kill $(shell cat pid); rm pid; }
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
##### ZeroMQ
|
##### ZeroMQ
|
||||||
ZMQ_PORT=5556
|
ZMQ_PORT=5556
|
||||||
SUBSCRIBER_ADDR=localhost
|
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
|
##### Logger/Publisher
|
||||||
# LOGGERS_DIR will contains all the data generated by the loggers
|
# LOGGERS_DIR will contains all the data generated by the loggers
|
||||||
|
|
|
@ -17,6 +17,7 @@ void publish(void *publisher, char *filepath, char* client, long int interval);
|
||||||
|
|
||||||
int main (int argc, char *argv [])
|
int main (int argc, char *argv [])
|
||||||
{
|
{
|
||||||
|
printf("%d\n",ZMQ_MSG_SIZE);
|
||||||
if(argc != 6){
|
if(argc != 6){
|
||||||
printf("Usage: %s <abslogdir> <loginterval> <ip> <port> <key>",argv[0]);
|
printf("Usage: %s <abslogdir> <loginterval> <ip> <port> <key>",argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -8,25 +8,24 @@
|
||||||
#define MIN_INTERVAL 30
|
#define MIN_INTERVAL 30
|
||||||
#define INA260_SYSFS "/sys/kernel/ina260"
|
#define INA260_SYSFS "/sys/kernel/ina260"
|
||||||
#define INA260_POWER_REGISTER "registers/power"
|
#define INA260_POWER_REGISTER "registers/power"
|
||||||
|
|
||||||
#ifndef ZMQ_TOKEN
|
#ifndef ZMQ_TOKEN
|
||||||
#define ZMQ_TOKEN "ina260-zmq-publisher"
|
#define ZMQ_TOKEN "ina260-zmq-publisher"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ZMQ_MSG_SIZE
|
||||||
#define ZMQ_MSG_SIZE 255*10
|
#define ZMQ_MSG_SIZE 255*10
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STR(symbol) #symbol
|
#define STR(symbol) #symbol
|
||||||
#define STRINGIFY(symbol) STR(symbol)
|
#define STRINGIFY(symbol) STR(symbol)
|
||||||
|
|
||||||
#define TIMESTAMP() (time(NULL))
|
#define TIMESTAMP() (time(NULL))
|
||||||
|
|
||||||
#define INTERVAL(duration)\
|
#define INTERVAL(duration)\
|
||||||
((TIMESTAMP()) - ((TIMESTAMP())%(duration)))
|
((TIMESTAMP()) - ((TIMESTAMP())%(duration)))
|
||||||
|
|
||||||
#define INTERVAL_NEXT(duration)\
|
#define INTERVAL_NEXT(duration)\
|
||||||
((INTERVAL(duration))+(duration))
|
((INTERVAL(duration))+(duration))
|
||||||
|
|
||||||
#define INTERVAL_LAST(duration)\
|
#define INTERVAL_LAST(duration)\
|
||||||
(INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))
|
(INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))
|
||||||
|
|
||||||
#define FILE_EXISTS(path) (access((path), F_OK) == 0)
|
#define FILE_EXISTS(path) (access((path), F_OK) == 0)
|
||||||
|
|
||||||
void mkdirp(char *path);
|
void mkdirp(char *path);
|
Loading…
Add table
Reference in a new issue