diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 210129f6..437526a4 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -1952,7 +1952,11 @@ namespace pv case DS_EV_INACTIVE_DEVICE_DETACH: _callback->trigger_message(DSV_MSG_DEVICE_LIST_UPDATED); // Update list only. - break; + break; + + case DS_EV_DEVICE_SPEED_NOT_MATCH: + _callback->trigger_message(DS_EV_DEVICE_SPEED_NOT_MATCH); + break; default: dsv_err("%s", "Error!Unknown device event."); @@ -2112,6 +2116,13 @@ namespace pv case DSV_MSG_COLLECT_END: break; + + case DS_EV_DEVICE_SPEED_NOT_MATCH: + { + QString strMsg(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_DEVICE_SPEED_TOO_LOW), "Speed too low!")); + _callback->delay_prop_msg(strMsg); + } + break; } } diff --git a/lang/cn/msg.json b/lang/cn/msg.json index a53b5cb5..e07dfd52 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -365,5 +365,9 @@ { "id": "IDS_MSG_TO_CLEAR_LOG", "text": "您确定要清除日志文件?" + }, + { + "id": "IDS_MSG_DEVICE_SPEED_TOO_LOW", + "text": "错误, 设备连接的USB端口速度太低!" } ] \ No newline at end of file diff --git a/lang/en/msg.json b/lang/en/msg.json index be122302..c5645446 100644 --- a/lang/en/msg.json +++ b/lang/en/msg.json @@ -366,5 +366,9 @@ { "id": "IDS_MSG_TO_CLEAR_LOG", "text": "Are you sure to clear log file?" + }, + { + "id": "IDS_MSG_DEVICE_SPEED_TOO_LOW", + "text": "Error, The speed of the USB port that \nthe device connected is too low!" } ] \ No newline at end of file diff --git a/libsigrok4DSL/hardware/DSL/dscope.c b/libsigrok4DSL/hardware/DSL/dscope.c index fb6a147e..7a55e0db 100644 --- a/libsigrok4DSL/hardware/DSL/dscope.c +++ b/libsigrok4DSL/hardware/DSL/dscope.c @@ -197,9 +197,11 @@ static GSList *scan(GSList *options) uint8_t address; int isProduct; int num; + int is_speed_not_match; drvc = di->priv; num = 0; + is_speed_not_match = 0; if (options != NULL) sr_info("%s", "Scan DSCope device with options."); @@ -264,16 +266,19 @@ static GSList *scan(GSList *options) usb_speed = libusb_get_device_speed(device_handle); if ((usb_speed != LIBUSB_SPEED_HIGH) && (usb_speed != LIBUSB_SPEED_SUPER)){ sr_info("scan(): The idVendor is right, but the usb speed is too low, speed type:%d", usb_speed); + is_speed_not_match = 1; continue; } prof = NULL; - for (j = 0; supported_DSCope[j].vid; j++) { + for (j = 0; supported_DSCope[j].vid; j++) + { if (des.idVendor == supported_DSCope[j].vid && - des.idProduct == supported_DSCope[j].pid && - usb_speed == supported_DSCope[j].usb_speed) { - prof = &supported_DSCope[j]; - break; + des.idProduct == supported_DSCope[j].pid){ + if (usb_speed == supported_DSCope[j].usb_speed) { + prof = &supported_DSCope[j]; + break; + } } } @@ -380,6 +385,10 @@ static GSList *scan(GSList *options) sr_info("Fond new DSCope device count: %d", num); + if (is_speed_not_match){ + post_message_callback(DS_EV_DEVICE_SPEED_NOT_MATCH); + } + return devices; } diff --git a/libsigrok4DSL/hardware/DSL/dslogic.c b/libsigrok4DSL/hardware/DSL/dslogic.c index 9222d75e..e5d2b33c 100644 --- a/libsigrok4DSL/hardware/DSL/dslogic.c +++ b/libsigrok4DSL/hardware/DSL/dslogic.c @@ -283,9 +283,11 @@ static GSList *scan(GSList *options) uint8_t address; int isProduct; int num; + int is_speed_not_match; drvc = di->priv; num = 0; + is_speed_not_match = 0; if (options != NULL) sr_info("%s", "Scan DSLogic device with options."); @@ -351,17 +353,20 @@ static GSList *scan(GSList *options) usb_speed = libusb_get_device_speed(device_handle); if ((usb_speed != LIBUSB_SPEED_HIGH) && (usb_speed != LIBUSB_SPEED_SUPER)){ sr_info("scan(): The idVendor is right, but the usb speed is too low, speed type:%d", usb_speed); + is_speed_not_match = 1; continue; } /* Check manufactory id and product id, and speed type. */ prof = NULL; - for (j = 0; supported_DSLogic[j].vid; j++) { + for (j = 0; supported_DSLogic[j].vid; j++) + { if (des.idVendor == supported_DSLogic[j].vid && - des.idProduct == supported_DSLogic[j].pid && - usb_speed == supported_DSLogic[j].usb_speed) { - prof = &supported_DSLogic[j]; - break; + des.idProduct == supported_DSLogic[j].pid){ + if (usb_speed == supported_DSLogic[j].usb_speed) { + prof = &supported_DSLogic[j]; + break; + } } } @@ -466,6 +471,10 @@ static GSList *scan(GSList *options) sr_info("Fond new DSLogic device count: %d", num); + if (is_speed_not_match){ + post_message_callback(DS_EV_DEVICE_SPEED_NOT_MATCH); + } + return devices; } diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c index cfc8e003..0adfd431 100644 --- a/libsigrok4DSL/lib_main.c +++ b/libsigrok4DSL/lib_main.c @@ -1636,4 +1636,10 @@ static struct libusb_device* get_new_detached_usb_device() return dev; } +SR_PRIV int post_message_callback(int msg) +{ + send_event(msg); + return SR_OK; +} + /**-------------------private function end---------------*/ diff --git a/libsigrok4DSL/libsigrok-internal.h b/libsigrok4DSL/libsigrok-internal.h index 3291b197..08fdad16 100644 --- a/libsigrok4DSL/libsigrok-internal.h +++ b/libsigrok4DSL/libsigrok-internal.h @@ -415,6 +415,8 @@ SR_PRIV int current_device_acquisition_stop(); SR_PRIV int lib_extern_init(struct sr_context *ctx); +SR_PRIV int post_message_callback(int msg); + /*--- hwdriver.c ------------------------------------------------------------*/ SR_PRIV int sr_config_get(const struct sr_dev_driver *driver, diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 6aa8e241..d9427916 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -1304,6 +1304,8 @@ SR_API void ds_log_level(int level); #define DS_EV_COLLECT_TASK_END_BY_ERROR 106 +#define DS_EV_DEVICE_SPEED_NOT_MATCH 107 + enum DS_DEVICE_EVENT_TYPE { DS_EV_NEW_DEVICE_ATTACH = 1,