* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
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]");
+ puts("trinketd [-d] [-l logfile] [-p pidfile] [-P period] [-D datadir] [-w]");
if (errmsg) {
puts("");
}
while(42) {
+ if (workaround)
+ trinketPing();
+
if (trinketGetCumDose(&curDose) != ERR_OK) {
fprintf(stderr, "trinketGetCumDose fails\n");
trinketClose();
logfd;
opterr = 0;
- while((i=getopt(argn,argv,"dD:p:P:h")) != EOF) {
+ while((i=getopt(argn,argv,"dD:p:P:wh")) != EOF) {
switch(i) {
case 'd':
daemonize = true;
case 'P':
period = atoi(optarg);
break;
+ case 'w':
+ workaround = true;
+ break;
case 'h':
default:
usage(NULL);
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
TrinketErrorCode
trinketOpen() {
+ TrinketErrorCode r;
#ifndef NDEBUG
int i;
return ERR_ERROR;
}
- return trinketPing();
+ if ((r = trinketPing()) != ERR_OK)
+ trinketClose();
+ return r;
}
void
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE