diff --git a/DSView/main.cpp b/DSView/main.cpp index e038ae68..c7e59aea 100755 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -112,8 +112,14 @@ int main(int argc, char *argv[]) QApplication::setOrganizationDomain("www.DreamSourceLab.com"); #ifdef Q_OS_LINUX - QCoreApplication::addLibraryPath("/usr/lib/x86_64-linux-gnu/qt5/plugins"); - printf("qt plugins root:/usr/lib/x86_64-linux-gnu/qt5/plugins\n"); + // Use low version qt plugins, for able to debug + QDir qtdir; + qtdir.setPath(GetAppDataDir() + "/qt5.0/plugins"); + + if (qtdir.exists()){ + printf("qt plugins root:%s\n", qtdir.absolutePath().toLatin1().data()); + QCoreApplication::addLibraryPath(qtdir.absolutePath()); + } #endif AppControl *control = AppControl::Instance(); diff --git a/DSView/pv/data/decode/annotation.cpp b/DSView/pv/data/decode/annotation.cpp index 6bd60bee..a362f0e6 100755 --- a/DSView/pv/data/decode/annotation.cpp +++ b/DSView/pv/data/decode/annotation.cpp @@ -25,7 +25,7 @@ #include #include "annotation.h" -#include "AnnotationResTable.h" +#include "annotationrestable.h" #include #include #include @@ -33,10 +33,7 @@ #include "decoderstatus.h" #include "../../dsvdef.h" - //a find talbe instance -AnnotationResTable annTable; -char sz_format_tmp_buf[50]; - + bool is_hex_number_str(const char *str) { char c = *str; @@ -65,6 +62,7 @@ Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status) const srd_proto_data_annotation *const pda = (const srd_proto_data_annotation*)pdata->data; assert(pda); + assert(status); _start_sample = pdata->start_sample; _end_sample = pdata->end_sample; @@ -88,7 +86,7 @@ Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status) } AnnotationSourceItem *resItem = NULL; - _resIndex = annTable.MakeIndex(key, resItem); + _resIndex = _status->m_resTable.MakeIndex(key, resItem); //is a new item if (resItem != NULL){ @@ -103,11 +101,14 @@ Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status) strcpy(resItem->str_number_hex, pda->str_number_hex); resItem->is_numeric = true; } + /* + //disable auto convert to numberic format else if (resItem->src_lines.size() == 1 && _type >= 100 && _type < 200){ if (is_hex_number_str(resItem->src_lines[0].toLatin1().data())){ resItem->is_numeric = true; } } + */ _status->m_bNumeric |= resItem->is_numeric; } @@ -125,44 +126,38 @@ Annotation::~Annotation() } const std::vector& Annotation::annotations() const -{ - assert(_status); - - AnnotationSourceItem &resItem = *annTable.GetItem(_resIndex); +{ + AnnotationSourceItem &resItem = *(_status->m_resTable.GetItem(_resIndex)); //get origin data, is not a numberic value if (!resItem.is_numeric){ return resItem.src_lines; } - + + //resItem.str_number_hex must be not null + if (resItem.str_number_hex[0] == 0){ + assert(false); + } + if (resItem.cur_display_format != _status->m_format){ resItem.cur_display_format = _status->m_format; resItem.cvt_lines.clear(); if (resItem.src_lines.size() > 0) { + //have custom string for (QString &rd_src : resItem.src_lines) { - if (resItem.str_number_hex[0] != 0) - { - QString src = rd_src.replace("{$}", "%s"); - const char *num_str = AnnotationResTable::format_numberic(resItem.str_number_hex, resItem.cur_display_format); - sprintf(sz_format_tmp_buf, src.toLatin1().data(), num_str); - resItem.cvt_lines.push_back(QString(sz_format_tmp_buf)); - } - else - { - const char *src_str = rd_src.toLatin1().data(); - const char *num_str = AnnotationResTable::format_numberic(src_str, resItem.cur_display_format); - if (src_str != num_str) - resItem.cvt_lines.push_back(QString(num_str)); - else - resItem.cvt_lines.push_back(QString(rd_src)); - } + char sz_format_tmp_buf[50] = {0}; + QString src = rd_src.replace("{$}", "%s"); + const char *num_str = _status->m_resTable.format_numberic(resItem.str_number_hex, resItem.cur_display_format); + sprintf(sz_format_tmp_buf, src.toLatin1().data(), num_str); + resItem.cvt_lines.push_back(QString(sz_format_tmp_buf)); } } else{ - const char *num_str = AnnotationResTable::format_numberic(resItem.str_number_hex, resItem.cur_display_format); + //have only numberic value + const char *num_str = _status->m_resTable.format_numberic(resItem.str_number_hex, resItem.cur_display_format); resItem.cvt_lines.push_back(QString(num_str)); } } @@ -172,7 +167,7 @@ const std::vector& Annotation::annotations() const bool Annotation::is_numberic() { - AnnotationSourceItem *resItem = annTable.GetItem(_resIndex); + AnnotationSourceItem *resItem = _status->m_resTable.GetItem(_resIndex); return resItem->is_numeric; } diff --git a/DSView/pv/data/decode/AnnotationResTable.cpp b/DSView/pv/data/decode/annotationrestable.cpp similarity index 92% rename from DSView/pv/data/decode/AnnotationResTable.cpp rename to DSView/pv/data/decode/annotationrestable.cpp index 223a3409..9b761725 100644 --- a/DSView/pv/data/decode/AnnotationResTable.cpp +++ b/DSView/pv/data/decode/annotationrestable.cpp @@ -2,7 +2,7 @@ * This file is part of the PulseView project. * * Copyright (C) 2013 Joel Holdsworth - * Copyright (C) 2014 DreamSourceLab + * Copyright (C) 2022 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,16 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "AnnotationResTable.h" +#include "annotationrestable.h" #include #include "../../dsvdef.h" - -#define DECODER_MAX_DATA_BLOCK_LEN 25 - + const char g_bin_cvt_table[] = "0000000100100011010001010110011110001001101010111100110111101111"; -char g_bin_format_tmp_buffer[DECODER_MAX_DATA_BLOCK_LEN * 4 + 2]; -char g_oct_format_tmp_buffer[DECODER_MAX_DATA_BLOCK_LEN * 3 + 2]; -char g_number_tmp_64[30]; char* bin2oct_string(char *buf, int size, const char *bin, int len){ char *wr = buf + size - 1; @@ -98,6 +93,15 @@ long long bin2long_string(const char *bin, int len) return value; } +//----------------------------------- + +AnnotationResTable::AnnotationResTable(){ + + } + +AnnotationResTable::~AnnotationResTable(){ + reset(); +} int AnnotationResTable::MakeIndex(const std::string &key, AnnotationSourceItem* &newItem) { @@ -126,7 +130,7 @@ AnnotationSourceItem* AnnotationResTable::GetItem(int index){ const char* AnnotationResTable::format_numberic(const char *hex_str, int fmt) { assert(hex_str); - + //flow, convert to oct\dec\bin format const char *data = hex_str; if (data[0] == 0 || fmt == DecoderDataFormat::hex){ @@ -203,4 +207,14 @@ const char* AnnotationResTable::format_numberic(const char *hex_str, int fmt) return data; } + +void AnnotationResTable::reset() +{ + //release all resource + for (auto p : m_resourceTable){ + delete p; + } + m_resourceTable.clear(); + m_indexs.clear(); +} diff --git a/DSView/pv/data/decode/AnnotationResTable.h b/DSView/pv/data/decode/annotationrestable.h similarity index 79% rename from DSView/pv/data/decode/AnnotationResTable.h rename to DSView/pv/data/decode/annotationrestable.h index 1cf98f73..222e0147 100644 --- a/DSView/pv/data/decode/AnnotationResTable.h +++ b/DSView/pv/data/decode/annotationrestable.h @@ -2,7 +2,7 @@ * This file is part of the PulseView project. * * Copyright (C) 2013 Joel Holdsworth - * Copyright (C) 2014 DreamSourceLab + * Copyright (C) 2022 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +26,8 @@ #include #include +#define DECODER_MAX_DATA_BLOCK_LEN 25 + struct AnnotationSourceItem { bool is_numeric; @@ -38,6 +40,10 @@ struct AnnotationSourceItem class AnnotationResTable { + public: + AnnotationResTable(); + ~AnnotationResTable(); + public: int MakeIndex(const std::string &key, AnnotationSourceItem* &newItem); AnnotationSourceItem* GetItem(int index); @@ -45,9 +51,14 @@ class AnnotationResTable inline int GetCount(){ return m_resourceTable.size();} - static const char* format_numberic(const char *hex_str, int fmt); + const char* format_numberic(const char *hex_str, int fmt); + + void reset(); private: std::map m_indexs; std::vector m_resourceTable; -}; \ No newline at end of file + char g_bin_format_tmp_buffer[DECODER_MAX_DATA_BLOCK_LEN * 4 + 2]; + char g_oct_format_tmp_buffer[DECODER_MAX_DATA_BLOCK_LEN * 3 + 2]; + char g_number_tmp_64[30]; +}; diff --git a/DSView/pv/data/decode/decoderstatus.cpp b/DSView/pv/data/decode/decoderstatus.cpp new file mode 100644 index 00000000..be3e6255 --- /dev/null +++ b/DSView/pv/data/decode/decoderstatus.cpp @@ -0,0 +1,35 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2013 Joel Holdsworth + * Copyright (C) 2022 DreamSourceLab + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "decoderstatus.h" + +DecoderStatus::DecoderStatus() +{ + m_bNumeric = false; + m_format = 0; + sdr_decoder_handle = NULL; +} + + void DecoderStatus::clear() + { + m_resTable.reset(); + } + diff --git a/DSView/pv/data/decode/decoderstatus.h b/DSView/pv/data/decode/decoderstatus.h index 8761bcc2..c43e8135 100644 --- a/DSView/pv/data/decode/decoderstatus.h +++ b/DSView/pv/data/decode/decoderstatus.h @@ -2,7 +2,7 @@ * This file is part of the PulseView project. * * Copyright (C) 2013 Joel Holdsworth - * Copyright (C) 2014 DreamSourceLab + * Copyright (C) 2022 DreamSourceLab * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,18 +21,18 @@ #pragma once +#include "annotationrestable.h" + class DecoderStatus { public: - DecoderStatus() - { - m_bNumeric = false; - m_format = 0; - sdr_decoder_handle = NULL; - } + DecoderStatus(); + + void clear(); public: - bool m_bNumeric; //when decoder get any numerical data,it will be set - int m_format; //protocol format code - void *sdr_decoder_handle; + bool m_bNumeric; //when decoder get any numerical data,it will be set + int m_format; //protocol format code + void *sdr_decoder_handle; + AnnotationResTable m_resTable; }; diff --git a/DSView/pv/data/decode/rowdata.cpp b/DSView/pv/data/decode/rowdata.cpp index 7dbe30a3..964c13a2 100755 --- a/DSView/pv/data/decode/rowdata.cpp +++ b/DSView/pv/data/decode/rowdata.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "rowdata.h" diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index 7b7f3930..e68b111a 100755 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -73,6 +73,9 @@ DecoderStack::DecoderStack(pv::SigSession *session, DecoderStack::~DecoderStack() { + //release resource talbe + DESTROY_OBJECT(_decoder_status); + //release source for (auto &kv : _rows) { @@ -392,6 +395,7 @@ void DecoderStack::do_decode_work() } _stask_stauts = new decode_task_status(); _stask_stauts->m_bStop = false; + _decoder_status->clear(); //clear old items pv::view::LogicSignal *logic_signal = NULL; pv::data::Logic *data = NULL; diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index 7685e272..bb77ac73 100755 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -31,8 +31,8 @@ #include "decode/row.h" #include "../data/signaldata.h" - -class DecoderStatus; +#include "decode/decoderstatus.h" + struct decode_task_status { diff --git a/DSView/pv/device/device.cpp b/DSView/pv/device/device.cpp index 4e056b45..ca6a4ad9 100755 --- a/DSView/pv/device/device.cpp +++ b/DSView/pv/device/device.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "device.h" diff --git a/DSView/pv/device/file.cpp b/DSView/pv/device/file.cpp index c24233e2..b1ce663a 100755 --- a/DSView/pv/device/file.cpp +++ b/DSView/pv/device/file.cpp @@ -27,7 +27,6 @@ #include -#include using std::string; diff --git a/DSView/pv/device/sessionfile.cpp b/DSView/pv/device/sessionfile.cpp index 3873fa22..82804cde 100755 --- a/DSView/pv/device/sessionfile.cpp +++ b/DSView/pv/device/sessionfile.cpp @@ -20,6 +20,7 @@ */ #include "sessionfile.h" +#include namespace pv { namespace device { diff --git a/DSView/pv/dialogs/calibration.cpp b/DSView/pv/dialogs/calibration.cpp index 76648789..09804c39 100755 --- a/DSView/pv/dialogs/calibration.cpp +++ b/DSView/pv/dialogs/calibration.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "../view/trace.h" #include "../dialogs/dsmessagebox.h" diff --git a/DSView/pv/dialogs/dsomeasure.cpp b/DSView/pv/dialogs/dsomeasure.cpp index 7e9825ef..d9fb4a88 100755 --- a/DSView/pv/dialogs/dsomeasure.cpp +++ b/DSView/pv/dialogs/dsomeasure.cpp @@ -32,7 +32,6 @@ #include "../dsvdef.h" -using namespace boost; using namespace std; using namespace pv::view; diff --git a/DSView/pv/prop/binding/deviceoptions.cpp b/DSView/pv/prop/binding/deviceoptions.cpp index 66a9900f..a357a418 100755 --- a/DSView/pv/prop/binding/deviceoptions.cpp +++ b/DSView/pv/prop/binding/deviceoptions.cpp @@ -33,7 +33,7 @@ #include "../int.h" #include "../../config/appconfig.h" -using namespace boost; + using namespace std; namespace pv { diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/pv/prop/binding/probeoptions.cpp index 74b18088..ea665886 100755 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/pv/prop/binding/probeoptions.cpp @@ -33,7 +33,7 @@ #include "../../config/appconfig.h" -using namespace boost; + using namespace std; namespace pv { diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index 44404627..87fb50b4 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -716,7 +716,7 @@ void StoreSession::export_proc(data::Snapshot *snapshot) meta.config = g_slist_append(meta.config, src); GVariant *gvar; - uint8_t bits; + uint8_t bits=0; gvar = _session->get_device()->get_config(NULL, NULL, SR_CONF_UNIT_BITS); if (gvar != NULL) { bits = g_variant_get_byte(gvar); diff --git a/DSView/pv/view/logicsignal.cpp b/DSView/pv/view/logicsignal.cpp index dae072a8..cc5f8685 100755 --- a/DSView/pv/view/logicsignal.cpp +++ b/DSView/pv/view/logicsignal.cpp @@ -31,7 +31,6 @@ #include "view.h" #include "../extdef.h" -using namespace boost; using namespace std; namespace pv { diff --git a/libsigrokdecode4DSL/type_decoder.c b/libsigrokdecode4DSL/type_decoder.c index 6199652b..2362eda1 100755 --- a/libsigrokdecode4DSL/type_decoder.c +++ b/libsigrokdecode4DSL/type_decoder.c @@ -91,6 +91,7 @@ static int py_parse_ann_data(PyObject *list_obj, char ***out_strv, int list_size goto err; } + //vet numberic value if (py_numobj != NULL){ lv = PyLong_AsLongLong(py_numobj); sprintf(hex_str_buf, "%02llX", lv);