summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-07-15 12:26:46 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2023-07-15 12:26:46 +0200
commit97e167da1bd01570562913d6e496241f6cdb246e (patch)
treea109c7b01b96b40bb8dfe5a7596651e419813f01
parent3da360332b38ba50e2a03f4b9287bc916523e492 (diff)
Minor changes
-rw-r--r--src/logger.c2
-rw-r--r--src/publisher.c19
2 files changed, 18 insertions, 3 deletions
diff --git a/src/logger.c b/src/logger.c
index 8c5a454..3ba934e 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -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
diff --git a/src/publisher.c b/src/publisher.c
index 8764294..1416738 100644
--- a/src/publisher.c
+++ b/src/publisher.c
@@ -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");
+ }
}
}
}