]> sigrok.org Git - sigrok-cli.git/blobdiff - show.c
doc: update sigrok-cli(1) for channel assignment to decoder inputs
[sigrok-cli.git] / show.c
diff --git a/show.c b/show.c
index 5c35bb317c972b0442622ef36245a68fd0ba7d63..85b440989212f04d2480f68bb242c155117c5b0f 100644 (file)
--- a/show.c
+++ b/show.c
 #include <string.h>
 #include "sigrok-cli.h"
 
+#define DECODERS_HAVE_TAGS \
+       ((SRD_PACKAGE_VERSION_MAJOR > 0) || \
+        (SRD_PACKAGE_VERSION_MAJOR == 0) && (SRD_PACKAGE_VERSION_MINOR > 5))
+
 static gint sort_inputs(gconstpointer a, gconstpointer b)
 {
        return strcmp(sr_input_id_get((struct sr_input_module *)a),
@@ -235,11 +239,13 @@ void show_supported_wiki(void)
        for (l = sl; l; l = l->next) {
                dec = l->data;
 
+#if DECODERS_HAVE_TAGS
                GString *tags = g_string_new(NULL);
                for (GSList *t = dec->tags; t; t = t->next)
                        g_string_append_printf(tags, "%s, ", (char *)t->data);
                if (tags->len != 0)
                        g_string_truncate(tags, tags->len - 2);
+#endif
 
                GString *in = g_string_new(NULL);
                for (GSList *t = dec->inputs; t; t = t->next)
@@ -257,11 +263,19 @@ void show_supported_wiki(void)
                else
                        g_string_truncate(out, out->len - 2);
 
+#if DECODERS_HAVE_TAGS
                printf("{{pd|%s|%s|%s|%s|%s|%s|%s|supported}}\n",
                        dec->id, dec->name, dec->longname, dec->desc,
                        tags->str, in->str, out->str);
+#else
+               printf("{{pd|%s|%s|%s|%s|%s|%s|supported}}\n",
+                       dec->id, dec->name, dec->longname, dec->desc,
+                       in->str, out->str);
+#endif
 
+#if DECODERS_HAVE_TAGS
                g_string_free(tags, TRUE);
+#endif
                g_string_free(in, TRUE);
                g_string_free(out, TRUE);
        }
@@ -404,7 +418,7 @@ void show_dev_detail(void)
        char *tmp_str, *s, c;
        const char **stropts;
        double tmp_flt;
-       gboolean have_tmp_flt;
+       gboolean have_tmp_flt, have_curr;
        const double *fltopts;
 
        if (parse_driver(opt_drv, &driver_from_opt, NULL)) {
@@ -451,8 +465,11 @@ void show_dev_detail(void)
                printf("Channel groups:\n");
                for (cgl = channel_groups; cgl; cgl = cgl->next) {
                        cg = cgl->data;
-                       printf("    %s: channel%s", cg->name,
-                                       g_slist_length(cg->channels) > 1 ? "s" : "");
+                       printf("    %s: ", cg->name);
+                       if (g_slist_length(cg->channels) == 0)
+                               printf("No channels");
+                       else
+                               printf("channel%s", g_slist_length(cg->channels) > 1 ? "s" : "");
                        for (chl = cg->channels; chl; chl = chl->next) {
                                ch = chl->data;
                                printf(" %s", ch->name);
@@ -701,12 +718,11 @@ void show_dev_detail(void)
                                continue;
                        }
 
+                       have_curr = FALSE;
                        if (maybe_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) {
                                g_variant_get(gvar, "(dd)", &dcur_low, &dcur_high);
                                g_variant_unref(gvar);
-                       } else {
-                               dcur_low = 0;
-                               dcur_high = 0;
+                               have_curr = TRUE;
                        }
 
                        num_elements = g_variant_n_children(gvar_list);
@@ -717,6 +733,8 @@ void show_dev_detail(void)
                                if (i)
                                        printf(", ");
                                printf("%.1f-%.1f", dlow, dhigh);
+                               if (!have_curr)
+                                       continue;
                                if (dlow == dcur_low && dhigh == dcur_high)
                                        printf(" (current)");
                        }
@@ -880,6 +898,7 @@ static void show_pd_detail_single(const char *pd)
                        printf("None.\n");
                }
                printf("Decoder tags:\n");
+#if DECODERS_HAVE_TAGS
                if (dec->tags) {
                        for (l = dec->tags; l; l = l->next) {
                                str = l->data;
@@ -888,6 +907,7 @@ static void show_pd_detail_single(const char *pd)
                } else {
                        printf("None.\n");
                }
+#endif
                printf("Annotation classes:\n");
                if (dec->annotations) {
                        for (l = dec->annotations; l; l = l->next) {