]> sigrok.org Git - libsigrok.git/blobdiff - output/analog.c
Always interleave analog data with all enabled probes.
[libsigrok.git] / output / analog.c
index 776f29549074dcbae0a23188ef53ce92b40b28c7..b40439c2bed0c8533d5ba4b5424c33d1d0a8d015 100644 (file)
@@ -173,6 +173,9 @@ static void fancyprint(int unit, int mqflags, float value, GString *out)
                                 * a made-up notation. */
                                g_string_append(out, " %oA");
                        break;
+               case SR_UNIT_CONCENTRATION:
+                       g_string_append_printf(out, "%f ppm", value * 1000000);
+                       break;
                default:
                        si_printf(value, out, "");
        }
@@ -186,12 +189,14 @@ static void fancyprint(int unit, int mqflags, float value, GString *out)
 }
 
 static GString *receive(struct sr_output *o, const struct sr_dev_inst *sdi,
-               struct sr_datafeed_packet *packet)
+               const struct sr_datafeed_packet *packet)
 {
-       struct sr_datafeed_analog *analog;
        struct context *ctx;
-       float *fdata;
-       int i, j;
+       const struct sr_datafeed_analog *analog;
+       struct sr_probe *probe;
+       GSList *l;
+       const float *fdata;
+       int i, p;
 
        (void)sdi;
 
@@ -211,13 +216,13 @@ static GString *receive(struct sr_output *o, const struct sr_dev_inst *sdi,
                break;
        case SR_DF_ANALOG:
                analog = packet->payload;
-               fdata = (float *)analog->data;
+               fdata = (const float *)analog->data;
                for (i = 0; i < analog->num_samples; i++) {
-                       for (j = 0; j < ctx->num_enabled_probes; j++) {
-                               g_string_append_printf(ctx->out, "%s: ",
-                                               (char *)g_ptr_array_index(ctx->probelist, j));
+                       for (l = analog->probes, p = 0; l; l = l->next, p++) {
+                               probe = l->data;
+                               g_string_append_printf(ctx->out, "%s: ", probe->name);
                                fancyprint(analog->unit, analog->mqflags,
-                                               fdata[i + j], ctx->out);
+                                               fdata[i + p], ctx->out);
                        }
                }
                break;