diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 63931863..1031fa1a 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -257,42 +257,53 @@ namespace pv // The current device changed. _callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGED); - if (ds_get_last_error() == SR_ERR_DEVICE_FIRMWARE_VERSION_LOW) - { - QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TO_RECONNECT_FOR_FIRMWARE), - "Please reconnect the device!"); - _callback->delay_prop_msg(strMsg); - return false; - } + int lastError = ds_get_last_error(); + bool ret = true; - if (ds_get_last_error() == SR_ERR_FIRMWARE_NOT_EXIST) + switch (lastError) { - QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_FIRMWARE_NOT_EXIST), - "Firmware not exist!"); - _callback->delay_prop_msg(strMsg); - 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), - "Device is busy!"); - if (old_dev != NULL_HANDLE) - MsgBox::Show(strMsg); - else + case SR_ERR_DEVICE_FIRMWARE_VERSION_LOW:{ + QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TO_RECONNECT_FOR_FIRMWARE), + "Please reconnect the device!"); _callback->delay_prop_msg(strMsg); - return false; + ret = false; + break; + } + case SR_ERR_FIRMWARE_NOT_EXIST:{ + QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_FIRMWARE_NOT_EXIST), + "Firmware not exist!"); + _callback->delay_prop_msg(strMsg); + ret = false; + break; + } + case 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); + ret = false; + break; + } + case SR_ERR_DEVICE_IS_EXCLUSIVE:{ + QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_BUSY_SWITCH_FAILED), + "Device is busy!"); + if (old_dev != NULL_HANDLE) + MsgBox::Show(strMsg); + else + _callback->delay_prop_msg(strMsg); + ret = false; + break; + } + case SR_ERR_DEVICE_NO_DRIVER: + { + QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_NO_DRIVER), + "No driver!"); + _callback->delay_prop_msg(strMsg); + ret = false; + break; + } } - return true; + return ret; } bool SigSession::set_file(QString name) diff --git a/lang/cn/msg.json b/lang/cn/msg.json index 598f3b44..3ba7ab6a 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -354,6 +354,10 @@ "id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED", "text": "设备被其它程序占用,切换失败!" }, + { + "id": "IDS_MSG_DEVICE_NO_DRIVER", + "text": "设备的驱动可能未安装!" + }, { "id": "IDS_MSG_NO_ENABLED_CHANNEL", "text": "未启用通道!" diff --git a/lang/en/msg.json b/lang/en/msg.json index 83f92942..42610cc5 100644 --- a/lang/en/msg.json +++ b/lang/en/msg.json @@ -355,6 +355,10 @@ "id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED", "text": "The device is busy, switch failed!" }, + { + "id": "IDS_MSG_DEVICE_NO_DRIVER", + "text": "The device driver may not be installed!" + }, { "id": "IDS_MSG_NO_ENABLED_CHANNEL", "text": "No channels enabled!" diff --git a/libsigrok4DSL/hardware/DSL/dsl.c b/libsigrok4DSL/hardware/DSL/dsl.c index 38ffde67..319a5387 100644 --- a/libsigrok4DSL/hardware/DSL/dsl.c +++ b/libsigrok4DSL/hardware/DSL/dsl.c @@ -335,7 +335,11 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi) if (ret != LIBUSB_SUCCESS){ sr_err("%s:%d, Failed to open device: %s, handle:%p", __func__, __LINE__, libusb_error_name(ret), dev_handel); - ds_set_last_error(SR_ERR_DEVICE_IS_EXCLUSIVE); + + if (ret == LIBUSB_ERROR_NOT_SUPPORTED) + ds_set_last_error(SR_ERR_DEVICE_NO_DRIVER); + else + ds_set_last_error(SR_ERR_DEVICE_IS_EXCLUSIVE); return SR_ERR; } //sr_info("------------Open returns the libusb_device_handle: %p, struct:%p", usb->devhdl, usb); diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 4487aea2..7b3550ef 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -80,7 +80,8 @@ 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.*/ + SR_ERR_DEVICE_USB_IO_ERROR = 13, /**< The usb io error.*/ + SR_ERR_DEVICE_NO_DRIVER = 14, /**< The device have no driver.*/ /* * Note: When adding entries here, don't forget to also update the