Upon reception of the SR_DF_END packet, communicate this end of the
datafeed event to libsigrokdecode.  Which in turn can invoke the
protocol decoders' optional decode_end() method before closing the
output stream.

This allows to flush previously accumulated and not yet committed output
data, emit warnings about unterminated frames/transfers/transactions,
etc.  Which minimizes the potential for loss of partial information
about started yet not fully completed conditions in decoded protocols.

Signed-off-by: Gerhard Sittig <gerhard.sit...@gmx.net>
 session.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/session.c b/session.c
index 5e096cd32f39..2833dabcd398 100644
--- a/session.c
+++ b/session.c
@@ -332,6 +332,14 @@ void datafeed_in(const struct sr_dev_inst *sdi,
        if (packet->type == SR_DF_END) {
                g_debug("cli: Received SR_DF_END.");
+#ifdef HAVE_SRD
+               if (opt_pds) {
+                       g_debug("cli: Flushing PDs.");
+                       if (srd_session_send_eof(srd_sess) != SRD_OK)
+                               sr_session_stop(session);
+               }
                if (o)
                o = NULL;

Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
sigrok-devel mailing list

Reply via email to