X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=sigsession.cpp;h=e8d129fcdcc6f7f2cdd3d85455d3bcd352988b52;hp=2df6a151c31e972651f84cc8b157862741ed5204;hb=fc645aa3338e70a1fe3428421037d6a936576464;hpb=2953961c06ff9e758035ba3cd67220568bd01710 diff --git a/sigsession.cpp b/sigsession.cpp index 2df6a151..e8d129fc 100644 --- a/sigsession.cpp +++ b/sigsession.cpp @@ -20,12 +20,16 @@ #include "sigsession.h" +#include + #include // TODO: This should not be necessary SigSession* SigSession::session = NULL; -SigSession::SigSession() +SigSession::SigSession() : + unitSize(0), + sigData(NULL) { // TODO: This should not be necessary session = this; @@ -33,6 +37,8 @@ SigSession::SigSession() SigSession::~SigSession() { + g_array_free(sigData, TRUE); + // TODO: This should not be necessary session = NULL; } @@ -68,10 +74,38 @@ void SigSession::dataFeedIn(const struct sr_dev_inst *sdi, probeList[num_enabled_probes++] = probe->index; } } + + /* How many bytes we need to store num_enabled_probes bits */ + unitSize = (num_enabled_probes + 7) / 8; + sigData = g_array_new(FALSE, FALSE, unitSize); + } + break; + + case SR_DF_LOGIC: + { + uint64_t filter_out_len; + uint8_t *filter_out; + + const struct sr_datafeed_logic *const logic = + (sr_datafeed_logic*)packet->payload; + + qDebug() << "SR_DF_LOGIC (length =" << logic->length + << ", unitsize = " << logic->unitsize << ")"; + + if (sr_filter_probes(logic->unitsize, unitSize, + probeList, (uint8_t*)logic->data, logic->length, + &filter_out, &filter_out_len) != SR_OK) + return; + + assert(sigData); + g_array_append_vals(sigData, filter_out, filter_out_len / unitSize); + + g_free(filter_out); } break; case SR_DF_END: + dataUpdated(); break; } }