]> sigrok.org Git - pulseview.git/commitdiff
Add DecodeSignal and Session error logging
authorSoeren Apel <redacted>
Wed, 4 Apr 2018 17:07:27 +0000 (19:07 +0200)
committerSoeren Apel <redacted>
Wed, 4 Apr 2018 17:07:27 +0000 (19:07 +0200)
pv/data/decodesignal.cpp
pv/data/decodesignal.hpp
pv/globalsettings.cpp
pv/mainwindow.cpp
pv/session.cpp

index 95ea45a4e0a707f62fd2b8e6ba259dc4ebd5fc52..f5dc000169611e355e0d13c07182f81de4bffc5e 100644 (file)
@@ -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<decode::Decoder> &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<uint64_t>::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;
index 1455274af33877a56ca7ffe91e3ac403ef143aab..807f0e70628c0fffaecac06d3eedc487380b0ad4 100644 (file)
@@ -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;
index 8be4265b247e729d00f9bccacd433283d868250f..088a6e27bda0701771e75c8a33c41debc89ed7f2 100644 (file)
@@ -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_)
index e88d382e87c4d6b84cc594ab36469001b305e099..19caab32e2d8d63265758eee8b0bc0b28d2168ed 100644 (file)
@@ -30,6 +30,7 @@
 #include <QAction>
 #include <QApplication>
 #include <QCloseEvent>
+#include <QDebug>
 #include <QDockWidget>
 #include <QHBoxLayout>
 #include <QMessageBox>
@@ -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));
index e8174915e4043c37d508c3371b0c8007d168bd06..bf9e3a2c0897973854223520fb37c1fae83018f7 100644 (file)
@@ -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<void (const QString)> 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();