From a42686042a62e24c0eb5f8fbcd9024b4bcbf8e7d Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Sat, 6 May 2023 17:25:18 +0800 Subject: [PATCH] Prompt users to update firmware --- DSView/pv/deviceagent.cpp | 25 ++++++++++++++----------- DSView/pv/deviceagent.h | 6 +++--- DSView/pv/sigsession.cpp | 26 +++++++++++++++++++++++++- DSView/pv/sigsession.h | 6 +++++- lang/cn/msg.json | 4 ++++ lang/en/msg.json | 4 ++++ libsigrok4DSL/lib_main.c | 11 +++++++++++ libsigrok4DSL/libsigrok.h | 2 ++ 8 files changed, 68 insertions(+), 16 deletions(-) diff --git a/DSView/pv/deviceagent.cpp b/DSView/pv/deviceagent.cpp index 21c97932..7fc8ab6c 100644 --- a/DSView/pv/deviceagent.cpp +++ b/DSView/pv/deviceagent.cpp @@ -275,16 +275,6 @@ bool DeviceAgent::have_enabled_channel() return ds_channel_is_enabled() > 0; } -bool DeviceAgent::get_status(struct sr_status &status, gboolean prg) -{ - assert(_dev_handle); - - if (ds_get_actived_device_status(&status, prg) == SR_OK){ - return true; - } - return false; -} - void DeviceAgent::config_changed() { if (_callback != NULL){ @@ -317,7 +307,9 @@ const struct sr_config_info *DeviceAgent::get_config_info(int key) } bool DeviceAgent::get_device_status(struct sr_status &status, gboolean prg) -{ +{ + assert(_dev_handle); + if (ds_get_actived_device_status(&status, prg) == SR_OK) { return true; @@ -384,5 +376,16 @@ GSList *DeviceAgent::get_channels() return get_operation_mode() == LO_OP_STREAM; } + bool DeviceAgent::check_firmware_version() + { + int st = -1; + if (ds_get_actived_device_init_status(&st) == SR_OK){ + if (st == SR_ST_INCOMPATIBLE){ + return false; + } + } + return true; + } + //---------------device config end -----------/ diff --git a/DSView/pv/deviceagent.h b/DSView/pv/deviceagent.h index 31cad840..9b927efc 100644 --- a/DSView/pv/deviceagent.h +++ b/DSView/pv/deviceagent.h @@ -150,9 +150,7 @@ public: */ bool is_trigger_enabled(); - bool have_enabled_channel(); - - bool get_status(struct sr_status &status, gboolean prg); + bool have_enabled_channel(); GSList* get_channels(); @@ -183,6 +181,8 @@ public: bool is_stream_mode(); + bool check_firmware_version(); + private: void config_changed(); bool is_in_history(ds_device_handle dev_handle); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 43e41fe4..eec8c361 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -55,6 +55,7 @@ #include "config/appconfig.h" #include "utility/path.h" #include "ui/msgbox.h" +#include "ui/langresource.h" namespace pv { @@ -124,6 +125,7 @@ namespace pv _repeat_timer.SetCallback(std::bind(&SigSession::repeat_capture_wait_timeout, this)); _repeat_wait_prog_timer.SetCallback(std::bind(&SigSession::repeat_wait_prog_timeout, this)); _refresh_rt_timer.SetCallback(std::bind(&SigSession::realtime_refresh_timeout, this)); + _delay_prop_msg_timer.SetCallback(std::bind(&SigSession::on_delay_prop_msg, this)); } SigSession::SigSession(SigSession &o) @@ -249,6 +251,12 @@ 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) + { + QString strMsg = L_S(STR_PAGE_MSG, S_ID(IDS_MSG_TO_RECONNECT_FOR_FIRMWARE), "Please reconnect the device!"); + delay_prop_msg(strMsg); + } + return true; } @@ -690,7 +698,7 @@ namespace pv uint64_t sample_limits = cur_samplelimits(); sr_status status; - if (_device_agent.get_status(status, true)) + if (_device_agent.get_device_status(status, true)) { triggered = status.trig_hit & 0x01; uint64_t captured_cnt = status.trig_hit >> 2; @@ -2231,4 +2239,20 @@ namespace pv set_cur_samplelimits(_device_agent.get_sample_limit()); } + void SigSession::delay_prop_msg(QString strMsg) + { + _strMsg = strMsg; + if (_strMsg != ""){ + _delay_prop_msg_timer.Start(1000); + } + } + + void SigSession::on_delay_prop_msg() + { + _delay_prop_msg_timer.Stop(); + + if (_strMsg != "") + MsgBox::Show("", _strMsg); + } + } // namespace pv diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index a00a1259..db3d6882 100644 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -410,7 +410,8 @@ public: } void on_load_config_end(); - void init_signals(); + void init_signals(); + void delay_prop_msg(QString strMsg); private: void set_cur_samplelimits(uint64_t samplelimits); @@ -490,6 +491,7 @@ private: void realtime_refresh_timeout(); void clear_signals(); + void on_delay_prop_msg(); private: mutable std::mutex _sampling_mutex; @@ -511,6 +513,7 @@ private: DsTimer _repeat_timer; DsTimer _repeat_wait_prog_timer; DsTimer _refresh_rt_timer; + DsTimer _delay_prop_msg_timer; int _noData_cnt; bool _data_lock; bool _data_updated; @@ -545,6 +548,7 @@ private: uint64_t _rt_ck_refresh_time_id; COLLECT_OPT_MODE _opt_mode; bool _is_stream_mode; + QString _strMsg; ISessionCallback *_callback; diff --git a/lang/cn/msg.json b/lang/cn/msg.json index d64d07d6..132fe0d7 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -362,5 +362,9 @@ { "id": "IDS_MSG_DISABLED_CHANNEL_TRIG", "text": "禁用通道不能用于触发!" + }, + { + "id": "IDS_MSG_TO_RECONNECT_FOR_FIRMWARE", + "text": "固件版本不对,请重新连接设备!" } ] \ No newline at end of file diff --git a/lang/en/msg.json b/lang/en/msg.json index 6708bbd5..6efb4cc2 100644 --- a/lang/en/msg.json +++ b/lang/en/msg.json @@ -363,5 +363,9 @@ { "id": "IDS_MSG_DISABLED_CHANNEL_TRIG", "text": "Disabled channels cannot be used for triggering!" + }, + { + "id": "IDS_MSG_TO_RECONNECT_FOR_FIRMWARE", + "text": "The firmware version is incorrect, please reconnect the device!" } ] \ No newline at end of file diff --git a/libsigrok4DSL/lib_main.c b/libsigrok4DSL/lib_main.c index 2f88d376..675388f7 100644 --- a/libsigrok4DSL/lib_main.c +++ b/libsigrok4DSL/lib_main.c @@ -969,6 +969,17 @@ SR_API int ds_dsl_option_value_to_code(int work_mode, int config_id, const char return sr_dscope_option_value_to_code(lib_ctx.actived_device_instance, config_id, value); } +SR_API int ds_get_actived_device_init_status(int *status) +{ + if (lib_ctx.actived_device_instance != NULL && status != NULL) + { + *status = lib_ctx.actived_device_instance->status; + return SR_OK; + } + + return SR_ERR; +} + /**-----------channel -------------*/ SR_API int ds_enable_device_channel(const struct sr_channel *ch, gboolean enable) { diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 3da86f79..6aa8e241 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -1484,6 +1484,8 @@ SR_API struct sr_config *ds_new_config(int key, GVariant *data); SR_API void ds_free_config(struct sr_config *src); +SR_API int ds_get_actived_device_init_status(int *status); + /** The session file options value text,convert to code. */