]> sigrok.org Git - libsigrok.git/commitdiff
output/analog: Fix channel deinterleaving.
authorBert Vermeulen <redacted>
Fri, 1 Aug 2014 09:57:59 +0000 (11:57 +0200)
committerBert Vermeulen <redacted>
Fri, 1 Aug 2014 09:57:59 +0000 (11:57 +0200)
src/output/analog.c

index b4985a4eaf50a2c7b9384239c85539737c608ebc..c76392caeffbf488ad373e84d1eb92bd0385f41e 100644 (file)
@@ -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;