X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmultimeter.c;h=00e9964b85f82718d104c7d4bce8688c702ba6b2;hb=aa3811995bfae69f0d1a0f897acfa4a9a4c0138a;hp=775eb57e27bff64201f81e83cf6528c36fa0608e;hpb=37905c5a2370c8e6edae5011978773eeaa589d09;p=collectd.git diff --git a/src/multimeter.c b/src/multimeter.c index 775eb57e..00e9964b 100644 --- a/src/multimeter.c +++ b/src/multimeter.c @@ -153,17 +153,17 @@ static int multimeter_init (void) for (i = 0; i < 10; i++) { - device[strlen(device)-1] = i + '0'; + device[strlen(device)-1] = i + '0'; - if ((fd = open(device, O_RDWR | O_NOCTTY)) > 0) + if ((fd = open(device, O_RDWR | O_NOCTTY)) != -1) { - struct termios tios; + struct termios tios = { 0 }; int rts = TIOCM_RTS; double value; tios.c_cflag = B1200 | CS7 | CSTOPB | CREAD | CLOCAL; tios.c_iflag = IGNBRK | IGNPAR; - tios.c_oflag = 0; + tios.c_oflag = 0; tios.c_lflag = 0; tios.c_cc[VTIME] = 3; tios.c_cc[VMIN] = LINE_LENGTH; @@ -171,7 +171,7 @@ static int multimeter_init (void) tcflush(fd, TCIFLUSH); tcsetattr(fd, TCSANOW, &tios); ioctl(fd, TIOCMBIC, &rts); - + if (multimeter_read_value (&value) < -1) { close (fd);