]> sigrok.org Git - libsigrok.git/commitdiff
kingst-la2016: stop acquisition when USB device was lost
authorGerhard Sittig <redacted>
Sun, 20 Feb 2022 10:36:43 +0000 (11:36 +0100)
committerGerhard Sittig <redacted>
Tue, 22 Feb 2022 20:53:20 +0000 (21:53 +0100)
Check for the condition when the USB device has gone away in the middle
of getting communicated to. Terminate acquisition in that case, instead
of trying to continue.

src/hardware/kingst-la2016/protocol.c

index 8f08337ad7fa570663d35485c63b23272c7d5350..596b085c49b4d04c6de45d19a320470ab335be40 100644 (file)
@@ -1515,15 +1515,22 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
-       gboolean was_cancelled;
+       gboolean was_cancelled, device_gone;
        int ret;
 
        sdi = transfer->user_data;
        devc = sdi->priv;
 
        was_cancelled = transfer->status == LIBUSB_TRANSFER_CANCELLED;
+       device_gone = transfer->status == LIBUSB_TRANSFER_NO_DEVICE;
        sr_dbg("receive_transfer(): status %s received %d bytes.",
                libusb_error_name(transfer->status), transfer->actual_length);
+       if (device_gone) {
+               sr_warn("Lost communication to USB device.");
+               devc->download_finished = TRUE;
+               return;
+       }
+
        /*
         * Implementation detail: A USB transfer timeout is not fatal
         * here. We just process whatever was received, empty input is