2023-07-15 10:31:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-15 10:11:50 +02:00
|
|
|
#include <time.h>
|
2023-07-15 10:31:36 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2023-07-16 12:12:49 +02:00
|
|
|
#include <dirent.h>
|
2023-07-15 10:11:50 +02:00
|
|
|
|
2023-07-15 10:34:20 +02:00
|
|
|
#define MIN_INTERVAL 30
|
2023-07-15 09:25:30 +02:00
|
|
|
#define INA260_SYSFS "/sys/kernel/ina260"
|
|
|
|
#define INA260_POWER_REGISTER "registers/power"
|
2023-07-16 10:46:52 +02:00
|
|
|
#define STATIC_LEN 255
|
2023-07-17 14:50:13 +02:00
|
|
|
#define RECORD_QUEUES 1
|
|
|
|
#define RECORD_MAX 1000
|
2023-07-15 21:38:12 +02:00
|
|
|
|
2023-07-15 19:12:13 +02:00
|
|
|
#ifndef ZMQ_TOKEN
|
2023-07-15 14:02:43 +02:00
|
|
|
#define ZMQ_TOKEN "ina260-zmq-publisher"
|
2023-07-15 19:12:13 +02:00
|
|
|
#endif
|
2023-07-15 21:38:12 +02:00
|
|
|
|
|
|
|
#ifndef ZMQ_MSG_SIZE
|
2023-07-16 22:52:16 +02:00
|
|
|
#define ZMQ_MSG_SIZE 5242880
|
2023-07-15 21:38:12 +02:00
|
|
|
#endif
|
2023-07-15 10:11:50 +02:00
|
|
|
|
2023-07-15 10:34:20 +02:00
|
|
|
#define STR(symbol) #symbol
|
|
|
|
#define STRINGIFY(symbol) STR(symbol)
|
2023-07-15 11:43:41 +02:00
|
|
|
#define TIMESTAMP() (time(NULL))
|
|
|
|
#define INTERVAL(duration)\
|
|
|
|
((TIMESTAMP()) - ((TIMESTAMP())%(duration)))
|
2023-07-15 12:14:22 +02:00
|
|
|
#define INTERVAL_NEXT(duration)\
|
|
|
|
((INTERVAL(duration))+(duration))
|
2023-07-15 11:43:41 +02:00
|
|
|
#define INTERVAL_LAST(duration)\
|
|
|
|
(INTERVAL(INTERVAL((TIMESTAMP()),(duration))-1,(duration)))
|
2023-07-15 10:31:36 +02:00
|
|
|
#define FILE_EXISTS(path) (access((path), F_OK) == 0)
|
2023-07-16 12:12:49 +02:00
|
|
|
#define DIR_EXISTS(path) (dir_exists(path))
|
2023-07-15 10:31:36 +02:00
|
|
|
|
2023-07-16 12:12:49 +02:00
|
|
|
void mkdirp(char *path);
|
|
|
|
unsigned char dir_exists(char *path);
|