]> sigrok.org Git - sigrok-cli.git/blobdiff - sigrok-cli.c
cli: manpage: Add sigrok-gtk(1) to "SEE ALSO".
[sigrok-cli.git] / sigrok-cli.c
index 979fc89263bb40a2fae0bd1b11147fb5577c0585..ce504b743a0a70f8f6e9ae230ad55c70c9c304c1 100644 (file)
@@ -119,7 +119,7 @@ static void show_version(void)
        printf("Supported protocol decoders:\n");
        for (l = srd_list_decoders(); l; l = l->next) {
                dec = l->data;
-               printf("  %-20s %s\n", dec->id, dec->desc);
+               printf("  %-20s %s\n", dec->id, dec->longname);
        }
        printf("\n");
 
@@ -258,6 +258,38 @@ static void show_device_detail(void)
        }
 }
 
+static void show_pd_detail(void)
+{
+       GSList *l;
+       struct srd_decoder *dec;
+       char **pdtokens, **pdtok, **ann, *doc;
+
+       pdtokens = g_strsplit(opt_pds, ",", -1);
+       for (pdtok = pdtokens; *pdtok; pdtok++) {
+               if (!(dec = srd_get_decoder_by_id(*pdtok))) {
+                       printf("Protocol decoder %s not found.", *pdtok);
+                       return;
+               }
+               printf("ID: %s\nName: %s\nLong name: %s\nDescription: %s\n",
+                               dec->id, dec->name, dec->longname, dec->desc);
+               printf("License: %s\n", dec->license);
+               if (dec->annotations) {
+                       printf("Annotations:\n");
+                       for (l = dec->annotations; l; l = l->next) {
+                               ann = l->data;
+                               printf("- %s\n  %s\n", ann[0], ann[1]);
+                       }
+               }
+               if ((doc = srd_decoder_doc(dec))) {
+                       printf("Documentation:\n%s\n", doc[0] == '\n' ? doc+1 : doc);
+                       g_free(doc);
+               }
+       }
+
+       g_strfreev(pdtokens);
+
+}
+
 static void datafeed_in(struct sr_device *device, struct sr_datafeed_packet *packet)
 {
        static struct sr_output *o = NULL;
@@ -487,25 +519,25 @@ static int register_pds(struct sr_device *device, const char *pdstring)
        return 0;
 }
 
-void show_pd_annotation(struct srd_protocol_data *pdata)
+void show_pd_annotation(struct srd_proto_data *pdata)
 {
        int i;
-       char **annotation;
+       char **annotations;
 
-       annotation = pdata->data;
-       if (pdata->annotation_format != 0) {
+       annotations = pdata->data;
+       if (pdata->ann_format != 0) {
                /* CLI only shows the default annotation format */
                return;
        }
 
-       if (!g_datalist_get_data(&pd_ann_visible, pdata->pdo->protocol_id)) {
+       if (!g_datalist_get_data(&pd_ann_visible, pdata->pdo->proto_id)) {
                /* not in the list of PDs whose annotations we're showing */
                return;
        }
 
-       printf("%s: ", pdata->pdo->protocol_id);
-       for (i = 0; annotation[i]; i++)
-               printf("\"%s\" ", annotation[i]);
+       printf("%s: ", pdata->pdo->proto_id);
+       for (i = 0; annotations[i]; i++)
+               printf("\"%s\" ", annotations[i]);
        printf("\n");
 
 }
@@ -984,7 +1016,7 @@ int main(int argc, char **argv)
                        printf("Failed to register protocol decoders\n");
                        return 1;
                }
-               if (srd_register_callback(SRD_OUTPUT_ANNOTATION,
+               if (srd_register_callback(SRD_OUTPUT_ANN,
                                show_pd_annotation) != SRD_OK) {
                        printf("Failed to register protocol decoder callback\n");
                        return 1;
@@ -1063,6 +1095,8 @@ int main(int argc, char **argv)
                run_session();
        else if (opt_device)
                show_device_detail();
+       else if (opt_pds)
+               show_pd_detail();
        else
                printf("%s", g_option_context_get_help(context, TRUE, NULL));