]> git.itanic.dy.fi Git - rrdd/commitdiff
onewire_parser: Fix "85" degree handling case
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 20 Aug 2019 18:38:02 +0000 (21:38 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Tue, 20 Aug 2019 18:38:02 +0000 (21:38 +0300)
The current method of comparing the beginning of the raw string to
"85" will discard all measurements, even valid ones that are different
than strictly "85". This includes values such as 85.5, which can be
100% correct.

This also fixes a small memory leak that took place when we actually
got "85" from the sensor. If that happens, it is a failure, but the
*_read() function still had allocated the string for us. So it must be
freed.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
onewire_parser.c

index 7d1e8a6e3d7eb3fbe6b91643c363a99e699524ef..e129e5c5e78efbcf47be588656d5abbc5af1c9bd 100644 (file)
@@ -50,6 +50,10 @@ static int might_be_glitch(double data, const struct owparser_state *s)
 {
        double max_delta, delta;
 
+       /* The known bad data value from the sensor */
+       if (data == 85)
+               return 1;
+
        max_delta = max_glitch_delta(s);
 
        /* Probably no enough data yet, so no glitch detection */
@@ -255,7 +259,7 @@ undefined:
                parse_opts(parser_data[i], ow_path, sizeof(ow_path), &offset);
 
                while (1) {
-                       int fail, j;
+                       int j;
                        char *tmp2;
 
                        tmp = NULL;
@@ -272,15 +276,9 @@ undefined:
                        for (j = 0; j < ret && *tmp2 == ' '; j++)
                                tmp2++;
 
-                       if (ret > 0)
-                               fail = !strncmp(tmp2, "85", 2);
-                       else
-                               fail = 1;
-
-                       if (ret <= 0 || fail)
+                       if (ret <= 0)
                                goto retry;
 
-
                        /*
                         * Older versions of OWNET_read did not NULL
                         * terminate data.