]> sigrok.org Git - libsigrok.git/commitdiff
output/analog: Display META packets
authorFrank Stettner <redacted>
Thu, 26 Oct 2017 10:56:02 +0000 (12:56 +0200)
committerUwe Hermann <redacted>
Sat, 11 Nov 2017 18:46:52 +0000 (19:46 +0100)
src/output/analog.c

index cd1764b842fd7c23d0e8fd2a91e3aaf762a3160c..f5d23e6fc085b896e0a18246bf51e2134041294a 100644 (file)
@@ -75,6 +75,9 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
 {
        struct context *ctx;
        const struct sr_datafeed_analog *analog;
+       const struct sr_datafeed_meta *meta;
+       const struct sr_config *src;
+       const struct sr_key_info *srci;
        struct sr_channel *ch;
        GSList *l;
        float *fdata;
@@ -94,6 +97,28 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
        case SR_DF_FRAME_END:
                *out = g_string_new("FRAME-END\n");
                break;
+       case SR_DF_META:
+               meta = packet->payload;
+               for (l = meta->config; l; l = l->next) {
+                       src = l->data;
+                       if (!(srci = sr_key_info_get(SR_KEY_CONFIG, src->key)))
+                               return SR_ERR;
+                       *out = g_string_sized_new(512);
+                       g_string_append(*out, "META ");
+                       g_string_append_printf(*out, "%s: ", srci->id);
+                       if (srci->datatype == SR_T_BOOL) {
+                               g_string_append_printf(*out, "%u",
+                                       g_variant_get_boolean(src->data));
+                       } else if (srci->datatype == SR_T_FLOAT) {
+                               g_string_append_printf(*out, "%f",
+                                       g_variant_get_double(src->data));
+                       } else if (srci->datatype == SR_T_UINT64) {
+                               g_string_append_printf(*out, "%" PRIu64,
+                                       g_variant_get_uint64(src->data));
+                       }
+                       g_string_append(*out, "\n");
+               }
+               break;
        case SR_DF_ANALOG:
                analog = packet->payload;
                num_channels = g_slist_length(analog->meaning->channels);