X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fdmm%2Fbm86x.c;h=442e5cca038e2238dfc7c9f1ba41a943a5679856;hb=d32120c4c30650c30720d04eaf88dcf7b76a1e9f;hp=b38c3123d3d55a616c21616ddc2e72443523f1fa;hpb=0fb45121254b159e1dabf8fd3f3bbd84e4aa693d;p=libsigrok.git diff --git a/src/dmm/bm86x.c b/src/dmm/bm86x.c index b38c3123..442e5cca 100644 --- a/src/dmm/bm86x.c +++ b/src/dmm/bm86x.c @@ -59,6 +59,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; } @@ -286,6 +302,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) {