X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=show.c;h=ce001cdc55b47c3b099ad71989612c24cea53771;hp=1c5aad09f47760e4d6752a5236311da58926b374;hb=a360511e48f7b77a5535b0391bf391edd2f4718c;hpb=6293db8aea090170eced25d6f92c348b013ea475 diff --git a/show.c b/show.c index 1c5aad0..ce001cd 100644 --- a/show.c +++ b/show.c @@ -58,13 +58,65 @@ static gint sort_pds(gconstpointer a, gconstpointer b) void show_version(void) { + GString *s; + GSList *l, *l_orig, *m; + char *str; + const char *lib, *version; + printf("sigrok-cli %s\n\n", SC_PACKAGE_VERSION_STRING); - printf("Using libsigrok %s (lib version %s).\n", - sr_package_version_string_get(), sr_lib_version_string_get()); + printf("Libraries and features:\n"); + + printf("- libsigrok %s/%s (rt: %s/%s).\n", + SR_PACKAGE_VERSION_STRING, SR_LIB_VERSION_STRING, + sr_package_version_string_get(), sr_lib_version_string_get()); + + s = g_string_sized_new(200); + g_string_append(s, " - Libs:\n"); + l_orig = sr_buildinfo_libs_get(); + for (l = l_orig; l; l = l->next) { + m = l->data; + lib = m->data; + version = m->next->data; + g_string_append_printf(s, " - %s %s\n", lib, version); + g_slist_free_full(m, g_free); + } + g_slist_free(l_orig); + s->str[s->len - 1] = '\0'; + printf("%s\n", s->str); + g_string_free(s, TRUE); + + str = sr_buildinfo_host_get(); + printf(" - Host: %s.\n", str); + g_free(str); + + str = sr_buildinfo_scpi_backends_get(); + printf(" - SCPI backends: %s.\n", str); + g_free(str); + #ifdef HAVE_SRD - printf("Using libsigrokdecode %s (lib version %s).\n\n", - srd_package_version_string_get(), srd_lib_version_string_get()); + printf("- libsigrokdecode %s/%s (rt: %s/%s).\n", + SRD_PACKAGE_VERSION_STRING, SRD_LIB_VERSION_STRING, + srd_package_version_string_get(), srd_lib_version_string_get()); + + s = g_string_sized_new(200); + g_string_append(s, " - Libs:\n"); + l_orig = srd_buildinfo_libs_get(); + for (l = l_orig; l; l = l->next) { + m = l->data; + lib = m->data; + version = m->next->data; + g_string_append_printf(s, " - %s %s\n", lib, version); + g_slist_free_full(m, g_free); + } + g_slist_free(l_orig); + s->str[s->len - 1] = '\0'; + printf("%s\n", s->str); + g_string_free(s, TRUE); + + str = srd_buildinfo_host_get(); + printf(" - Host: %s.\n", str); + g_free(str); #endif } @@ -152,6 +204,74 @@ void show_supported(void) #endif } +void show_supported_wiki(void) +{ +#ifndef HAVE_SRD + printf("Error, libsigrokdecode support not compiled in."); +#else + const GSList *l; + GSList *sl; + struct srd_decoder *dec; + + if (srd_init(NULL) != SRD_OK) + return; + + srd_decoder_load_all(); + sl = g_slist_copy((GSList *)srd_decoder_list()); + sl = g_slist_sort(sl, sort_pds); + + printf("== Supported protocol decoders ==\n\n"); + + printf("\n\n"); + + printf("Number of currently supported protocol decoders: " + "'''%d'''.\n\n", g_slist_length(sl)); + + printf("{| border=\"0\" style=\"font-size: smaller\" " + "class=\"alternategrey sortable sigroktable\"\n" + "|-\n!Protocol\n!Tags\n!Input IDs\n!Output IDs\n!Status\n" + "!Full name\n!Description\n\n"); + + for (l = sl; l; l = l->next) { + dec = l->data; + + 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); + + GString *in = g_string_new(NULL); + for (GSList *t = dec->inputs; t; t = t->next) + g_string_append_printf(in, "%s, ", (char *)t->data); + if (in->len == 0) + g_string_append_printf(in, "—"); + else + g_string_truncate(in, in->len - 2); + + GString *out = g_string_new(NULL); + for (GSList *t = dec->outputs; t; t = t->next) + g_string_append_printf(out, "%s, ", (char *)t->data); + if (out->len == 0) + g_string_append_printf(out, "—"); + else + g_string_truncate(out, out->len - 2); + + 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); + + g_string_free(tags, TRUE); + g_string_free(in, TRUE); + g_string_free(out, TRUE); + } + g_slist_free(sl); + srd_exit(); + + printf("\n|}\n"); +#endif +} + static gint sort_channels(gconstpointer a, gconstpointer b) { const struct sr_channel *pa = a, *pb = b; @@ -269,7 +389,8 @@ void show_dev_detail(void) GVariant *gvar_dict, *gvar_list, *gvar; gsize num_elements; double dlow, dhigh, dcur_low, dcur_high; - const uint64_t *uint64, p, q, low, high; + const uint64_t *uint64; + 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; const int32_t *int32; @@ -717,6 +838,15 @@ static void show_pd_detail_single(const char *pd) } else { printf("None.\n"); } + printf("Decoder tags:\n"); + if (dec->tags) { + for (l = dec->tags; l; l = l->next) { + str = l->data; + printf("- %s\n", str); + } + } else { + printf("None.\n"); + } printf("Annotation classes:\n"); if (dec->annotations) { for (l = dec->annotations; l; l = l->next) { @@ -925,3 +1055,25 @@ void show_transform(void) } g_strfreev(tok); } + +static void print_serial_port(gpointer data, gpointer user_data) +{ + struct sr_serial_port *port; + + port = (void *)data; + (void)user_data; + printf("\t%s\t%s\n", port->name, port->description); +} + +void show_serial_ports(void) +{ + GSList *serial_ports; + + serial_ports = sr_serial_list(NULL); + if (!serial_ports) + return; + + printf("Available serial/HID/BT/BLE ports:\n"); + g_slist_foreach(serial_ports, print_serial_port, NULL); + g_slist_free_full(serial_ports, (GDestroyNotify)sr_serial_free); +}