X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoder%2Fruntc.c;h=2193309881b6ed4cc85591d159a94518db1fb1a9;hb=8160e43bc6085f41614b9ce965e5e9bc16618c3e;hp=364e43f284e89bb4f6e2de5081ea15fe49796f64;hpb=dd37a782a8637bdee703a13c949b222b9ba8b95d;p=sigrok-test.git diff --git a/decoder/runtc.c b/decoder/runtc.c index 364e43f..2193309 100644 --- a/decoder/runtc.c +++ b/decoder/runtc.c @@ -252,14 +252,14 @@ static void srd_cb_ann(struct srd_proto_data *pdata, void *cb_data) /* This is not the PD selected for output. */ return; - if (op->class_idx != -1 && op->class_idx != pda->ann_format) + if (op->class_idx != -1 && op->class_idx != pda->ann_class) /* * This output takes a specific annotation class, * but not the one that just came in. */ return; - dec_ann = g_slist_nth_data(dec->annotations, pda->ann_format); + dec_ann = g_slist_nth_data(dec->annotations, pda->ann_class); line = g_string_sized_new(256); g_string_printf(line, "%" PRIu64 "-%" PRIu64 " %s: %s:", pdata->start_sample, pdata->end_sample, @@ -282,13 +282,16 @@ static void sr_cb(const struct sr_dev_inst *sdi, uint64_t samplerate; int num_samples; static int samplecnt = 0; + struct sr_dev_driver *driver; sess = cb_data; + driver = sr_dev_inst_driver_get(sdi); + switch (packet->type) { case SR_DF_HEADER: DBG("Received SR_DF_HEADER"); - if (sr_config_get(sdi->driver, sdi, NULL, SR_CONF_SAMPLERATE, + if (sr_config_get(driver, sdi, NULL, SR_CONF_SAMPLERATE, &gvar) != SR_OK) { ERR("Getting samplerate failed"); break; @@ -308,7 +311,8 @@ static void sr_cb(const struct sr_dev_inst *sdi, case SR_DF_LOGIC: logic = packet->payload; num_samples = logic->length / logic->unitsize; - DBG("Received SR_DF_LOGIC: %d samples", num_samples); + DBG("Received SR_DF_LOGIC (%"PRIu64" bytes, unitsize = %d).", + logic->length, logic->unitsize); srd_session_send(sess, samplecnt, samplecnt + num_samples, logic->data, logic->length); samplecnt += logic->length / logic->unitsize; @@ -331,11 +335,16 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) struct option *option; GVariant *gvar; GHashTable *channels, *opts; - GSList *pdl, *l; - int idx; + GSList *pdl, *l, *devices; + int idx, i; int max_channel; char **decoder_class; struct sr_session *sr_sess; + gboolean is_number; + const char *s; + struct sr_dev_inst *sdi; + uint64_t unitsize; + struct sr_dev_driver *driver; if (op->outfile) { if ((op->outfd = open(op->outfile, O_CREAT|O_WRONLY, 0600)) == -1) { @@ -348,6 +357,13 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) if (sr_session_load(infile, &sr_sess) != SR_OK) return FALSE; + sr_session_dev_list(sr_sess, &devices); + sdi = devices->data; + driver = sr_dev_inst_driver_get(sdi); + sr_config_get(driver, sdi, NULL, SR_CONF_CAPTURE_UNITSIZE, &gvar); + unitsize = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + if (srd_session_new(&sess) != SRD_OK) return FALSE; sr_session_datafeed_callback_add(sr_sess, sr_cb, sess); @@ -378,7 +394,22 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) (GDestroyNotify)g_variant_unref); for (l = pd->options; l; l = l->next) { option = l->data; - g_hash_table_insert(opts, option->key, option->value); + + is_number = TRUE; + s = g_variant_get_string(option->value, NULL); + for (i = 0; i < (int)strlen(s); i++) { + if (!isdigit(s[i])) + is_number = FALSE; + } + + if (is_number) { + /* Integer option value */ + g_hash_table_insert(opts, option->key, + g_variant_new_int64(strtoull(s, NULL, 10))); + } else { + /* String option value */ + g_hash_table_insert(opts, option->key, option->value); + } } if (!(di = srd_inst_new(sess, pd->name, opts))) return FALSE; @@ -397,8 +428,8 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op) g_variant_ref_sink(gvar); g_hash_table_insert(channels, channel->name, gvar); } - if (srd_inst_channel_set_all(di, channels, - (max_channel + 8) / 8) != SRD_OK) + + if (srd_inst_channel_set_all(di, channels, unitsize) != SRD_OK) return FALSE; g_hash_table_destroy(channels); }