metex14: Fix parsing of spaces.

When the parser found a space, it treated it as an invalid digit
and discarded the whole packet. This behavior was incorrect on
2000 count devices, where the first digit can be sent as a space
rather than a '0'.

Convert spaces to '0' and parse them as usual.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-11-30 12:29:22 -06:00 committed by Uwe Hermann
parent 21a7f2692e
commit 76b55dfa8a
1 changed files with 3 additions and 0 deletions

View File

@ -75,6 +75,9 @@ static int parse_value(const uint8_t *buf, float *result)
factor = 1000;
for (i = 0; i < 5; i++) {
digit = buf[4 + i];
/* Convert spaces to '0', so that we can parse them. */
if (digit == ' ')
digit = '0';
if (digit == '.') {
decimal_point = i;
} else if (isdigit(digit)) {