From: Soeren Apel Date: Wed, 4 Apr 2018 17:07:27 +0000 (+0200) Subject: Add DecodeSignal and Session error logging X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=403c3e87178230339ceeb1927b2ed99d3fde046f;p=pulseview.git Add DecodeSignal and Session error logging --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 95ea45a4..f5dc0001 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -156,7 +156,10 @@ void DecodeSignal::reset_decode() logic_mux_data_.reset(); logic_mux_data_invalid_ = true; - error_message_ = QString(); + if (!error_message_.isEmpty()) { + error_message_ = QString(); + qDebug().noquote().nospace() << name() << ": Error cleared"; + } decode_reset(); } @@ -178,14 +181,14 @@ void DecodeSignal::begin_decode() reset_decode(); if (stack_.size() == 0) { - error_message_ = tr("No decoders"); + set_error_message(tr("No decoders")); return; } assert(channels_.size() > 0); if (get_assigned_signal_count() == 0) { - error_message_ = tr("There are no channels assigned to this decoder"); + set_error_message(tr("There are no channels assigned to this decoder")); return; } @@ -199,8 +202,8 @@ void DecodeSignal::begin_decode() // Check that all decoders have the required channels for (const shared_ptr &dec : stack_) if (!dec->have_required_channels()) { - error_message_ = tr("One or more required channels " - "have not been specified"); + set_error_message(tr("One or more required channels " + "have not been specified")); return; } @@ -238,7 +241,7 @@ void DecodeSignal::begin_decode() connect_input_notifiers(); if (get_input_segment_count() == 0) { - error_message_ = tr("No input data"); + set_error_message(tr("No input data")); return; } @@ -582,6 +585,12 @@ void DecodeSignal::restore_settings(QSettings &settings) begin_decode(); } +void DecodeSignal::set_error_message(QString msg) +{ + error_message_ = msg; + qDebug().noquote().nospace() << name() << ": " << msg; +} + uint32_t DecodeSignal::get_input_segment_count() const { uint64_t count = std::numeric_limits::max(); @@ -895,7 +904,7 @@ void DecodeSignal::decode_data( if (srd_session_send(srd_session_, i, chunk_end, chunk, data_size, unit_size) != SRD_OK) { - error_message_ = tr("Decoder reported an error"); + set_error_message(tr("Decoder reported an error")); delete[] chunk; break; } @@ -1022,7 +1031,7 @@ void DecodeSignal::start_srd_session() srd_decoder_inst *const di = dec->create_decoder_inst(srd_session_); if (!di) { - error_message_ = tr("Failed to create decoder instance"); + set_error_message(tr("Failed to create decoder instance")); srd_session_destroy(srd_session_); srd_session_ = nullptr; return; diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index 1455274a..807f0e70 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -137,6 +137,8 @@ public: virtual void restore_settings(QSettings &settings); private: + void set_error_message(QString msg); + uint32_t get_input_segment_count() const; uint32_t get_input_samplerate(uint32_t segment_id) const; diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 8be4265b..088a6e27 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -107,7 +107,7 @@ void GlobalSettings::setValue(const QString &key, const QVariant &value) QSettings::setValue(key, value); - qDebug() << "Setting" << key << "changed to" << value; + qDebug().noquote() << "Setting" << key << "changed to" << value; // Call all registered callbacks for (GlobalSettingsInterface *cb : callbacks_) diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index e88d382e..19caab32 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -562,6 +563,8 @@ bool MainWindow::restoreState(const QByteArray &state, int version) void MainWindow::session_error(const QString text, const QString info_text) { + qDebug().noquote() << "Notifying user of session error:" << info_text; + QMetaObject::invokeMethod(this, "show_session_error", Qt::QueuedConnection, Q_ARG(QString, text), Q_ARG(QString, info_text)); diff --git a/pv/session.cpp b/pv/session.cpp index e8174915..bf9e3a2c 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -299,8 +299,8 @@ void Session::restore_settings(QSettings &settings) filename.toStdString()); set_device(device); - // TODO Perform error handling - start_capture([](QString infoMessage) { (void)infoMessage; }); + start_capture([](QString infoMessage) { + qDebug().noquote() << "Session error:" << infoMessage; }); set_name(QFileInfo(filename).fileName()); } @@ -953,10 +953,8 @@ void Session::sample_thread_proc(function error_handler) set_capture_state(Stopped); // Confirm that SR_DF_END was received - if (cur_logic_segment_) { - qDebug("SR_DF_END was not received."); - assert(false); - } + if (cur_logic_segment_) + qDebug() << "WARNING: SR_DF_END was not received."; // Optimize memory usage free_unused_memory();