]> sigrok.org Git - sigrok-test.git/blobdiff - decoder/runtc.c
pwm: Update files, add a missing file.
[sigrok-test.git] / decoder / runtc.c
index 364e43f284e89bb4f6e2de5081ea15fe49796f64..9dcb66daf03ed00a85f5008e1b5937546c9e0d29 100644 (file)
@@ -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,
@@ -332,10 +332,12 @@ static int run_testcase(char *infile, GSList *pdlist, struct output *op)
        GVariant *gvar;
        GHashTable *channels, *opts;
        GSList *pdl, *l;
-       int idx;
+       int idx, i;
        int max_channel;
        char **decoder_class;
        struct sr_session *sr_sess;
+       gboolean is_number;
+       const char *s;
 
        if (op->outfile) {
                if ((op->outfd = open(op->outfile, O_CREAT|O_WRONLY, 0600)) == -1) {
@@ -378,7 +380,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;