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>
{
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 */
parse_opts(parser_data[i], ow_path, sizeof(ow_path), &offset);
while (1) {
- int fail, j;
+ int j;
char *tmp2;
tmp = NULL;
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.