]> sigrok.org Git - libsigrok.git/commitdiff
saleae-logic16: Don't send more samples than requested.
authorMarcus Comstedt <redacted>
Fri, 25 Apr 2014 19:07:16 +0000 (21:07 +0200)
committerUwe Hermann <redacted>
Sat, 3 May 2014 19:25:57 +0000 (21:25 +0200)
This fixes bug #350.

hardware/saleae-logic16/protocol.c

index c7ff20c4379d12db148be9fdb9d2dbe587aa0d40..61700455cf4ffe02293228c34aaaf93a266ce673 100644 (file)
@@ -736,6 +736,14 @@ SR_PRIV void logic16_receive_transfer(struct libusb_transfer *transfer)
                                transfer->actual_length);
 
        if (converted_length > 0) {
+               /* Cap sample count if needed */
+               if (devc->limit_samples &&
+                   (uint64_t)devc->num_samples + converted_length / 2
+                   > devc->limit_samples) {
+                       converted_length =
+                         (devc->limit_samples - devc->num_samples) * 2;
+               }
+
                /* Send the incoming transfer to the session bus. */
                packet.type = SR_DF_LOGIC;
                packet.payload = &logic;
@@ -746,7 +754,7 @@ SR_PRIV void logic16_receive_transfer(struct libusb_transfer *transfer)
 
                devc->num_samples += converted_length / 2;
                if (devc->limit_samples &&
-                   (uint64_t)devc->num_samples > devc->limit_samples) {
+                   (uint64_t)devc->num_samples >= devc->limit_samples) {
                        devc->num_samples = -2;
                        free_transfer(transfer);
                        return;