Cath the error about driver have not installed

This commit is contained in:
dreamsourcelabTAI 2024-06-24 18:12:07 +08:00
parent d17440a862
commit 7b0d79d6c4
5 changed files with 57 additions and 33 deletions

View File

@ -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)

View File

@ -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": "未启用通道!"

View File

@ -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!"

View File

@ -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);

View File

@ -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