X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fkingst-la2016%2Fprotocol.c;h=e59bae0aab48fbc15386f546fee3839d21a3ce53;hb=7a38cdf76678a64f6bfc9178e623f9f9cecfcd4b;hp=8f08337ad7fa570663d35485c63b23272c7d5350;hpb=0fbb464bdf0951228d4430794263bb48bc668821;p=libsigrok.git diff --git a/src/hardware/kingst-la2016/protocol.c b/src/hardware/kingst-la2016/protocol.c index 8f08337a..e59bae0a 100644 --- a/src/hardware/kingst-la2016/protocol.c +++ b/src/hardware/kingst-la2016/protocol.c @@ -915,15 +915,15 @@ static uint16_t run_state(const struct sr_dev_inst *sdi) return state; } -static int la2016_is_idle(const struct sr_dev_inst *sdi) +static gboolean la2016_is_idle(const struct sr_dev_inst *sdi) { uint16_t state; state = run_state(sdi); if ((state & runstate_mask_idle) == runstate_patt_idle) - return 1; + return TRUE; - return 0; + return FALSE; } static int set_run_mode(const struct sr_dev_inst *sdi, uint8_t mode) @@ -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