From: Bert Vermeulen Date: Sun, 20 Jan 2013 14:29:28 +0000 (+0100) Subject: handle meta packets, specifically SR_HWCAP_SAMPLERATE X-Git-Tag: sigrok-cli-0.4.0~54 X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=commitdiff_plain;h=7e97afa0d99bf4961f1336122fc595cb4bd55e84 handle meta packets, specifically SR_HWCAP_SAMPLERATE It's actually unused, but a good example of how to handle these. --- diff --git a/sigrok-cli.c b/sigrok-cli.c index 9d870ab..622b5e7 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -568,8 +568,10 @@ static GArray *get_enabled_logic_probes(const struct sr_dev_inst *sdi) static void datafeed_in(const struct sr_dev_inst *sdi, const struct sr_datafeed_packet *packet) { + const struct sr_datafeed_meta *meta; const struct sr_datafeed_logic *logic; const struct sr_datafeed_analog *analog; + struct sr_config *src; static struct sr_output *o = NULL; static GArray *logic_probelist = NULL; static uint64_t received_samples = 0; @@ -580,6 +582,7 @@ static void datafeed_in(const struct sr_dev_inst *sdi, uint64_t *samplerate, output_len, filter_out_len; uint8_t *output_buf, *filter_out; GString *out; + GSList *l; /* If the first packet to come in isn't a header, don't even try. */ if (packet->type != SR_DF_HEADER && o == NULL) @@ -676,6 +679,23 @@ static void datafeed_in(const struct sr_dev_inst *sdi, o = NULL; break; + case SR_DF_META: + g_debug("cli: received SR_DF_META"); + meta = packet->payload; + for (l = meta->config; l; l = l->next) { + src = l->data; + switch (src->key) { + case SR_HWCAP_SAMPLERATE: + samplerate = (uint64_t *)src->value; + g_debug("cli: got samplerate %"PRIu64, *samplerate); + break; + default: + /* Unknown metadata is not an error. */ + break; + } + } + break; + case SR_DF_TRIGGER: g_debug("cli: received SR_DF_TRIGGER"); if (o->format->event)