]> sigrok.org Git - pulseview.git/commitdiff
Do not attempt to decode when required probes have not been specified
authorJoel Holdsworth <redacted>
Sat, 8 Feb 2014 16:42:18 +0000 (16:42 +0000)
committerUwe Hermann <redacted>
Sun, 9 Feb 2014 18:44:15 +0000 (19:44 +0100)
This fixes 204

pv/data/decode/decoder.cpp
pv/data/decode/decoder.h
pv/data/decoderstack.cpp

index 0404227eeaef48a92da5581e93f29d16e7e42bf7..3767e4853b3bbe92299a6034d8140cde90424ca4 100644 (file)
@@ -84,6 +84,18 @@ void Decoder::set_option(const char *id, GVariant *value)
        _options[id] = value;
 }
 
+bool Decoder::have_required_probes() const
+{
+       for (GSList *p = _decoder->probes; p; p = p->next) {
+               const srd_probe *const probe = (const srd_probe*)p->data;
+               assert(probe);
+               if (_probes.find(probe) == _probes.end())
+                       return false;
+       }
+
+       return true;
+}
+
 srd_decoder_inst* Decoder::create_decoder_inst(
        srd_session *const session) const
 {
index f96ba2b6e18e66a3b80e00469fdf2cf05db19c17..087955853ca3f6ad719c6f7063193c20a682b66a 100644 (file)
@@ -62,6 +62,8 @@ public:
 
        void set_option(const char *id, GVariant *value);
 
+       bool have_required_probes() const;
+
        srd_decoder_inst* create_decoder_inst(
                srd_session *const session) const;
 
index 073dcd523ec44146fb067cadd9957d5c523f2d76..74ad7d362d0b2fe1e93dc31e928202b06689d23c 100644 (file)
@@ -246,11 +246,17 @@ void DecoderStack::decode_proc(shared_ptr<data::Logic> data)
 
        assert(data);
 
+       // Check we have a snapshot of data
        const deque< shared_ptr<pv::data::LogicSnapshot> > &snapshots =
                data->get_snapshots();
        if (snapshots.empty())
                return;
 
+       // Check that all decoders have the required probes
+       BOOST_FOREACH(const shared_ptr<decode::Decoder> &dec, _stack)
+               if (!dec->have_required_probes())
+                       return;
+
        const shared_ptr<pv::data::LogicSnapshot> &snapshot =
                snapshots.front();
        const int64_t sample_count = snapshot->get_sample_count();