-.TH SIGROK\-CLI 1 "October 22, 2018"
+.TH SIGROK\-CLI 1 "March 28, 2019"
.SH "NAME"
sigrok\-cli \- Command-line client for the sigrok software
.SH "SYNOPSIS"
Show information about supported hardware drivers, input file
formats, output file formats, and protocol decoders.
.TP
+.B "\-\-list\-supported\-wiki"
+Show information about supported protocol decoders in MediaWiki syntax.
+This is generally only used by developers to easily update the list of
+supported protocol decoders in the sigrok wiki.
+.TP
\fB\-d, \-\-driver\fP <drivername>
A driver must always be selected (unless doing a global scan). Use the
-.BR "\-L " ( "\-\-list-supported" ")"
+.BR "\-L " ( "\-\-list\-supported" ")"
option to get a list of available drivers.
.sp
Drivers can take options, in the form \fBkey=value\fP
show_version();
else if (opt_list_supported)
show_supported();
+ else if (opt_list_supported_wiki)
+ show_supported_wiki();
else if (opt_input_format && opt_show)
show_input();
else if (opt_output_format && opt_show)
gboolean opt_version = FALSE;
gboolean opt_list_supported = FALSE;
+gboolean opt_list_supported_wiki = FALSE;
gint opt_loglevel = SR_LOG_WARN; /* Show errors+warnings by default. */
gboolean opt_scan_devs = FALSE;
gboolean opt_wait_trigger = FALSE;
"Show version", NULL},
{"list-supported", 'L', 0, G_OPTION_ARG_NONE, &opt_list_supported,
"List supported devices/modules/decoders", NULL},
+ {"list-supported-wiki", 0, 0, G_OPTION_ARG_NONE, &opt_list_supported_wiki,
+ "List supported decoders (MediaWiki)", NULL},
{"loglevel", 'l', 0, G_OPTION_ARG_INT, &opt_loglevel,
"Set loglevel (5 is most verbose)", NULL},
{"driver", 'd', 0, G_OPTION_ARG_CALLBACK, &check_opt_drv,
#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("<!-- Generated via sigrok-cli --list-supported-wiki. -->\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;
/* show.c */
void show_version(void);
void show_supported(void);
+void show_supported_wiki(void);
void show_dev_list(void);
void show_dev_detail(void);
void show_pd_detail(void);
/* options.c */
extern gboolean opt_version;
extern gboolean opt_list_supported;
+extern gboolean opt_list_supported_wiki;
extern gint opt_loglevel;
extern gboolean opt_scan_devs;
extern gboolean opt_wait_trigger;