X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdmm%2Fbm86x.c;h=b38c3123d3d55a616c21616ddc2e72443523f1fa;hb=ed787682255cdecbb3ba8cefc87c20182b97ce7b;hp=318d4af011c9af61d56e5253fb6e3f13259cf824;hpb=0759e2f55b5e45ff283f396c38c08eb180ba83b7;p=libsigrok.git diff --git a/src/dmm/bm86x.c b/src/dmm/bm86x.c index 318d4af0..b38c3123 100644 --- a/src/dmm/bm86x.c +++ b/src/dmm/bm86x.c @@ -41,7 +41,6 @@ SR_PRIV int sr_brymen_bm86x_packet_request(struct sr_serial_dev_inst *serial) { static const uint8_t request[] = { 0x00, 0x00, 0x86, 0x66, }; - sr_spew("%s() sending request", __func__); serial_write_nonblocking(serial, request, sizeof(request)); return SR_OK; @@ -50,14 +49,6 @@ SR_PRIV int sr_brymen_bm86x_packet_request(struct sr_serial_dev_inst *serial) SR_PRIV gboolean sr_brymen_bm86x_packet_valid(const uint8_t *buf) { - GString *text; - - if (sr_log_loglevel_get() >= SR_LOG_SPEW) { - text = sr_hexdump_new(buf, BRYMEN_BM86X_PACKET_SIZE); - sr_spew("%s() checking DMM packet: %s", __func__, text->str); - sr_hexdump_free(text); - } - /* * "Model ID3" (3rd HID report, byte 3) is the only documented * fixed value, and must be 0x86. All other positions either depend @@ -172,6 +163,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 @@ -220,7 +212,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; @@ -286,9 +278,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) { @@ -303,7 +300,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;