diff --git a/DSView/pv/appcontrol.cpp b/DSView/pv/appcontrol.cpp index dff58bc7..eae70d5d 100644 --- a/DSView/pv/appcontrol.cpp +++ b/DSView/pv/appcontrol.cpp @@ -71,8 +71,10 @@ bool AppControl::Init() return false; } + const char *decoderScriptDir = "/home/lala/tmpdir/any"; + // Initialise libsigrokdecode - if (srd_init(NULL) != SRD_OK) + if (srd_init(decoderScriptDir) != SRD_OK) { m_error = "ERROR: libsigrokdecode init failed."; return false; diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index c53affa1..b8c15a24 100755 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -516,11 +516,18 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod if (chunk_end - i > MaxChunkSize) chunk_end = i + MaxChunkSize; - if (srd_session_send(session, i, chunk_end, - chunk.data(), chunk_const.data(), chunk_end - i, &error) != SRD_OK) { + if (srd_session_send( + session, + i, + chunk_end, + chunk.data(), + chunk_const.data(), + chunk_end - i, + &error) != SRD_OK){ _error_message = QString::fromLocal8Bit(error); break; } + i = chunk_end; { diff --git a/DSView/pv/data/decoderstack.h b/DSView/pv/data/decoderstack.h index cef31dab..7685e272 100755 --- a/DSView/pv/data/decoderstack.h +++ b/DSView/pv/data/decoderstack.h @@ -94,9 +94,7 @@ public: } void push(decode::Decoder *decoder); - void remove(decode::Decoder *decoder); - void build_row(); int64_t samples_decoded(); @@ -111,7 +109,6 @@ public: uint64_t get_annotation_index( const decode::Row &row, uint64_t start_sample); - uint64_t get_max_annotation(const decode::Row &row); uint64_t get_min_annotation(const decode::Row &row); // except instant(end=start) annotation @@ -119,9 +116,7 @@ public: std::map get_rows_lshow(); void set_rows_gshow(const decode::Row row, bool show); void set_rows_lshow(const decode::Row row, bool show); - bool has_annotations(const decode::Row &row); - uint64_t list_annotation_size(); uint64_t list_annotation_size(uint16_t row_index); @@ -131,13 +126,9 @@ public: bool list_row_title(int row, QString &title); - QString error_message(); - void clear(); - void init(); - uint64_t get_max_sample_count(); inline bool IsRunning(){ @@ -145,31 +136,22 @@ public: } void begin_decode_work(); - void do_decode_work(); - - void stop_decode_work(); - + void stop_decode_work(); int list_rows_size(); - bool options_changed(); void set_options_changed(bool changed); uint64_t sample_count(); uint64_t sample_rate(); - bool out_of_memory(); - void set_mark_index(int64_t index); int64_t get_mark_index(); - void frame_ended(); private: void decode_data(const uint64_t decode_start, const uint64_t decode_end, srd_session *const session); - void decode_proc(); - static void annotation_callback(srd_proto_data *pdata, void *decoder); @@ -179,7 +161,6 @@ signals: private: std::list _stack; - pv::data::LogicSnapshot *_snapshot; std::map _rows; @@ -192,15 +173,15 @@ private: volatile bool _options_changed; volatile bool _no_memory; int64_t _mark_index; + DecoderStatus *_decoder_status; QString _error_message; int64_t _samples_decoded; uint64_t _sample_count; - decode_task_status *_stask_stauts; - + decode_task_status *_stask_stauts; mutable std::mutex _output_mutex; - + friend class DecoderStackTest::TwoDecoderStack; }; diff --git a/DSView/pv/dock/protocoldock.cpp b/DSView/pv/dock/protocoldock.cpp index 26afcc8b..a9affcdc 100755 --- a/DSView/pv/dock/protocoldock.cpp +++ b/DSView/pv/dock/protocoldock.cpp @@ -195,9 +195,7 @@ ProtocolDock::ProtocolDock(QWidget *parent, view::View &view, SigSession *sessio connect(_table_view->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(column_resize(int, int, int))); connect(_search_edit, SIGNAL(editingFinished()), this, SLOT(search_changed())); - retranslateUi(); - - ds_debug("protocol panel\n"); + retranslateUi(); } ProtocolDock::~ProtocolDock() @@ -303,14 +301,19 @@ void ProtocolDock::add_protocol(bool silent) return; } + //have no protocol + if (_protocol_combobox->count() == 0){ + if (!silent){ + MsgBox::Show(NULL, "Protocol list is empty!"); + } + return; + } + srd_decoder *const decoder = (srd_decoder *)(_protocol_combobox->itemData(_protocol_combobox->currentIndex())).value(); DecoderStatus *dstatus = new DecoderStatus(); dstatus->m_format = (int)DecoderDataFormat::hex; - - int numm= _protocol_items.size(); - numm += 0; if (_session->add_decoder(decoder, silent, dstatus)) { diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 2c711e74..a8f3dc45 100755 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -21,9 +21,6 @@ */ - -#include -#include "dock/protocoldock.h" #include #include @@ -70,6 +67,7 @@ #include "dock/dsotriggerdock.h" #include "dock/measuredock.h" #include "dock/searchdock.h" +#include "dock/protocoldock.h" #include "view/view.h" #include "view/trace.h" @@ -168,19 +166,16 @@ void MainWindow::setup_ui() addToolBar(_trig_bar); addToolBar(_file_bar); addToolBar(_logo_bar); - - // Setup the dockWidget - - // protocol dock + + //Setup the dockWidget _protocol_dock=new QDockWidget(tr("Protocol"),this); _protocol_dock->setObjectName("protocol_dock"); _protocol_dock->setFeatures(QDockWidget::DockWidgetMovable); _protocol_dock->setAllowedAreas(Qt::RightDockWidgetArea); - _protocol_dock->setVisible(false); - //dock::ProtocolDock *_protocol_widget = new dock::ProtocolDock(_protocol_dock, _session); + _protocol_dock->setVisible(false); _protocol_widget = new dock::ProtocolDock(_protocol_dock, *_view, _session); _protocol_dock->setWidget(_protocol_widget); - qDebug() << "Protocol decoder enabled!\n"; + //qDebug() << "Protocol decoder enabled!\n"; // measure dock @@ -224,9 +219,7 @@ void MainWindow::setup_ui() _logo_bar->installEventFilter(this); _dso_trigger_dock->installEventFilter(this); _trigger_dock->installEventFilter(this); - _protocol_dock->installEventFilter(this); - _measure_dock->installEventFilter(this); _search_dock->installEventFilter(this); diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 99a41300..4e9e144c 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -437,8 +437,7 @@ void SigSession::start_capture(bool instant) dsoSig->set_mValid(false); } - // update setting - qDebug()<<"device name:"<<_dev_inst->name(); + // update setting if (_dev_inst->name() != "virtual-session") _instant = instant; @@ -1167,8 +1166,6 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi, _dso_data->snapshot()->capture_ended(); _analog_data->snapshot()->capture_ended(); - qDebug()<<"data frame end"; - for (auto trace : _decode_traces){ trace->decoder()->frame_ended(); trace->frame_ended(); @@ -1248,7 +1245,7 @@ void SigSession::hotplug_proc() } catch(...) { qDebug("Interrupt exception for hotplug thread was thrown."); } - qDebug("Hotplug thread exit!"); + // qDebug("Hotplug thread exit!"); } void SigSession::register_hotplug_callback() @@ -1271,10 +1268,9 @@ void SigSession::deregister_hotplug_callback() } void SigSession::start_hotplug_work() -{ - +{ // Begin the session - qDebug() << "Starting a hotplug thread...\n"; + // qDebug() << "Starting a hotplug thread...\n"; _hot_attach = false; _hot_detach = false; @@ -1788,7 +1784,7 @@ void SigSession::set_stop_scale(float scale) //append a decode task, and try create a thread void SigSession::add_decode_task(view::DecodeTrace *trace) { - qDebug()<<"add a decode task"; + //qDebug()<<"add a decode task"; std::lock_guard lock(_decode_task_mutex); _decode_tasks.push_back(trace); @@ -1844,7 +1840,7 @@ void SigSession::set_stop_scale(float scale) //wait thread end if (_decode_thread.joinable()) { - qDebug() << "wait the decode thread end"; + // qDebug() << "wait the decode thread end"; _decode_thread.join(); } @@ -1900,12 +1896,12 @@ void SigSession::set_stop_scale(float scale) //the decode task thread proc void SigSession::decode_task_proc(){ - qDebug()<<"decode thread start"; + //qDebug()<<"decode thread start"; auto task = get_top_decode_task(); while (task != NULL) { - qDebug()<<"one decode task be actived"; + // qDebug()<<"one decode task be actived"; if (!task->_delete_flag){ task->decoder()->begin_decode_work(); @@ -1924,7 +1920,7 @@ void SigSession::set_stop_scale(float scale) task = get_top_decode_task(); } - qDebug()<<"decode thread end"; + // qDebug()<<"decode thread end"; _bDecodeRunning = false; } diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index 16864adb..7f478af0 100755 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -274,7 +274,6 @@ private: void set_capture_state(capture_state state); void register_hotplug_callback(); void deregister_hotplug_callback(); - bool do_add_decoder(srd_decoder *const dec, bool silent, DecoderStatus *dstatus); void add_decode_task(view::DecodeTrace *trace); @@ -301,25 +300,17 @@ private: * used, or NULL if no input format was selected or * auto-detected. */ - static sr_input_format* determine_input_file_format( - const std::string &filename); - + static sr_input_format* determine_input_file_format(const std::string &filename); void sample_thread_proc(DevInst *dev_inst); // data feed void feed_in_header(const sr_dev_inst *sdi); - - void feed_in_meta(const sr_dev_inst *sdi, - const sr_datafeed_meta &meta); - + void feed_in_meta(const sr_dev_inst *sdi, const sr_datafeed_meta &meta); void feed_in_trigger(const ds_trigger_pos &trigger_pos); - void feed_in_logic(const sr_datafeed_logic &logic); void feed_in_dso(const sr_datafeed_dso &dso); - - void feed_in_analog(const sr_datafeed_analog &analog); - + void feed_in_analog(const sr_datafeed_analog &analog); void data_feed_in(const struct sr_dev_inst *sdi, const struct sr_datafeed_packet *packet); diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index eee40b78..a621dc8e 100755 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -23,23 +23,22 @@ #define __STDC_FORMAT_MACROS #include "storesession.h" +#include "sigsession.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include "data/logic.h" +#include "data/logicsnapshot.h" +#include "data/dsosnapshot.h" +#include "data/analogsnapshot.h" +#include "data/decoderstack.h" +#include "data/decode/decoder.h" +#include "data/decode/row.h" +#include "view/trace.h" +#include "view/signal.h" +#include "view/logicsignal.h" +#include "view/dsosignal.h" +#include "view/decodetrace.h" +#include "device/devinst.h" +#include "dock/protocoldock.h" #include #include @@ -51,7 +50,7 @@ #include #include - +#include #include "config/appconfig.h" namespace pv { diff --git a/DSView/pv/storesession.h b/DSView/pv/storesession.h index c7ef0e1d..daadef74 100755 --- a/DSView/pv/storesession.h +++ b/DSView/pv/storesession.h @@ -29,7 +29,7 @@ #include #include -#include + #include "ZipMaker.h" namespace pv { diff --git a/DSView/pv/toolbars/samplingbar.cpp b/DSView/pv/toolbars/samplingbar.cpp index ff193b4c..33f52c72 100755 --- a/DSView/pv/toolbars/samplingbar.cpp +++ b/DSView/pv/toolbars/samplingbar.cpp @@ -339,11 +339,14 @@ void SamplingBar::zero_adj() if ((dsoSig = dynamic_cast(s))) dsoSig->set_enable(true); } + const int index_back = _sample_count.currentIndex(); int i = 0; + for (i = 0; i < _sample_count.count(); i++) if (_sample_count.itemData(i).value() == ZeroTimeBase) break; + _sample_count.setCurrentIndex(i); commit_hori_res(); @@ -722,8 +725,6 @@ double SamplingBar::get_hori_res() double SamplingBar::hori_knob(int dir) { double hori_res = -1; - disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)), - this, SLOT(on_samplecount_sel(int))); if (0 == dir) { hori_res = commit_hori_res(); @@ -735,6 +736,9 @@ double SamplingBar::hori_knob(int dir) hori_res = commit_hori_res(); } + disconnect(&_sample_count, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_samplecount_sel(int))); + connect(&_sample_count, SIGNAL(currentIndexChanged(int)), this, SLOT(on_samplecount_sel(int))); diff --git a/DSView/pv/toolbars/samplingbar.h b/DSView/pv/toolbars/samplingbar.h index 14779f96..3459bb93 100755 --- a/DSView/pv/toolbars/samplingbar.h +++ b/DSView/pv/toolbars/samplingbar.h @@ -64,6 +64,7 @@ namespace pv static const int RefreshShort = 500; static const uint64_t LogicMaxSWDepth64 = SR_GB(16); static const uint64_t LogicMaxSWDepth32 = SR_GB(8); + static const uint64_t AnalogMaxSWDepth = SR_Mn(100); static const QString RLEString; static const QString DIVString; @@ -71,11 +72,8 @@ namespace pv public: SamplingBar(SigSession *session, QWidget *parent); - void set_device_list(const std::list &devices, DevInst* selected); - DevInst *get_selected_device(); - void update_sample_rate_selector(); void set_sampling(bool sampling); @@ -83,9 +81,7 @@ namespace pv bool get_instant(); void enable_toggle(bool enable); - void enable_run_stop(bool enable); - void enable_instant(bool enable); double hori_knob(int dir); @@ -132,37 +128,33 @@ namespace pv void reload(); private: - SigSession *_session; + SigSession *_session; + mutable std::mutex _sampling_mutex; + bool _enable; + bool _sampling; - mutable std::mutex _sampling_mutex; - bool _enable; - bool _sampling; - - QToolButton _device_type; - - QComboBox _device_selector; + QToolButton _device_type; + QComboBox _device_selector; std::map _device_selector_map; - bool _updating_device_selector; + bool _updating_device_selector; - QToolButton _configure_button; + QToolButton _configure_button; + QComboBox _sample_count; + QComboBox _sample_rate; + bool _updating_sample_rate; + bool _updating_sample_count; - QComboBox _sample_count; - QComboBox _sample_rate; - bool _updating_sample_rate; - bool _updating_sample_count; + QToolButton _run_stop_button; + QToolButton _instant_button; + QAction *_run_stop_action; + QAction *_instant_action; + QAction *_mode_action; + QToolButton _mode_button; - QToolButton _run_stop_button; - QToolButton _instant_button; - QAction *_run_stop_action; - QAction *_instant_action; - - QAction *_mode_action; - QToolButton _mode_button; - QMenu *_mode_menu; - QAction *_action_repeat; - QAction *_action_single; - - bool _instant; + QMenu *_mode_menu; + QAction *_action_repeat; + QAction *_action_single; + bool _instant; }; } // namespace toolbars diff --git a/DSView/pv/view/header.cpp b/DSView/pv/view/header.cpp index 3eecd685..90b734f4 100755 --- a/DSView/pv/view/header.cpp +++ b/DSView/pv/view/header.cpp @@ -58,6 +58,8 @@ Header::Header(View &parent) : _moveFlag = false; _colorFlag = false; _nameFlag = false; + _context_trace = NULL; + nameEdit = new QLineEdit(this); nameEdit->setFixedWidth(100); nameEdit->hide(); diff --git a/libsigrokdecode4DSL/srd.c b/libsigrokdecode4DSL/srd.c index 38bb803e..92be591f 100755 --- a/libsigrokdecode4DSL/srd.c +++ b/libsigrokdecode4DSL/srd.c @@ -190,7 +190,7 @@ SRD_API int srd_init(const char *path) size_t i; int ret; const char *env_path; - + if (max_session_id != -1) { srd_err("libsigrokdecode is already initialized."); return SRD_ERR; @@ -202,30 +202,15 @@ SRD_API int srd_init(const char *path) PyImport_AppendInittab("sigrokdecode", PyInit_sigrokdecode); /* Initialize the Python interpreter. */ - Py_InitializeEx(0); + Py_InitializeEx(0); - /* Locations relative to the XDG system data directories. */ - sys_datadirs = g_get_system_data_dirs(); - for (i = g_strv_length((char **)sys_datadirs); i > 0; i--) { - ret = searchpath_add_xdg_dir(sys_datadirs[i-1]); - if (ret != SRD_OK) { - Py_Finalize(); - return ret; - } - } #ifdef DECODERS_DIR /* Hardcoded decoders install location, if defined. */ if ((ret = srd_decoder_searchpath_add(DECODERS_DIR)) != SRD_OK) { Py_Finalize(); return ret; } -#endif - /* Location relative to the XDG user data directory. */ - ret = searchpath_add_xdg_dir(g_get_user_data_dir()); - if (ret != SRD_OK) { - Py_Finalize(); - return ret; - } +#endif /* Path specified by the user. */ if (path) { @@ -234,13 +219,36 @@ SRD_API int srd_init(const char *path) return ret; } } + else{ + /* Locations relative to the XDG system data directories. */ + sys_datadirs = g_get_system_data_dirs(); + for (i = g_strv_length((char **)sys_datadirs); i > 0; i--) + { + ret = searchpath_add_xdg_dir(sys_datadirs[i - 1]); + if (ret != SRD_OK) + { + Py_Finalize(); + return ret; + } + } - /* Environment variable overrides everything, for debugging. */ - if ((env_path = g_getenv("SIGROKDECODE_DIR"))) { - if ((ret = srd_decoder_searchpath_add(env_path)) != SRD_OK) { + /* Location relative to the XDG user data directory. */ + ret = searchpath_add_xdg_dir(g_get_user_data_dir()); + if (ret != SRD_OK) + { Py_Finalize(); return ret; } + + /* Environment variable overrides everything, for debugging. */ + if ((env_path = g_getenv("SIGROKDECODE_DIR"))) + { + if ((ret = srd_decoder_searchpath_add(env_path)) != SRD_OK) + { + Py_Finalize(); + return ret; + } + } } /* Initialize the Python GIL (this also happens to acquire it). */ diff --git a/libsigrokdecode4DSL/util.c b/libsigrokdecode4DSL/util.c index 45fb2d1c..3211fae5 100755 --- a/libsigrokdecode4DSL/util.c +++ b/libsigrokdecode4DSL/util.c @@ -39,13 +39,13 @@ SRD_PRIV PyObject *py_import_by_name(const char *name) PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - + py_modname = PyUnicode_FromString(name); if (!py_modname) { PyGILState_Release(gstate); return NULL; - } - + } + py_mod = PyImport_Import(py_modname); Py_DECREF(py_modname);