MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / receive

Function receive

libsigrok4DSL/output/csv.c:214–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static int receive(const struct sr_output *o, const struct sr_datafeed_packet *packet,
215 GString **out)
216{
217 const struct sr_datafeed_meta *meta;
218 const struct sr_datafeed_logic *logic;
219 const struct sr_datafeed_dso *dso;
220 const struct sr_datafeed_analog *analog;
221 const struct sr_config *src;
222 GSList *l;
223 struct context *ctx;
224 int idx;
225 uint64_t i, j;
226 unsigned char *p, c;
227 double tmpv;
228 struct sr_channel *ch;
229
230 *out = NULL;
231 if (!o || !o->sdi)
232 return SR_ERR_ARG;
233 if (!(ctx = o->priv))
234 return SR_ERR_ARG;
235
236 switch (packet->type) {
237 case SR_DF_META:
238 meta = packet->payload;
239 for (l = meta->config; l; l = l->next) {
240 src = l->data;
241 if (src->key == SR_CONF_SAMPLERATE)
242 ctx->samplerate = g_variant_get_uint64(src->data);
243 else if (src->key == SR_CONF_LIMIT_SAMPLES)
244 ctx->limit_samples = g_variant_get_uint64(src->data);
245 else if (src->key == SR_CONF_REF_MIN)
246 ctx->ref_min = g_variant_get_uint32(src->data);
247 else if (src->key == SR_CONF_REF_MAX)
248 ctx->ref_max = g_variant_get_uint32(src->data);
249 }
250 break;
251 case SR_DF_LOGIC:
252 logic = packet->payload;
253 if (!ctx->header_done) {
254 *out = gen_header(o);
255 ctx->header_done = TRUE;
256 } else {
257 *out = g_string_sized_new(512);
258 }
259
260 for (i = 0; i <= logic->length - logic->unitsize; i += logic->unitsize) {
261 ctx->index++;
262
263 if (packet->bExportOriginalData == 0){
264 if (ctx->index > 1 && (*(uint64_t *)(logic->data + i) & ctx->mask) == ctx->pre_data)
265 continue;
266 }
267
268 tmpv = (double)(ctx->index-1) / (double)ctx->samplerate;
269 g_string_append_printf(*out, "%0.15g", tmpv);
270
271 for (j = 0; j < ctx->num_enabled_channels; j++) {

Callers

nothing calls this directly

Calls 1

gen_headerFunction · 0.70

Tested by

no test coverage detected