Minor changes

This commit is contained in:
Loic Guegan 2023-07-15 11:48:06 +02:00
parent 83e6235919
commit ec60f1e34a

View file

@ -18,8 +18,6 @@ char __logdir[255];
char __regpower[100];
int __loginterval;
void start(char *power_path, char *busid, char *chipaddr);
int main (int argc, char *argv [])
{
if(argc != 4){
@ -58,11 +56,12 @@ int main (int argc, char *argv [])
FILE *regptr,*logptr;
char logfilepath[255]="";
regptr=fopen("/home/loic/out.txt","r");
char buffer[255];
int power;
time_t interval;
for(int i=0;i<1;i++){
char buffer[255];
int power;
time_t interval=INTERVAL(__loginterval);
interval=INTERVAL(__loginterval);
*logfilepath='\0';
sprintf(logfilepath,"%s/%ld",__logdir);
logptr=fopen(logfilepath,"w");
@ -80,39 +79,5 @@ int main (int argc, char *argv [])
}
fclose(regptr);
// Extract bus id and ina260 chip address
/*char busid[10];
char chipaddr[10];
char *base=basename(argv[1]);
sscanf(base,"%[^-]-%[^-]",busid,chipaddr);
start("/home/loic/out.txt", busid,chipaddr);*/
// printf("ts=%d, dur=%d, interval=%d\n",15,__logfrequency,INTERVAL(15,__logfrequency));
// printf("ts=%d, dur=%d, interval_last=%d\n",15,__logfrequency,INTERVAL_LAST(15,__logfrequency));
return 0;
}
void start(char *power_path, char *busid, char *chipaddr){
if (!FILE_EXISTS(power_path)){
printf("Could not read %s\n",power_path);
exit(2);
}
char outdir[255];
mkdir(STRINGIFY(LOGGER_DIR),0755);
sprintf(outdir,"%s/%s-%s/",STRINGIFY(LOGGER_DIR), busid,chipaddr);
mkdir(outdir,0755);
char outfile[255];
time_t timestamp;
timestamp = time(NULL);
sprintf(outfile,"%s/%d",outdir,timestamp);
printf("aa %s\n",outfile);
FILE *f;
f=fopen(outfile, "w");
fclose(f);
}