]> sigrok.org Git - libsigrok.git/blobdiff - src/dmm/bm86x.c
input/wav: undo "create channels once" workaround
[libsigrok.git] / src / dmm / bm86x.c
index 1cc447e1b7042bda92c095a9e35c536933753ee8..ea260d8f97180869cfa6441696be549a476323da 100644 (file)
@@ -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;
@@ -60,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;
 }