brymen-dmm: unbreak temperature response parsing

The BM850s temperature function response includes the C/F unit in an
unexpected position ("0.0272CE+3") which breaks number conversion. Drop
the C/F unit to unbreak the conversion.

This was observed with BM859s. Absence of the C/F unit in the response
is fatal in this implementation. If other meter firmware versions or
models don't suffer from that issue, the removal must be silent and
non-fatal.
This commit is contained in:
Gerhard Sittig 2020-09-21 20:32:21 +02:00
parent 66b349841a
commit 3f8453b274
1 changed files with 13 additions and 0 deletions

View File

@ -223,6 +223,7 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
uint8_t *bfunc;
const char *txt;
int txtlen;
char *unit;
int ret;
(void)info;
@ -236,6 +237,18 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval,
memset(&flags, 0, sizeof(flags));
parse_flags(bfunc, &flags);
if (flags.is_fahrenheit || flags.is_celsius) {
/*
* The value text in temperature mode includes the C/F
* suffix between the mantissa and the exponent, which
* breaks the text to number conversion. Example data:
* " 0.0217CE+3". Remove the C/F unit identifier.
*/
unit = strchr(txt, flags.is_fahrenheit ? 'F' : 'C');
if (!unit)
return SR_ERR;
*unit = ' ';
}
ret = parse_value(txt, txtlen, floatval);
sr_dbg("floatval: %f, ret %d", *floatval, ret);
if (ret != SR_OK)