static char* pidfile = NULL;
static char* logfile = NULL;
static bool daemonize = false;
-static bool workaround = false;
static char tfile[MAXPATHLEN],
ofile[MAXPATHLEN];
usage(const char *errmsg) {
puts("trinketd - collecting info from AtomPro");
puts("Copyright (c) 2016, Teodor Sigaev <teodor@sigaev.ru>");
- puts("trinketd [-d] [-l logfile] [-p pidfile] [-P period] [-D datadir] [-i tics] [-w]");
+ puts("trinketd [-d] [-l logfile] [-p pidfile] [-P period] [-D datadir] [-i tics]");
if (errmsg) {
puts("");
double *prevDose,
curDose;
int i;
- int collected;
+ int collected = 0;
prevDose = malloc(sizeof(*prevDose) * (tics + 1));
if (!prevDose) {
return;
}
-restart:
collected = 0;
- if (trinketOpen() != ERR_OK) {
- fprintf(stderr, "trinketOpen fails\n");
- sleep(1);
- goto restart;
- }
-
while(42) {
- if (workaround)
- trinketPing();
+ if (trinketOpen() != ERR_OK) {
+ fprintf(stderr, "trinketOpen fails\n");
+ sleep(1);
+ continue;
+ }
if (trinketGetCumDose(&curDose) != ERR_OK) {
fprintf(stderr, "trinketGetCumDose fails\n");
trinketClose();
sleep(1);
- goto restart;
+ continue;
}
if (collected <= tics) {
}
}
+ trinketClose();
sleep(period);
}
-
- trinketClose();
}
logfd;
opterr = 0;
- while((i=getopt(argn,argv,"dD:i:l:p:P:wh")) != EOF) {
+ while((i=getopt(argn,argv,"dD:i:l:p:P:h")) != EOF) {
switch(i) {
case 'd':
daemonize = true;
case 'P':
period = atoi(optarg);
break;
- case 'w':
- workaround = true;
- break;
case 'h':
default:
usage(NULL);