X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdmm%2Fbm86x.c;h=c160a88c033fc452b0e740a94d196700ba81818d;hb=HEAD;hp=1cc447e1b7042bda92c095a9e35c536933753ee8;hpb=e378e3a2d4d2b24464ab01d19000c8a39dfc29b8;p=libsigrok.git diff --git a/src/dmm/bm86x.c b/src/dmm/bm86x.c index 1cc447e1..c160a88c 100644 --- a/src/dmm/bm86x.c +++ b/src/dmm/bm86x.c @@ -23,9 +23,10 @@ * * Brymen BM86x serial protocol parser. The USB protocol (for the cable) * and the packet description (for the meter) were retrieved from: - * http://brymen.com/product-html/Download2.html - * http://brymen.com/product-html/PD02BM860s_protocolDL.html - * http://brymen.com/product-html/images/DownloadList/ProtocolList/BM860-BM860s_List/BM860-BM860s-500000-count-dual-display-DMMs-protocol.pdf + * http://www.brymen.com/Download2.html + * http://www.brymen.com/PD02BM860s_protocolDL.html + * http://www.brymen.com/images/DownloadList/ProtocolList/BM860-BM860s_List/BM860-BM860s-500000-count-dual-display-DMMs-protocol.pdf + * http://web.archive.org/web/20191231053213/http://www.brymen.com/images/DownloadList/ProtocolList/BM860-BM860s_List/BM860-BM860s-500000-count-dual-display-DMMs-protocol.pdf */ #include @@ -41,7 +42,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; @@ -60,6 +60,22 @@ SR_PRIV gboolean sr_brymen_bm86x_packet_valid(const uint8_t *buf) if (buf[19] != 0x86) return FALSE; + /* + * 2021-05 update: The devices that we have seen in the field do + * provide four bytes which we can synchronize to. Which happens + * to match the bm52x and bm82x devices' protocol. This condition + * is not documented by the vendor, but improves reliability of + * the re-synchronization for slight offsets, which were seen + * in the field, and which would have kept failing in an earlier + * implementation. + */ + if (buf[16] != 0x86) + return FALSE; + if (buf[17] != 0x86) + return FALSE; + if (buf[18] != 0x86) + return FALSE; + return TRUE; } @@ -287,6 +303,8 @@ static void brymen_bm86x_parse(const uint8_t *buf, float *floatval, NULL, &temp_unit, NULL, 0x80); ret = brymen_bm86x_parse_digits(&buf[9], 4, txtbuf, floatval, NULL, &digits, 0x10); + if (ret != SR_OK) + return; /* SI unit. */ if (buf[14] & 0x08) {