X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-test.git;a=blobdiff_plain;f=decoder%2Fruntc.c;h=2193309881b6ed4cc85591d159a94518db1fb1a9;hp=f58e0046a23d8f5ba29880b76a445147ac4a1f49;hb=e11929d1e00e8326ced8c4ba05ea20d509f74ac7;hpb=ec3de18f47d7cfeeed0756c4f87621259063c435 diff --git a/decoder/runtc.c b/decoder/runtc.c index f58e004..2193309 100644 --- a/decoder/runtc.c +++ b/decoder/runtc.c @@ -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); }