mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-19 12:19:46 +00:00
Minor changes
This commit is contained in:
parent
e0fdde7cd0
commit
33c5443794
4 changed files with 37 additions and 6 deletions
12
src/logger.c
12
src/logger.c
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue