From: Bert Vermeulen Date: Fri, 1 Aug 2014 09:57:59 +0000 (+0200) Subject: output/analog: Fix channel deinterleaving. X-Git-Tag: libsigrok-0.4.0~1183 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6e6babb9d5f2293b3ebc1b7d90f94fa7038e0602;p=libsigrok.git output/analog: Fix channel deinterleaving. --- diff --git a/src/output/analog.c b/src/output/analog.c index b4985a4e..c76392ca 100644 --- a/src/output/analog.c +++ b/src/output/analog.c @@ -222,7 +222,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p struct sr_channel *ch; GSList *l; const float *fdata; - int i, p; + int num_channels, i, c; *out = NULL; if (!o || !o->sdi) @@ -239,12 +239,13 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p analog = packet->payload; fdata = (const float *)analog->data; *out = g_string_sized_new(512); + num_channels = g_slist_length(analog->channels); for (i = 0; i < analog->num_samples; i++) { - for (l = analog->channels, p = 0; l; l = l->next, p++) { + for (l = analog->channels, c = 0; l; l = l->next, c++) { ch = l->data; g_string_append_printf(*out, "%s: ", ch->name); fancyprint(analog->unit, analog->mqflags, - fdata[i + p], *out); + fdata[i * num_channels + c], *out); } } break;