forked from Ivasoft/DSView
The device can only be accessed by one process
This commit is contained in:
@@ -1837,20 +1837,20 @@ namespace pv
|
||||
|
||||
case DSV_MSG_NEW_USB_DEVICE:
|
||||
{
|
||||
_sampling_bar->update_device_list();
|
||||
|
||||
if (_session->get_device()->is_demo() == false)
|
||||
{
|
||||
QString msgText = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TO_SWITCH_DEVICE), "To switch the new device?");
|
||||
|
||||
if (MsgBox::Confirm(msgText) == false){
|
||||
_sampling_bar->update_device_list(); // Update the list only.
|
||||
if (MsgBox::Confirm(msgText) == false){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The store confirm is not processed.
|
||||
if (_is_save_confirm_msg){
|
||||
_is_auto_switch_device = true;
|
||||
_sampling_bar->update_device_list();
|
||||
_is_auto_switch_device = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,8 @@ namespace pv
|
||||
|
||||
_device_status = ST_INIT;
|
||||
|
||||
ds_device_handle old_dev = _device_agent.handle();
|
||||
|
||||
if (ds_active_device(dev_handle) != SR_OK)
|
||||
{
|
||||
dsv_err("%s", "Switch device error!");
|
||||
@@ -258,6 +260,12 @@ namespace pv
|
||||
delay_prop_msg(strMsg);
|
||||
}
|
||||
|
||||
if (_device_agent.handle() != dev_handle && old_dev != NULL_HANDLE)
|
||||
{
|
||||
QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_BUSY_SWITCH_FAILED), "Device is busy!");
|
||||
MsgBox::Show("",strMsg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -366,5 +366,9 @@
|
||||
{
|
||||
"id": "IDS_MSG_TO_RECONNECT_FOR_FIRMWARE",
|
||||
"text": "固件版本不对,请重新连接设备!"
|
||||
},
|
||||
{
|
||||
"id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED",
|
||||
"text": "设置在使用中,切换失败!"
|
||||
}
|
||||
]
|
||||
@@ -367,5 +367,9 @@
|
||||
{
|
||||
"id": "IDS_MSG_TO_RECONNECT_FOR_FIRMWARE",
|
||||
"text": "The firmware version is incorrect, please reconnect the device!"
|
||||
},
|
||||
{
|
||||
"id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED",
|
||||
"text": "The device is busy,switch failed!"
|
||||
}
|
||||
]
|
||||
@@ -1826,7 +1826,8 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
|
||||
assert(usb->devhdl);
|
||||
|
||||
ret = libusb_claim_interface(usb->devhdl, USB_INTERFACE);
|
||||
if (ret != 0) {
|
||||
|
||||
if (ret != LIBUSB_SUCCESS) {
|
||||
switch(ret) {
|
||||
case LIBUSB_ERROR_BUSY:
|
||||
sr_err("%s: Unable to claim USB interface. Another "
|
||||
@@ -1848,12 +1849,13 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret != 0 && fdError == 1){
|
||||
if (ret != LIBUSB_SUCCESS && fdError == 1){
|
||||
sr_err("%s: Unable to claim interface, the second time: %s.",
|
||||
__func__, libusb_error_name(ret));
|
||||
}
|
||||
|
||||
if (ret != 0){
|
||||
if (ret != LIBUSB_SUCCESS){
|
||||
dsl_dev_close(sdi);
|
||||
return SR_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,12 +341,15 @@ SR_API int ds_active_device(ds_device_handle handle)
|
||||
struct sr_dev_inst *dev;
|
||||
int bFind = 0;
|
||||
int ret;
|
||||
struct sr_dev_inst *old_dev;
|
||||
|
||||
if (handle == NULL_HANDLE)
|
||||
{
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
ret = SR_OK;
|
||||
old_dev = NULL;
|
||||
|
||||
sr_info("%s", "Start activating device.");
|
||||
|
||||
@@ -371,6 +374,7 @@ SR_API int ds_active_device(ds_device_handle handle)
|
||||
{
|
||||
sr_info("Close the previous device \"%s\"", lib_ctx.actived_device_instance->name);
|
||||
close_device_instance(lib_ctx.actived_device_instance);
|
||||
old_dev = lib_ctx.actived_device_instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,14 +395,25 @@ SR_API int ds_active_device(ds_device_handle handle)
|
||||
else
|
||||
sr_info("device name: \"%s\".", dev->name);
|
||||
|
||||
if (open_device_instance(dev) == SR_OK)
|
||||
ret = open_device_instance(dev);
|
||||
|
||||
if (ret == SR_OK)
|
||||
{
|
||||
lib_ctx.actived_device_instance = dev;
|
||||
}
|
||||
else
|
||||
{
|
||||
sr_err("%s", "Open device error!");
|
||||
ret = SR_ERR_CALL_STATUS;
|
||||
{
|
||||
if (old_dev != NULL && old_dev != dev){
|
||||
sr_err("%s", "Open device error! the current device switch failed.");
|
||||
lib_ctx.actived_device_instance = old_dev;
|
||||
ret = open_device_instance(old_dev);
|
||||
}
|
||||
else if(lib_ctx.device_list != NULL){
|
||||
old_dev = lib_ctx.device_list->data;
|
||||
sr_err("%s", "Open device error! the current device switch to demo.");
|
||||
lib_ctx.actived_device_instance = old_dev;
|
||||
ret = open_device_instance(old_dev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1493,8 +1508,7 @@ static int open_device_instance(struct sr_dev_inst *dev)
|
||||
|
||||
if (driver_ins->dev_open)
|
||||
{
|
||||
driver_ins->dev_open(dev);
|
||||
return SR_OK;
|
||||
return driver_ins->dev_open(dev);
|
||||
}
|
||||
|
||||
return SR_ERR_CALL_STATUS;
|
||||
|
||||
Reference in New Issue
Block a user