]> sigrok.org Git - libsigrok.git/commitdiff
output/csv: always generate text for analog/logic data packets
authorGerhard Sittig <redacted>
Sat, 22 Aug 2020 16:24:12 +0000 (18:24 +0200)
committerGerhard Sittig <redacted>
Sat, 22 Aug 2020 17:04:31 +0000 (19:04 +0200)
Unconditionally generate output text when a session packet is received
which carries analog or logic sample data. Even if the data gets queued
and is not shown immediately, in that case the output text remains empty
but needs to be present. Otherwise applications may assume that the CSV
output module had not handled the data at all, which would result in
unexpected "screen output" with fallback data being interleaved with the
CSV output.

This resolves bug #1026 in its strictest sense (the unexpected presence
of fallback data). But leaves all other issues mentioned in comment 1.

src/output/csv.c

index 49d6eb6ec457ea2b211aaab4e897cbd72ce4566c..848595f9d3096b9570fcd0e5505e2d1026ea1250 100644 (file)
@@ -420,7 +420,8 @@ static void dump_saved_values(struct context *ctx, GString **out)
        } else {
                sr_info("Dumping %u samples", ctx->num_samples);
 
-               *out = g_string_sized_new(512);
+               if (!*out)
+                       *out = g_string_sized_new(512);
                num_channels =
                    ctx->num_logic_channels + ctx->num_analog_channels;
 
@@ -678,6 +679,7 @@ static int receive(const struct sr_output *o,
                ctx->trigger = TRUE;
                break;
        case SR_DF_LOGIC:
+               *out = g_string_sized_new(512);
                logic = packet->payload;
                ctx->pkt_snums = logic->length;
                ctx->pkt_snums /= logic->length;
@@ -685,6 +687,7 @@ static int receive(const struct sr_output *o,
                process_logic(ctx, logic);
                break;
        case SR_DF_ANALOG:
+               *out = g_string_sized_new(512);
                analog = packet->payload;
                ctx->pkt_snums = analog->num_samples;
                ctx->pkt_snums /= g_slist_length(analog->meaning->channels);