Minor changes

This commit is contained in:
Loic Guegan 2023-07-15 12:26:46 +02:00
parent 3da360332b
commit 97e167da1b
2 changed files with 18 additions and 3 deletions

View file

@ -63,7 +63,7 @@ int main (int argc, char *argv [])
for(int i=0;i<1;i++){
interval=INTERVAL(__loginterval);
*logfilepath='\0';
sprintf(logfilepath,"%s/%ld",__logdir);
sprintf(logfilepath,"%s/%ld",__logdir,interval);
logptr=fopen(logfilepath,"w");
fprintf(logptr,"timestamp,power\n");
// Log current interval

View file

@ -24,15 +24,30 @@ int main (int argc, char *argv [])
__logdir=argv[1];
__loginterval=atoi(argv[2]);
//----- Start publisher
DIR *dr = opendir(__logdir);
struct dirent *de; // Pointer for directory entry
for(int i=0;i<0;i++){
for(int i=0;i<=0;i++){
int interval=INTERVAL(__loginterval);
int interval_next=INTERVAL_NEXT(__loginterval);
while ((de = readdir(dr)) != NULL){
if(strcmp(de->d_name,".") && strcmp(de->d_name,"..")){
char *client=de->d_name;
printf("aa%s\n",client);
char logfile[255];
char logfile_next[255];
sprintf(logfile,"%s/%s/%ld",__logdir,client,interval);
sprintf(logfile_next,"%s/%s/%ld",__logdir,client,interval_next);
// As long as next logfile is not available, we should wait
// for sending the current one
printf("Waiting for %s...%s\n",client,logfile_next);
while(!FILE_EXISTS(logfile_next)){
sleep(1);
}
// Send current one
if(FILE_EXISTS(logfile)){
printf("Sending....\n");
}
}
}
}