X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=show.c;h=5243e53cc07aad1817b37cbd2bb2132a57ce83ac;hp=e62f69746358663190d4a8b625871efd79497119;hb=7ce834c1166fcf57ebb0e20bf4e7ba9e856aa6ce;hpb=6129707f9f9a13ba04eb2e6017197737428fa25a diff --git a/show.c b/show.c index e62f697..5243e53 100644 --- a/show.c +++ b/show.c @@ -22,6 +22,10 @@ #include #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); } @@ -393,6 +407,7 @@ void show_dev_detail(void) gsize num_elements; double dlow, dhigh, dcur_low, dcur_high; const uint64_t *uint64; + uint64_t cur_rate, rate; uint64_t p = 0, q = 0, low = 0, high = 0; uint64_t tmp_uint64, mask, cur_low, cur_high, cur_p, cur_q; GArray *opts; @@ -403,6 +418,7 @@ void show_dev_detail(void) char *tmp_str, *s, c; const char **stropts; double tmp_flt; + gboolean have_tmp_flt; const double *fltopts; if (parse_driver(opt_drv, &driver_from_opt, NULL)) { @@ -439,7 +455,7 @@ void show_dev_detail(void) * returned, or which values for them. */ select_channels(sdi); - channel_group = select_channel_group(sdi); + channel_group = lookup_channel_group(sdi, NULL); if (!(opts = sr_dev_options(driver, sdi, channel_group))) /* Driver supports no device instance options. */ @@ -449,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); @@ -535,6 +554,13 @@ void show_dev_detail(void) } else if (key == SR_CONF_SAMPLERATE) { /* Supported samplerates */ printf(" %s", srci->id); + cur_rate = ~0ull; + if (maybe_config_get(driver, sdi, channel_group, + SR_CONF_SAMPLERATE, &gvar) == SR_OK) { + if (g_variant_is_of_type(gvar, G_VARIANT_TYPE_UINT64)) + cur_rate = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + } if (maybe_config_list(driver, sdi, channel_group, SR_CONF_SAMPLERATE, &gvar_dict) != SR_OK) { printf("\n"); @@ -546,9 +572,14 @@ void show_dev_detail(void) &num_elements, sizeof(uint64_t)); printf(" - supported samplerates:\n"); for (i = 0; i < num_elements; i++) { - if (!(s = sr_samplerate_string(uint64[i]))) + rate = uint64[i]; + s = sr_samplerate_string(rate); + if (!s) continue; - printf(" %s\n", s); + printf(" %s", s); + if (rate == cur_rate) + printf(" (current)"); + printf("\n"); g_free(s); } g_variant_unref(gvar_list); @@ -712,14 +743,16 @@ void show_dev_detail(void) } else if (srci->datatype == SR_T_FLOAT) { printf(" %s: ", srci->id); tmp_flt = 0.0; + have_tmp_flt = FALSE; if (maybe_config_get(driver, sdi, channel_group, key, &gvar) == SR_OK) { tmp_flt = g_variant_get_double(gvar); + have_tmp_flt = TRUE; g_variant_unref(gvar); } if (maybe_config_list(driver, sdi, channel_group, key, &gvar) != SR_OK) { - if (tmp_flt) { + if (have_tmp_flt) { /* Can't list, but got a value to show. */ printf("%f (current)", tmp_flt); } @@ -732,7 +765,7 @@ void show_dev_detail(void) if (i) printf(", "); printf("%f", fltopts[i]); - if (tmp_flt && fltopts[i] == tmp_flt) + if (have_tmp_flt && fltopts[i] == tmp_flt) printf(" (current)"); } printf("\n"); @@ -864,6 +897,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; @@ -872,6 +906,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) {