From e56ed03d29fc069954d04c5c6452e5a717243521 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Thu, 1 Jun 2023 09:43:04 +0800 Subject: [PATCH] Prompt for user if the device linked to a too low speed USB port --- DSView/pv/deviceagent.cpp | 23 ++++------------------- DSView/pv/deviceagent.h | 9 ++++----- libsigrok4DSL/dsdevice.c | 1 + libsigrok4DSL/lib_main.c | 3 +++ libsigrok4DSL/libsigrok-internal.h | 2 ++ libsigrok4DSL/libsigrok.h | 1 + 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/DSView/pv/deviceagent.cpp b/DSView/pv/deviceagent.cpp index 710f75b5..62ebf10e 100644 --- a/DSView/pv/deviceagent.cpp +++ b/DSView/pv/deviceagent.cpp @@ -40,6 +40,7 @@ void DeviceAgent::update() _path = ""; _di = NULL; _dev_type = 0; + _is_new_device = false; struct ds_device_full_info info; @@ -48,19 +49,14 @@ void DeviceAgent::update() _dev_handle = info.handle; _dev_type = info.dev_type; _di = info.di; + _is_new_device = info.actived_times == 1; + _dev_name = QString::fromLocal8Bit(info.name); _driver_name = QString::fromLocal8Bit(info.driver_name); if (info.path[0] != '\0'){ _path = QString::fromLocal8Bit(info.path); - } - - if (is_in_history(_dev_handle) == false){ - _is_new_device = true; - } - else{ - _is_new_device = false; - } + } } } @@ -288,17 +284,6 @@ GSList *DeviceAgent::get_channels() return ds_get_actived_device_channels(); } - bool DeviceAgent::is_in_history(ds_device_handle dev_handle) - { - for(ds_device_handle h : _history_handles){ - if (h == dev_handle){ - return true; - } - } - _history_handles.push_back(dev_handle); - return false; - } - int DeviceAgent::get_hardware_operation_mode() { assert(_dev_handle); diff --git a/DSView/pv/deviceagent.h b/DSView/pv/deviceagent.h index 5c8179c9..ae9132d1 100644 --- a/DSView/pv/deviceagent.h +++ b/DSView/pv/deviceagent.h @@ -175,8 +175,9 @@ public: bool check_firmware_version(); - QString get_demo_operation_mode(); + QString get_demo_operation_mode(); +public: GVariant* get_config_list(const sr_channel_group *group, int key); GVariant* get_config(int key, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL); @@ -211,8 +212,7 @@ public: bool set_config_double(int key, double value, const sr_channel *ch = NULL, const sr_channel_group *cg = NULL); private: - void config_changed(); - bool is_in_history(ds_device_handle dev_handle); + void config_changed(); //---------------device config-----------/ public: @@ -233,8 +233,7 @@ private: QString _driver_name; QString _path; bool _is_new_device; - struct sr_dev_inst *_di; - std::vector _history_handles; + struct sr_dev_inst *_di; IDeviceAgentCallback *_callback; }; diff --git a/libsigrok4DSL/dsdevice.c b/libsigrok4DSL/dsdevice.c index 6f030df1..986f27bf 100644 --- a/libsigrok4DSL/dsdevice.c +++ b/libsigrok4DSL/dsdevice.c @@ -207,6 +207,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int mode, int status, sdi->status = status; sdi->handle = (ds_device_handle)sdi; sdi->dev_type = DEV_TYPE_UNKOWN; + sdi->actived_times = 0; if (vendor != NULL){ sdi->vendor = g_strdup(vendor); diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c index 0adfd431..234d717b 100644 --- a/libsigrok4DSL/lib_main.c +++ b/libsigrok4DSL/lib_main.c @@ -400,6 +400,7 @@ SR_API int ds_active_device(ds_device_handle handle) if (ret == SR_OK) { lib_ctx.actived_device_instance = dev; + dev->actived_times++; } else { @@ -646,6 +647,7 @@ SR_API int ds_get_actived_device_info(struct ds_device_full_info *fill_info) p->driver_name[0] = '\0'; p->dev_type = DEV_TYPE_UNKOWN; p->di = NULL; + p->actived_times = 0; pthread_mutex_lock(&lib_ctx.mutext); @@ -655,6 +657,7 @@ SR_API int ds_get_actived_device_info(struct ds_device_full_info *fill_info) p->handle = dev->handle; p->dev_type = dev->dev_type; p->di = dev; + p->actived_times = dev->actived_times; strncpy(p->name, dev->name, sizeof(p->name) - 1); if (dev->driver && dev->driver->name) diff --git a/libsigrok4DSL/libsigrok-internal.h b/libsigrok4DSL/libsigrok-internal.h index 08fdad16..8d0438c2 100644 --- a/libsigrok4DSL/libsigrok-internal.h +++ b/libsigrok4DSL/libsigrok-internal.h @@ -175,6 +175,8 @@ struct sr_dev_inst { /** Device instance private data (used?) */ void *priv; + + int actived_times; }; struct sr_session diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index d9427916..8293607b 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -1334,6 +1334,7 @@ struct ds_device_full_info char path[256]; //file path char driver_name[20]; int dev_type; // enum sr_device_type + int actived_times; struct sr_dev_inst *di; };