Minor changes

This commit is contained in:
Loic Guegan 2023-07-16 09:56:30 +02:00
parent 268acd0c8e
commit 1028f22e16

View file

@ -56,18 +56,19 @@ int main (int argc, char *argv [])
char buffer[255];
int power;
time_t interval;
struct timespec power_ts;
while(1){
interval=INTERVAL(__loginterval);
*logfilepath='\0';
sprintf(logfilepath,"%s/%ld",__logdir,interval);
logptr=fopen(logfilepath,"w");
fprintf(logptr,"timestamp,power\n");
fprintf(logptr,"timestamp,ns,power\n");
// Log current interval
while((TIMESTAMP()-interval)<__loginterval){
fgets(buffer,255,regptr);
power=atoi(buffer);
fprintf(logptr,"%ld,%d\n",TIMESTAMP(),power);
clock_gettime(CLOCK_REALTIME,&power_ts);
fprintf(logptr,"%d,%ld,%d\n",power_ts.tv_sec,power_ts.tv_nsec,power);
fseek(regptr,0,SEEK_SET);
sleep(1);
printf("Tick\n"); fflush(stdout);