From 7307b16dee23408c90bf36a1149c494890035d56 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 19 Jun 2023 19:10:07 +0800 Subject: [PATCH] The error message for USB io error! --- DSView/pv/sigsession.cpp | 8 ++++++++ lang/cn/msg.json | 4 ++++ lang/en/msg.json | 4 ++++ libsigrok4DSL/hardware/DSL/dsl.c | 13 +++++++++++-- libsigrok4DSL/libsigrok.h | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 6fa66933..004ce0ae 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -268,6 +268,14 @@ namespace pv return false; } + if (ds_get_last_error() == SR_ERR_DEVICE_USB_IO_ERROR) + { + QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_USB_IO_ERROR), + "USB io error!"); + _callback->delay_prop_msg(strMsg); + return false; + } + if (ds_get_last_error() == SR_ERR_DEVICE_IS_EXCLUSIVE) { QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_BUSY_SWITCH_FAILED), diff --git a/lang/cn/msg.json b/lang/cn/msg.json index d97fe07d..b37d4382 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -373,5 +373,9 @@ { "id": "IDS_MSG_FIRMWARE_NOT_EXIST", "text": "错误: 固件文件不存在!" + }, + { + "id": "IDS_MSG_DEVICE_USB_IO_ERROR", + "text": "Error: USB读写错误!" } ] diff --git a/lang/en/msg.json b/lang/en/msg.json index f50fc3c0..373b4ff5 100644 --- a/lang/en/msg.json +++ b/lang/en/msg.json @@ -374,5 +374,9 @@ { "id": "IDS_MSG_FIRMWARE_NOT_EXIST", "text": "Error: Firmware file is not exist!" + }, + { + "id": "IDS_MSG_DEVICE_USB_IO_ERROR", + "text": "Error: USB IO error!" } ] diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index 384f1c56..686bf6cf 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -327,7 +327,8 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi) sr_info("Open usb device instance, handle: %p", dev_handel); - if (libusb_open(dev_handel, &usb->devhdl) != 0){ + ret = libusb_open(dev_handel, &usb->devhdl); + if (ret != LIBUSB_SUCCESS){ sr_err("Failed to open device: %s, handle:%p", libusb_error_name(ret), dev_handel); return SR_ERR; @@ -1915,7 +1916,15 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo ret = dsl_wr_reg(sdi, CTR0_ADDR, bmNONE); // dessert clear /* Check HDL version */ ret = dsl_hdl_version(sdi, &hw_info); - if ((ret != SR_OK) || (hw_info != DSL_HDL_VERSION)) { + + if ((ret != SR_OK)) { + sr_err("%s: Failed to get FPGA bin version!", __func__); + ds_set_last_error(SR_ERR_DEVICE_USB_IO_ERROR); + sdi->status = SR_ST_INACTIVE; + return SR_ERR; + } + + if (hw_info != DSL_HDL_VERSION) { sr_err("%s: HDL verison incompatible!", __func__); ds_set_last_error(SR_ERR_DEVICE_FIRMWARE_VERSION_LOW); sdi->status = SR_ST_INCOMPATIBLE; diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index e01e65da..837be677 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -80,6 +80,7 @@ enum { SR_ERR_FIRMWARE_NOT_EXIST = 10, /**< The firmware file is not exist.*/ SR_ERR_DEVICE_IS_EXCLUSIVE = 11, /**< The device is exclusive by other process.*/ SR_ERR_DEVICE_FIRMWARE_VERSION_LOW = 12, /**< The firmware version is too low.*/ + SR_ERR_DEVICE_USB_IO_ERROR = 13, /**< THe use io error.*/ /* * Note: When adding entries here, don't forget to also update the