Minor changes

This commit is contained in:
Loic Guegan 2023-07-15 19:12:13 +02:00
parent 644bd0f612
commit b63811848f
4 changed files with 15 additions and 13 deletions

View file

@ -1,6 +1,6 @@
##### ZeroMQ
PUBLISHER_PORT=5556
PUBLISHER_INTERFACE=*
ZMQ_PORT=5556
SUBSCRIBER_ADDR=localhost
##### Logger/Publisher
# LOGGERS_DIR will contains all the data generated by the loggers

View file

@ -10,15 +10,14 @@
int main (int argc, char *argv [])
{
if(argc != 4){
printf("Usage: %s <address> <port> <cdatadir>",argv[0]);
if(argc != 3){
printf("Usage: %s <port> <cdatadir>",argv[0]);
exit(1);
}
//----- Arguments
char *ip=argv[1];
int port=atoi(argv[2]);
char *cdatadir=argv[3];
int port=atoi(argv[1]);
char *cdatadir=argv[2];
//----- Various inits
mkdirp(cdatadir);
@ -27,7 +26,7 @@ int main (int argc, char *argv [])
void *context = zmq_ctx_new ();
void *subscriber = zmq_socket (context, ZMQ_SUB);
char bindto[30];
sprintf(bindto,"tcp://%s:%d",ip,port);
sprintf(bindto,"tcp://*:%d",port);
int rc = zmq_bind (subscriber, bindto);
if(rc!=0){
printf("Failed to bind zmq on %s\n",bindto);

View file

@ -13,6 +13,7 @@
char *__logdir;
char *__key;
char *__interface;
char *__ip;
int __loginterval;
int __port;
@ -21,22 +22,22 @@ void publish(void *publisher, char *filepath, char* client, long int interval);
int main (int argc, char *argv [])
{
if(argc != 6){
printf("Usage: %s <abslogdir> <loginterval> <port> <key> <interface>",argv[0]);
printf("Usage: %s <abslogdir> <loginterval> <ip> <port> <key>",argv[0]);
exit(1);
}
//----- Init global variables
__logdir=argv[1];
__loginterval=atoi(argv[2]);
__port=atoi(argv[3]);
__key=argv[4];
__interface=argv[5];
__ip=argv[3];
__port=atoi(argv[4]);
__key=argv[5];
//----- Prepare our context and publisher
void *context = zmq_ctx_new ();
void *publisher = zmq_socket (context, ZMQ_PUB);
char bindto[30];
sprintf(bindto,"tcp://%s:%d",__interface,__port);
sprintf(bindto,"tcp://%s:%d",__ip,__port);
int rc = zmq_connect (publisher, bindto);
if(rc!=0){
printf("Failed to bind zmq on %s\n",bindto);

View file

@ -8,7 +8,9 @@
#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
#define ZMQ_MSG_SIZE 255*10
#define STR(symbol) #symbol