**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "configfile.h"
{
unsigned char receive_buffer[300];
unsigned char package_buffer[300];
- char pkt_request[1] = {0xAA};
+ unsigned char pkt_request[1] = {0xAA};
int package_buffer_pos;
fd_set input;
- struct timeval timeout;
+
+ /* Initialize timeout structure, set to 2 seconds */
+ struct timeval timeout = {
+ .tv_sec = 2
+ };
int end_flag;
int escape_flag;
FD_ZERO (&input);
FD_SET (fd, &input);
- /* Initialize timeout structure, set to 2 seconds */
- memset (&timeout, 0, sizeof (timeout));
- timeout.tv_sec = 2;
- timeout.tv_usec = 0;
-
/* clear out anything in the buffer */
tcflush (fd, TCIFLUSH);
while (end_flag == 0)
{
ssize_t receive_buffer_length;
- ssize_t i;
/* check for timeout or input error*/
status = select (fd + 1, &input, NULL, NULL, &timeout);
* the beginning of the package has been found. */
escape_flag = 0;
- for (i = 0; i < receive_buffer_length; i++)
+ for (ssize_t i = 0; i < receive_buffer_length; i++)
{
/* Check if previous byte was the escape byte. */
if (escape_flag == 1)
return (0);
} /* int ted_open_device */
-static void ted_submit (char *type, double value)
+static void ted_submit (const char *type, double value)
{
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
double power;
double voltage;
int status;
- int i;
status = ted_open_device ();
if (status != 0)
power = NAN;
voltage = NAN;
- for (i = 0; i <= conf_retries; i++)
+ for (int i = 0; i <= conf_retries; i++)
{
status = ted_read_value (&power, &voltage);
if (status == 0)