]> sigrok.org Git - sigrok-cli.git/blobdiff - show.c
configure.ac: Only check for things we actually use.
[sigrok-cli.git] / show.c
diff --git a/show.c b/show.c
index b91fa578c2cb5c6ac0e3632eeafba07840743add..2eaa69d70bedc1d4374fc6c6c4c46e4762439111 100644 (file)
--- a/show.c
+++ b/show.c
@@ -130,10 +130,17 @@ void show_version(void)
 #endif
 }
 
+static gint sort_probes(gconstpointer a, gconstpointer b)
+{
+       const struct sr_probe *pa = a, *pb = b;
+
+       return pa->index - pb->index;
+}
+
 static void print_dev_line(const struct sr_dev_inst *sdi)
 {
        struct sr_probe *probe;
-       GSList *l;
+       GSList *sl, *l;
        GString *s;
        GVariant *gvar;
 
@@ -156,11 +163,13 @@ static void print_dev_line(const struct sr_dev_inst *sdi)
                        probe = sdi->probes->data;
                        g_string_append_printf(s, "with 1 probe: %s", probe->name);
                } else {
-                       g_string_append_printf(s, "with %d probes:", g_slist_length(sdi->probes));
-                       for (l = sdi->probes; l; l = l->next) {
+                       sl = g_slist_sort(g_slist_copy(sdi->probes), sort_probes);
+                       g_string_append_printf(s, "with %d probes:", g_slist_length(sl));
+                       for (l = sl; l; l = l->next) {
                                probe = l->data;
                                g_string_append_printf(s, " %s", probe->name);
                        }
+                       g_slist_free(sl);
                }
        }
        g_string_append_printf(s, "\n");
@@ -485,7 +494,7 @@ void show_dev_detail(void)
 #ifdef HAVE_SRD
 void show_pd_detail(void)
 {
-       GSList *l, *ll;
+       GSList *l, *ll, *ol;
        struct srd_decoder *dec;
        struct srd_decoder_option *o;
        char **pdtokens, **pdtok, *optsep, **ann, *val, *doc;
@@ -549,9 +558,14 @@ void show_pd_detail(void)
                if (dec->options) {
                        for (l = dec->options; l; l = l->next) {
                                o = l->data;
+                               printf("- %s: %s (", o->id, o->desc);
+                               for (ol = o->values; ol; ol = ol->next) {
+                                       val = g_variant_print(ol->data, FALSE);
+                                       printf("%s, ", val);
+                                       g_free(val);
+                               }
                                val = g_variant_print(o->def, FALSE);
-                               printf("- %s: %s (default %s)\n", o->id,
-                                       o->desc, val);
+                               printf("default %s)\n", val);
                                g_free(val);
                        }
                } else {