From: Gerhard Sittig Date: Thu, 20 Jun 2019 09:53:36 +0000 (+0200) Subject: dmm/bm86x: unbreak temperature modes (two probes and no probes) X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e378e3a2d4d2b24464ab01d19000c8a39dfc29b8;p=libsigrok.git dmm/bm86x: unbreak temperature modes (two probes and no probes) The Brymen BM86x supports up to two temperature probes. The dual display can show individual temperatures of the two probes or differences. The previous implementation "detected" a value of zero degrees when no probe was attached and the display showed dash lines. When cycling assignments of probes to displays, some valid combinations did not result in values shown by the libsigrok driver. An implementation detail of the formerly separate brymen-bm86x driver was lost during recent migration of the dmm/bm86x parser into the serial-dmm driver. When the meter's temperature function is selected, it's essential to inspect the primary display's flags and digits, to determine the secondary display's quantity and unit. Previous versions never bothered to explicitly check for the "----" digits text, but the combination of the primary's last digit showing C/F as well as the binary C/F flags before the value provided hints which the secondary displays group of digits and flags did not. This fixes bug #1394. --- diff --git a/src/dmm/bm86x.c b/src/dmm/bm86x.c index 3cfe586d..1cc447e1 100644 --- a/src/dmm/bm86x.c +++ b/src/dmm/bm86x.c @@ -164,6 +164,7 @@ static void brymen_bm86x_parse(const uint8_t *buf, float *floatval, int ret, digits, is_diode, over_limit, scale; uint8_t ind1, ind15; + temp_unit = '\0'; if (ch_idx == 0) { /* * Main display. Note that _some_ of the second display's @@ -212,7 +213,7 @@ static void brymen_bm86x_parse(const uint8_t *buf, float *floatval, } else if (buf[15] & 0x80) { analog->meaning->mq = SR_MQ_DUTY_CYCLE; analog->meaning->unit = SR_UNIT_PERCENTAGE; - } else if (buf[ 2] & 0x0a) { + } else if ((buf[2] & 0x0a) && temp_unit) { analog->meaning->mq = SR_MQ_TEMPERATURE; if (temp_unit == 'F') analog->meaning->unit = SR_UNIT_FAHRENHEIT; @@ -278,9 +279,14 @@ static void brymen_bm86x_parse(const uint8_t *buf, float *floatval, analog->encoding->digits = digits; analog->spec->spec_digits = digits; } else if (ch_idx == 1) { - /* Secondary display. */ + /* + * Secondary display. Also inspect _some_ primary display + * data, to determine the secondary display's validity. + */ + (void)brymen_bm86x_parse_digits(&buf[2], 6, txtbuf, + NULL, &temp_unit, NULL, 0x80); ret = brymen_bm86x_parse_digits(&buf[9], 4, txtbuf, - floatval, &temp_unit, &digits, 0x10); + floatval, NULL, &digits, 0x10); /* SI unit. */ if (buf[14] & 0x08) { @@ -295,7 +301,7 @@ static void brymen_bm86x_parse(const uint8_t *buf, float *floatval, } else if (buf[14] & 0x04) { analog->meaning->mq = SR_MQ_FREQUENCY; analog->meaning->unit = SR_UNIT_HERTZ; - } else if (buf[9] & 0x40) { + } else if ((buf[9] & 0x40) && temp_unit) { analog->meaning->mq = SR_MQ_TEMPERATURE; if (temp_unit == 'F') analog->meaning->unit = SR_UNIT_FAHRENHEIT;