X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fted.c;h=28ee8e485ecfc3165f075a33f706bb5eb5b251a5;hb=4103105fb43cd72294f165b2541540b3a8a99532;hp=e76b3c9234f70878bf465ada946d6605642fdc86;hpb=1bcbb3d80ac6d79da697bba113d5864e721e35d7;p=collectd.git diff --git a/src/ted.c b/src/ted.c index e76b3c92..28ee8e48 100644 --- a/src/ted.c +++ b/src/ted.c @@ -35,6 +35,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "configfile.h" @@ -70,11 +71,15 @@ static int ted_read_value(double *ret_power, double *ret_voltage) { 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; @@ -87,11 +92,6 @@ static int ted_read_value(double *ret_power, double *ret_voltage) 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); @@ -263,7 +263,7 @@ static int ted_open_device (void) 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;