forked from Ivasoft/DSView
When switch device failed, prop the right information
This commit is contained in:
@@ -218,10 +218,8 @@ namespace pv
|
||||
ds_device_handle old_dev = _device_agent.handle();
|
||||
|
||||
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGE_PREV);
|
||||
|
||||
// Release the old device.
|
||||
_device_agent.release();
|
||||
|
||||
_device_status = ST_INIT;
|
||||
|
||||
if (ds_active_device(dev_handle) != SR_OK)
|
||||
@@ -231,7 +229,6 @@ namespace pv
|
||||
}
|
||||
|
||||
_device_agent.update();
|
||||
|
||||
set_collect_mode(COLLECT_SINGLE);
|
||||
|
||||
if (_device_agent.is_file()){
|
||||
@@ -255,16 +252,31 @@ namespace pv
|
||||
// The current device changed.
|
||||
_callback->trigger_message(DSV_MSG_CURRENT_DEVICE_CHANGED);
|
||||
|
||||
if (_device_agent.is_hardware() && _device_agent.check_firmware_version() == false)
|
||||
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!");
|
||||
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;
|
||||
}
|
||||
|
||||
if (_device_agent.handle() != dev_handle && old_dev != NULL_HANDLE)
|
||||
if (ds_get_last_error() == SR_ERR_FIRMWARE_NOT_EXIST)
|
||||
{
|
||||
QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_BUSY_SWITCH_FAILED), "Device is busy!");
|
||||
MsgBox::Show(strMsg);
|
||||
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_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);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -369,5 +369,9 @@
|
||||
{
|
||||
"id": "IDS_MSG_DEVICE_SPEED_TOO_LOW",
|
||||
"text": "错误: 当前连接的USB端口速率过低(<480Mbps)!"
|
||||
},
|
||||
{
|
||||
"id": "IDS_MSG_FIRMWARE_NOT_EXIST",
|
||||
"text": "错误: 固件文件不存在!"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -370,5 +370,9 @@
|
||||
{
|
||||
"id": "IDS_MSG_DEVICE_SPEED_TOO_LOW",
|
||||
"text": "Error: USB port speed is too low (<480Mbps)!"
|
||||
},
|
||||
{
|
||||
"id": "IDS_MSG_FIRMWARE_NOT_EXIST",
|
||||
"text": "Error: Firmware file is not exist!"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -81,7 +81,7 @@ SR_API const char *sr_error_str(int error_code)
|
||||
case SR_ERR_NA:
|
||||
str = "not applicable";
|
||||
break;
|
||||
case SR_ERR_DEV_CLOSED:
|
||||
case SR_ERR_DEVICE_CLOSED:
|
||||
str = "device closed but should be open";
|
||||
break;
|
||||
case SR_ERR_CALL_STATUS:
|
||||
@@ -147,8 +147,8 @@ SR_API const char *sr_error_name(int error_code)
|
||||
case SR_ERR_NA:
|
||||
str = "SR_ERR_NA";
|
||||
break;
|
||||
case SR_ERR_DEV_CLOSED:
|
||||
str = "SR_ERR_DEV_CLOSED";
|
||||
case SR_ERR_DEVICE_CLOSED:
|
||||
str = "SR_ERR_DEVICE_CLOSED";
|
||||
break;
|
||||
case SR_ERR_CALL_STATUS:
|
||||
str = "SR_ERR_CALL_STATUS";
|
||||
|
||||
@@ -1975,8 +1975,10 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
|
||||
struct ctl_wr_cmd wr_cmd;
|
||||
GSList *l;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
return SR_ERR_DEV_CLOSED;
|
||||
if (sdi->status != SR_ST_ACTIVE){
|
||||
ds_set_last_error(SR_ERR_DEVICE_CLOSED);
|
||||
return SR_ERR_DEVICE_CLOSED;
|
||||
}
|
||||
|
||||
drvc = di->priv;
|
||||
devc = sdi->priv;
|
||||
|
||||
@@ -362,6 +362,7 @@ static int hw_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi)
|
||||
sr_err("Expected firmware version %d.%d, "
|
||||
"got %d.%d.", DSL_REQUIRED_VERSION_MAJOR, DSL_REQUIRED_VERSION_MINOR,
|
||||
vi.major, vi.minor);
|
||||
ds_set_last_error(SR_ERR_DEVICE_FIRMWARE_VERSION_LOW);
|
||||
sdi->status = SR_ST_INCOMPATIBLE;
|
||||
}
|
||||
else {
|
||||
@@ -1300,6 +1301,7 @@ SR_PRIV int dsl_fpga_config(struct libusb_device_handle *hdl, const char *filena
|
||||
if ((fw = fopen(filename, "rb")) == NULL) {
|
||||
sr_err("Unable to open FPGA bit file %s for reading: %s",
|
||||
filename, strerror(errno));
|
||||
ds_set_last_error(SR_ERR_FIRMWARE_NOT_EXIST);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
@@ -1866,6 +1868,7 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
|
||||
|
||||
if (ret != LIBUSB_SUCCESS){
|
||||
dsl_dev_close(sdi);
|
||||
ds_set_last_error(SR_ERR_DEVICE_IS_EXCLUSIVE);
|
||||
return SR_ERR;
|
||||
}
|
||||
}
|
||||
@@ -1914,6 +1917,7 @@ SR_PRIV int dsl_dev_open(struct sr_dev_driver *di, struct sr_dev_inst *sdi, gboo
|
||||
ret = dsl_hdl_version(sdi, &hw_info);
|
||||
if ((ret != SR_OK) || (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;
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
@@ -1415,8 +1415,10 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data)
|
||||
int ret;
|
||||
struct ctl_wr_cmd wr_cmd;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
return SR_ERR_DEV_CLOSED;
|
||||
if (sdi->status != SR_ST_ACTIVE){
|
||||
ds_set_last_error(SR_ERR_DEVICE_CLOSED);
|
||||
return SR_ERR_DEVICE_CLOSED;
|
||||
}
|
||||
|
||||
drvc = di->priv;
|
||||
devc = sdi->priv;
|
||||
|
||||
@@ -60,6 +60,7 @@ SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
|
||||
if ((fw = fopen(filename, "rb")) == NULL) {
|
||||
sr_err("Unable to open firmware file %s for reading: %s",
|
||||
filename, strerror(errno));
|
||||
ds_set_last_error(SR_ERR_FIRMWARE_NOT_EXIST);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ struct sr_lib_context
|
||||
int is_stop_by_detached;
|
||||
int transaction_id;
|
||||
int transaction_command;
|
||||
int last_error;
|
||||
};
|
||||
|
||||
static void hotplug_event_listen_callback(struct libusb_context *ctx, struct libusb_device *dev, int event);
|
||||
@@ -104,6 +105,7 @@ static struct sr_lib_context lib_ctx = {
|
||||
.is_stop_by_detached = 0,
|
||||
.transaction_id = 0,
|
||||
.transaction_command = DEV_TRANS_NONE,
|
||||
.last_error = SR_OK,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -347,6 +349,8 @@ SR_API int ds_active_device(ds_device_handle handle)
|
||||
int ret;
|
||||
struct sr_dev_inst *old_dev;
|
||||
|
||||
lib_ctx.last_error = SR_OK;
|
||||
|
||||
if (handle == NULL_HANDLE)
|
||||
{
|
||||
return SR_ERR_ARG;
|
||||
@@ -408,6 +412,7 @@ SR_API int ds_active_device(ds_device_handle handle)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Failed to switch new device.
|
||||
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;
|
||||
@@ -706,6 +711,8 @@ SR_API int ds_start_collect()
|
||||
struct sr_dev_inst *di;
|
||||
di = lib_ctx.actived_device_instance;
|
||||
|
||||
lib_ctx.last_error = SR_OK;
|
||||
|
||||
sr_info("%s", "Start collect.");
|
||||
|
||||
if (ds_is_collecting())
|
||||
@@ -1650,3 +1657,13 @@ SR_PRIV int post_message_callback(int msg)
|
||||
}
|
||||
|
||||
/**-------------------private function end---------------*/
|
||||
|
||||
SR_PRIV void ds_set_last_error(int error)
|
||||
{
|
||||
lib_ctx.last_error = error;
|
||||
}
|
||||
|
||||
SR_API int ds_get_last_error()
|
||||
{
|
||||
return lib_ctx.last_error;
|
||||
}
|
||||
|
||||
@@ -407,6 +407,8 @@ SR_PRIV int sr_new_virtual_device(const char *filename, struct sr_dev_inst **out
|
||||
*/
|
||||
SR_PRIV int sr_usb_device_is_exists(libusb_device *usb_dev);
|
||||
|
||||
SR_PRIV void ds_set_last_error(int error);
|
||||
|
||||
/**
|
||||
* Forward the data.
|
||||
*/
|
||||
|
||||
@@ -74,9 +74,12 @@ enum {
|
||||
SR_ERR_BUG = 4, /**< Errors hinting at internal bugs. */
|
||||
SR_ERR_SAMPLERATE = 5, /**< Incorrect samplerate. */
|
||||
SR_ERR_NA = 6, /**< Not applicable. */
|
||||
SR_ERR_DEV_CLOSED = 7, /**< Device is closed, but needs to be open. */
|
||||
SR_ERR_CALL_STATUS = 8, /**< Function call status error. */
|
||||
SR_ERR_HAVE_DONE = 9, /**< The Function have called.*/
|
||||
SR_ERR_DEVICE_CLOSED = 7, /**< Device is closed, but needs to be open. */
|
||||
SR_ERR_CALL_STATUS = 8, /**< Function call status error. */
|
||||
SR_ERR_HAVE_DONE = 9, /**< The Function have called.*/
|
||||
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.*/
|
||||
|
||||
/*
|
||||
* Note: When adding entries here, don't forget to also update the
|
||||
@@ -1470,6 +1473,8 @@ SR_API int ds_is_collecting();
|
||||
*/
|
||||
SR_API int ds_release_actived_device();
|
||||
|
||||
SR_API int ds_get_last_error();
|
||||
|
||||
/*---config -----------------------------------------------*/
|
||||
SR_API int ds_get_actived_device_config(const struct sr_channel *ch,
|
||||
const struct sr_channel_group *cg,
|
||||
|
||||
Reference in New Issue
Block a user