Minor changes

This commit is contained in:
Loic Guegan 2023-07-16 14:50:53 +02:00
parent e0fdde7cd0
commit 33c5443794
4 changed files with 37 additions and 6 deletions

View file

@ -8,6 +8,7 @@
#include <sys/stat.h>
#include "utils.h"
#include <time.h>
#include <signal.h>
#ifndef LOGGER_DELAY
#define LOGGER_DELAY 0
@ -18,6 +19,14 @@ char *__client;
char __logdir[STATIC_LEN];
char __regpower[STATIC_LEN];
int __loginterval;
unsigned char __stop=0;
void sighandler(int signo){
if (signo == SIGINT){
printf("Stopping...\n");
__stop=1;
}
}
int main (int argc, char *argv [])
{
@ -41,6 +50,7 @@ int main (int argc, char *argv [])
strcat(__regpower,INA260_POWER_REGISTER);
//----- Sanity checks
signal(SIGINT,sighandler);
mkdirp(__logdir);
if(__loginterval<MIN_INTERVAL){
printf("Log interval is too small (min=%ds)\n",MIN_INTERVAL);
@ -62,7 +72,7 @@ int main (int argc, char *argv [])
time_t interval;
struct timespec power_ts;
while(1){
while(!__stop){
interval=INTERVAL(__loginterval);
*logfilepath='\0';
sprintf(logfilepath,"%s/%ld",__logdir,interval);