From 2067d5973bc3f5603507d6d2e1bb209ce459e32b Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 15 May 2023 18:58:28 +0800 Subject: [PATCH 1/6] fix: The hex format string of decoder result, max length up to 256 --- DSView/pv/data/decode/annotation.cpp | 12 ++++++++++-- DSView/pv/data/decode/annotationrestable.cpp | 3 +++ DSView/pv/data/decode/annotationrestable.h | 6 +++--- DSView/pv/mainwindow.cpp | 6 ++---- lang/cn/msg.json | 2 +- libsigrokdecode4DSL/libsigrokdecode.h | 2 +- libsigrokdecode4DSL/type_decoder.c | 3 ++- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/DSView/pv/data/decode/annotation.cpp b/DSView/pv/data/decode/annotation.cpp index f26a8bb2..cf2ca6dc 100644 --- a/DSView/pv/data/decode/annotation.cpp +++ b/DSView/pv/data/decode/annotation.cpp @@ -87,8 +87,16 @@ Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status) //get numeric data if (pda->str_number_hex[0]){ - strcpy(resItem->str_number_hex, pda->str_number_hex); - resItem->is_numeric = true; + int str_len = strlen(pda->str_number_hex); + + if (str_len <= DECODER_MAX_DATA_BLOCK_LEN){ + resItem->str_number_hex = (char*)malloc(str_len + 1); + + if (resItem->str_number_hex != NULL){ + strcpy(resItem->str_number_hex, pda->str_number_hex); + resItem->is_numeric = true; + } + } } _status->m_bNumeric |= resItem->is_numeric; diff --git a/DSView/pv/data/decode/annotationrestable.cpp b/DSView/pv/data/decode/annotationrestable.cpp index ee382d70..c73edceb 100644 --- a/DSView/pv/data/decode/annotationrestable.cpp +++ b/DSView/pv/data/decode/annotationrestable.cpp @@ -117,6 +117,7 @@ int AnnotationResTable::MakeIndex(const std::string &key, AnnotationSourceItem* item->cur_display_format = -1; item->is_numeric = false; + item->str_number_hex = NULL; newItem = item; int dex = m_indexs.size(); @@ -331,6 +332,8 @@ void AnnotationResTable::reset() { //release all resource for (auto p : m_resourceTable){ + if (p->str_number_hex) + free(p->str_number_hex); delete p; } m_resourceTable.clear(); diff --git a/DSView/pv/data/decode/annotationrestable.h b/DSView/pv/data/decode/annotationrestable.h index 6fbe95ac..0151ca0b 100644 --- a/DSView/pv/data/decode/annotationrestable.h +++ b/DSView/pv/data/decode/annotationrestable.h @@ -26,14 +26,14 @@ #include #include -#define DECODER_MAX_DATA_BLOCK_LEN 35 +#define DECODER_MAX_DATA_BLOCK_LEN 256 #define CONVERT_STR_MAX_LEN 150 struct AnnotationSourceItem { bool is_numeric; - char str_number_hex[DECODER_MAX_DATA_BLOCK_LEN]; //numerical value hex format string - long long numberic_value; + char *str_number_hex; //numerical value hex format string + std::vector src_lines; //the origin source string lines std::vector cvt_lines; //the converted to bin/hex/oct format string lines int cur_display_format; //current format as bin/ex/oct..., init with -1 diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index d4320268..f818a92c 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -1704,13 +1704,11 @@ namespace pv _protocol_widget->update_view_status(); break; - case DSV_MSG_COLLECT_END: - dsv_info("Mainwindow:DSV_MSG_COLLECT_END"); + case DSV_MSG_COLLECT_END: prgRate(0); _view->repeat_unshow(); _view->on_state_changed(true); - _protocol_widget->update_view_status(); - dsv_info("Mainwindow-end:DSV_MSG_COLLECT_END"); + _protocol_widget->update_view_status(); break; case DSV_MSG_END_COLLECT_WORK: diff --git a/lang/cn/msg.json b/lang/cn/msg.json index 75ad9e7c..05cedb4e 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -369,6 +369,6 @@ }, { "id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED", - "text": "设置在使用中,切换失败!" + "text": "设备在使用中,切换失败!" } ] \ No newline at end of file diff --git a/libsigrokdecode4DSL/libsigrokdecode.h b/libsigrokdecode4DSL/libsigrokdecode.h index cc0ad5d8..79f1d23a 100644 --- a/libsigrokdecode4DSL/libsigrokdecode.h +++ b/libsigrokdecode4DSL/libsigrokdecode.h @@ -26,7 +26,7 @@ #include #include -#define DECODE_NUM_HEX_MAX_LEN 35 +#define DECODE_NUM_HEX_MAX_LEN 256 #ifdef __cplusplus extern "C" { diff --git a/libsigrokdecode4DSL/type_decoder.c b/libsigrokdecode4DSL/type_decoder.c index 3b019e1e..dab18f73 100644 --- a/libsigrokdecode4DSL/type_decoder.c +++ b/libsigrokdecode4DSL/type_decoder.c @@ -132,6 +132,7 @@ static int py_parse_ann_data(PyObject *list_obj, char ***out_strv, int list_size nstr = strlen(str) - 1; if (nstr > 0 && nstr < DECODE_NUM_HEX_MAX_LEN){ strcpy(hex_str_buf, str + 1); + str[0] = '\n'; //set ignore flag str[1] = 0; } @@ -241,7 +242,7 @@ static int convert_annotation(struct srd_decoder_inst *di, PyObject *obj, pda->str_number_hex[0] = 0; ann_text = NULL; - pda->numberic_value = 0; + pda->numberic_value = 0; if (py_parse_ann_data(py_tmp, &ann_text, ann_size, pda->str_number_hex, &pda->numberic_value) != SRD_OK) { srd_err("Protocol decoder %s submitted annotation list, but " From 5cf8064ffd4dab1fcaf71d19f5a5cb3a5dbc6465 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 16 May 2023 15:27:57 +0800 Subject: [PATCH 2/6] fix: Unable to capture screen on windows --- DSView/pv/dialogs/applicationpardlg.h | 6 ++---- DSView/pv/mainwindow.cpp | 31 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/DSView/pv/dialogs/applicationpardlg.h b/DSView/pv/dialogs/applicationpardlg.h index 27abb2a0..58f97543 100644 --- a/DSView/pv/dialogs/applicationpardlg.h +++ b/DSView/pv/dialogs/applicationpardlg.h @@ -29,10 +29,8 @@ namespace pv namespace dialogs { - class ApplicationParamDlg : public QObject - { - Q_OBJECT - + class ApplicationParamDlg + { public: ApplicationParamDlg(); ~ApplicationParamDlg(); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index f818a92c..db8ba468 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -43,9 +43,7 @@ #include #include -#ifdef _WIN32 #include -#endif #include "mainwindow.h" @@ -517,21 +515,30 @@ namespace pv AppConfig &app = AppConfig::Instance(); QString default_name = app._userHistory.screenShotPath + "/" + APP_NAME + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss"); -#ifdef _WIN32 int x = parentWidget()->pos().x(); int y = parentWidget()->pos().y(); int w = parentWidget()->frameGeometry().width(); int h = parentWidget()->frameGeometry().height(); + QDesktopWidget *desktop = QApplication::desktop(); + int curMonitor = desktop->screenNumber(this); + +#ifdef _WIN32 + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QPixmap pixmap = QGuiApplication::primaryScreen()->grabWindow(desktop->winId(), x, y, w, h); -#elif __APPLE__ - int x = parentWidget()->pos().x() + MainFrame::Margin; - int y = parentWidget()->pos().y() + MainFrame::Margin; - int w = parentWidget()->geometry().width() - MainFrame::Margin * 2; - int h = parentWidget()->geometry().height() - MainFrame::Margin * 2; - QPixmap pixmap = QGuiApplication::primaryScreen()->grabWindow(winId(), x, y, w, h); -#else - QPixmap pixmap = QGuiApplication::primaryScreen()->grabWindow(winId()); + #else + QPixmap pixmap = QPixmap::grabWidget(parentWidget()); + #endif + +#elif __APPLE__ + x += MainFrame::Margin; + y += MainFrame::Margin; + w -= MainFrame::Margin * 2; + h -= MainFrame::Margin * 2; + QPixmap pixmap = QGuiApplication::screens().at(curMonitor)->grabWindow(winId(), x, y, w, h); + +#else + QPixmap pixmap = QGuiApplication::screens().at(curMonitor)->grabWindow(winId()); #endif QString format = "png"; @@ -1777,7 +1784,7 @@ namespace pv { _view->auto_set_max_scale(); - if(_pattern_mode != "random") + if(_pattern_mode != "random" && _device_agent->path() != "") { StoreSession ss(_session); QJsonArray deArray = get_decoder_json_from_file(_device_agent->path()); From 4836145ae43e3be658ab0d964d2331927e6908fc Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 16 May 2023 15:33:45 +0800 Subject: [PATCH 3/6] fix: The tool bar disabled status for demo device --- DSView/pv/toolbars/samplingbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index 080d0bac..bbd90a94 100644 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -1273,9 +1273,9 @@ namespace pv bool is_rand = rand_mode == "random"; _action_loop->setVisible(is_rand); - if (!is_rand){ + if (!is_rand && mode == LOGIC){ _sample_rate.setEnabled(false); - _sample_count.setEnabled(false); + _sample_count.setEnabled(false); } } } From e0c86995be583a40ddd732c4e565f72946a81cd6 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 16 May 2023 16:57:02 +0800 Subject: [PATCH 4/6] fix: Failed to compile on mac --- libsigrok4DSL/hardware/demo/demo.c | 8 +++++--- libsigrok4DSL/hardware/demo/demo.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libsigrok4DSL/hardware/demo/demo.c b/libsigrok4DSL/hardware/demo/demo.c index 3ffeba6b..b5ac6908 100644 --- a/libsigrok4DSL/hardware/demo/demo.c +++ b/libsigrok4DSL/hardware/demo/demo.c @@ -220,7 +220,7 @@ static int get_pattern_mode_from_file(uint8_t device_mode) dir = g_dir_open(dir_str,0,NULL); if(dir == NULL) { - return; + return 0; } while ((filename = g_dir_read_name(dir)) != NULL) @@ -251,6 +251,8 @@ static int get_pattern_mode_from_file(uint8_t device_mode) pattern_dso_count = index; else if(device_mode == ANALOG) pattern_analog_count = index; + + return 0; } static int scan_dsl_file(struct sr_dev_inst *sdi) @@ -423,7 +425,7 @@ static int init_random_data(struct session_vdev * vdev,struct sr_dev_inst *sdi) probe_count[cur_probe] -= 1; } } - return; + return 0; } @@ -448,7 +450,7 @@ static GSList *hw_scan(GSList *options) if (vdev == NULL) { sr_err("%s: sdi->priv malloc failed", __func__); - return SR_ERR_MALLOC; + return devices; } sdi = sr_dev_inst_new(LOGIC, SR_ST_INACTIVE, diff --git a/libsigrok4DSL/hardware/demo/demo.h b/libsigrok4DSL/hardware/demo/demo.h index de574896..8e33a378 100644 --- a/libsigrok4DSL/hardware/demo/demo.h +++ b/libsigrok4DSL/hardware/demo/demo.h @@ -136,7 +136,7 @@ struct DEMO_caps { const uint64_t *vdivs; uint8_t vga_id; uint16_t default_channelmode; - enum DEMO_PATTERN default_pattern; + int default_pattern; /**enum DEMO_PATTERN type*/ uint64_t default_timebase; }; From e7464a02d3b5a7970dac0596f07b82809bc07248 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 16 May 2023 17:56:10 +0800 Subject: [PATCH 5/6] fix: Paint the annotation mark used an invalid position --- DSView/pv/view/decodetrace.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index 3d3aa376..a27c9b4a 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -383,10 +383,12 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, ((type%100 != a.type()%100) && (type%100 != 0))) continue; + const double mark_end = a.end_sample() / samples_per_pixel - pixels_offset; + for(auto s : _session->get_signals()) { if((s->get_index() == iter.second) && s->signal_type() == LOGIC_SIGNAL) { view::LogicSignal *logicSig = (view::LogicSignal*)s; - logicSig->paint_mark(p, start, end, type/100); + logicSig->paint_mark(p, start, mark_end, type/100); break; } } From 04b36c9b2b1b150b03bdc89220c39b4257932d0f Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 16 May 2023 19:29:03 +0800 Subject: [PATCH 6/6] Language resource file --- DSView/pv/dialogs/deviceoptions.cpp | 13 ++++------- DSView/pv/sigsession.cpp | 3 ++- lang/cn/msg.json | 36 ++++++++++++++--------------- lang/en/msg.json | 12 +++++----- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/DSView/pv/dialogs/deviceoptions.cpp b/DSView/pv/dialogs/deviceoptions.cpp index 20477bef..332c629f 100644 --- a/DSView/pv/dialogs/deviceoptions.cpp +++ b/DSView/pv/dialogs/deviceoptions.cpp @@ -39,7 +39,7 @@ #include "../sigsession.h" #include "../ui/langresource.h" #include "../log.h" -#include +#include "../ui/msgbox.h" using namespace boost; using namespace std; @@ -578,14 +578,9 @@ void DeviceOptions::channel_checkbox_clicked(QCheckBox *sc) int vld_ch_num = g_variant_get_int16(gvar); g_variant_unref(gvar); if (cur_ch_num > vld_ch_num) { - dialogs::DSMessageBox msg(this); - msg.mBox()->setText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_INFORMATION), "Information")); - msg.mBox()->setInformativeText(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_MAX_CHANNEL), "Current mode only suppport max ") - + QString::number(vld_ch_num) - + L_S(STR_PAGE_MSG, S_ID(IDS_MSG_CHANNEL), " channels!")); - msg.mBox()->addButton(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_OK), "Ok"), QMessageBox::AcceptRole); - msg.mBox()->setIcon(QMessageBox::Information); - msg.exec(); + QString msg_str(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_MAX_CHANNEL_COUNT_WARNING), "max count of channels!")); + msg_str = msg_str.replace("{0}", QString::number(vld_ch_num) ); + MsgBox::Show("", msg_str); sc->setChecked(false); } diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index f9f5dfe1..ac4c9398 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -576,7 +576,8 @@ namespace pv if (_device_agent.have_enabled_channel() == false) { - _callback->show_error("No probes enabled."); + QString err_str(L_S(STR_PAGE_MSG, S_ID(IDS_MSG_NO_ENABLED_CHANNEL), "No channels enabled!")); + _callback->show_error(err_str); return false; } diff --git a/lang/cn/msg.json b/lang/cn/msg.json index 05cedb4e..0e094f05 100644 --- a/lang/cn/msg.json +++ b/lang/cn/msg.json @@ -28,7 +28,7 @@ }, { "id": "IDS_MSG_A_CAL_START", - "text": "自动校准程序将启动。不要连接任何探头。这可能需要一段时间!" + "text": "自动校准程序将启动。不要连接任何探头。这可能需要一段时间!" }, { "id": "IDS_MSG_A_CAL", @@ -56,11 +56,11 @@ }, { "id": "IDS_MSG_RE_WIN_ST_ER", - "text": " 还原窗口状态错误!" + "text": "还原窗口状态错误!" }, { "id": "IDS_MSG_INVAILD_CURSOR", - "text": " 样本范围的游标索引无效!" + "text": "样本范围的游标索引无效!" }, { "id": "IDS_MSG_SEL_FILENAME", @@ -104,15 +104,11 @@ }, { "id": "IDS_MSG_ALL_CHANNEL_DISABLE", - "text": " 所有频道已禁用请至少启用一个通道" + "text": "所有通道已禁用,请至少启用一个通道!" }, { - "id": "IDS_MSG_MAX_CHANNEL", - "text": "当前模式仅支持最大" - }, - { - "id": "IDS_MSG_CHANNEL", - "text": " 频道数!" + "id": "IDS_MSG_MAX_CHANNEL_COUNT_WARNING", + "text": "当前模式仅支持最大 {0}\n通道数!" }, { "id": "IDS_MSG_TRI_SET_ISSUE", @@ -132,7 +128,7 @@ }, { "id": "IDS_MSG_CHANGE_SOURCE_FAIL", - "text": " 更改触发源失败!" + "text": "更改触发源失败!" }, { "id": "IDS_MSG_CHANGE_CHANNEL_FAIL", @@ -176,7 +172,7 @@ }, { "id": "IDS_MSG_AD_TRIGGER_NEED_HARDWARE", - "text": " 高级触发模式需要DSLogic硬件支持!" + "text": "高级触发模式需要DSLogic硬件支持!" }, { "id": "IDS_MSG_SET_TRI_MULTI_CHANNEL", @@ -217,7 +213,7 @@ }, { "id": "IDS_MSG_MALLOC_ERROR_DET", - "text": " 内存不足,无法容纳此样本!\n请降低采样深度!" + "text": "内存不足,无法容纳此样本!\n请降低采样深度!" }, { "id": "IDS_DATA_ERROR", @@ -225,7 +221,7 @@ }, { "id": "IDS_DATA_ERROR_DET1", - "text": " 接收的数据与预定义的测试数据不一致!" + "text": "接收的数据与预定义的测试数据不一致!" }, { "id": "IDS_DATA_ERROR_DET2", @@ -237,7 +233,7 @@ }, { "id": "IDS_MSG_PACKET_ERROR_DET", - "text": " 接收到的数据包的内容不是预期的 !" + "text": "接收到的数据包的内容不是预期的 !" }, { "id": "IDS_MSG_DATA_OVERFLOW", @@ -245,7 +241,7 @@ }, { "id": "IDS_MSG_DATA_OVERFLOW_DET", - "text": " USB带宽无法支持当前采样率 ! \n请降低采样深度!" + "text": "USB带宽无法支持当前采样率 ! \n请降低采样深度!" }, { "id": "IDS_MSG_UNDEFINED_ERROR", @@ -257,7 +253,7 @@ }, { "id": "IDS_MSG_STORESESS_SAVESTART_ERROR1", - "text": " DSView当前不支持\n多数据类型的文件保存." + "text": "DSView当前不支持\n多数据类型的文件保存." }, { "id": "IDS_MSG_STORESESS_SAVESTART_ERROR2", @@ -269,7 +265,7 @@ }, { "id": "IDS_MSG_STORESESS_SAVESTART_ERROR4", - "text": " 生成临时文件数据失败." + "text": "生成临时文件数据失败." }, { "id": "IDS_MSG_STORESESS_SAVESTART_ERROR5", @@ -370,5 +366,9 @@ { "id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED", "text": "设备在使用中,切换失败!" + }, + { + "id": "IDS_MSG_NO_ENABLED_CHANNEL", + "text": "未启用通道!" } ] \ No newline at end of file diff --git a/lang/en/msg.json b/lang/en/msg.json index 989c9049..b5f1df3c 100644 --- a/lang/en/msg.json +++ b/lang/en/msg.json @@ -108,12 +108,8 @@ "text": "All channel disabled! Please enable at least one channel." }, { - "id": "IDS_MSG_MAX_CHANNEL", - "text": "Current mode only suppport max " - }, - { - "id": "IDS_MSG_CHANNEL", - "text": " channels!" + "id": "IDS_MSG_MAX_CHANNEL_COUNT_WARNING", + "text": "Current mode only suppport max {0}\nchannels!" }, { "id": "IDS_MSG_TRI_SET_ISSUE", @@ -371,5 +367,9 @@ { "id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED", "text": "The device is busy,switch failed!" + }, + { + "id": "IDS_MSG_NO_ENABLED_CHANNEL", + "text": "No channels enabled!" } ] \ No newline at end of file