#include "common.h"
#include "plugin.h"
-#if HAVE_TERMIOS_H && HAVE_SYS_IOCTL_H && HAVE_MATH_H
-#include <math.h>
+#if HAVE_TERMIOS_H && HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#include <termios.h>
#else
tcflush(fd, TCIFLUSH);
if (gettimeofday(&time_end, NULL) < 0) {
- char errbuf[1024];
- ERROR("multimeter plugin: gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ ERROR("multimeter plugin: gettimeofday failed: %s", STRERRNO);
+ return -1;
}
time_end.tv_sec++;
struct timeval time_now;
status = swrite(fd, "D", 1);
- if (status < 0) {
+ if (status != 0) {
ERROR("multimeter plugin: swrite failed.");
- return (-1);
+ return -1;
}
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
if (gettimeofday(&time_now, NULL) < 0) {
- char errbuf[1024];
ERROR("multimeter plugin: "
"gettimeofday failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ STRERRNO);
+ return -1;
}
if (timeval_cmp(time_end, time_now, &timeout) < 0)
break;
break;
}
} else
- return (-1); /* Overflow */
+ return -1; /* Overflow */
- return (0); /* value received */
+ return 0; /* value received */
} else
break;
} else if (!status) /* Timeout */
continue;
} else /* status == -1 */
{
- char errbuf[1024];
ERROR("multimeter plugin: "
"select failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ STRERRNO);
break;
}
}
} while (--retry);
- return (-2); /* no value received */
+ return -2; /* no value received */
} /* int multimeter_read_value */
static int multimeter_init(void) {
INFO("multimeter plugin: Device "
"found at %s",
device);
- return (0);
+ return 0;
}
}
}
ERROR("multimeter plugin: No device found");
- return (-1);
+ return -1;
}
#undef LINE_LENGTH
double value;
if (fd < 0)
- return (-1);
+ return -1;
if (multimeter_read_value(&value) != 0)
- return (-1);
+ return -1;
multimeter_submit(value);
- return (0);
+ return 0;
} /* int multimeter_read */
static int multimeter_shutdown(void) {
fd = -1;
}
- return (0);
+ return 0;
}
void module_register(void) {