From: Gerhard Sittig Date: Sat, 22 Aug 2020 16:24:12 +0000 (+0200) Subject: output/csv: always generate text for analog/logic data packets X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=98b7b0895659ded4ccbdf99ea3d6d72db6de4a5e;p=libsigrok.git output/csv: always generate text for analog/logic data packets 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. --- diff --git a/src/output/csv.c b/src/output/csv.c index 49d6eb6e..848595f9 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -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);