]> sigrok.org Git - sigrok-cli.git/blobdiff - show.c
Show driver detail even if no device was found.
[sigrok-cli.git] / show.c
diff --git a/show.c b/show.c
index cc5258b6777074a4d7d2154e5e04a02f67678c2e..fa2305f0f98b675c86e744f86b062d978f5b0652 100644 (file)
--- a/show.c
+++ b/show.c
@@ -193,8 +193,47 @@ void show_dev_list(void)
 
 }
 
+void show_drv_detail(struct sr_dev_driver *driver)
+{
+       const struct sr_config_info *srci;
+       GVariant *gvar_opts;
+       const uint32_t *opts;
+       gsize num_elements, i;
+
+       if ((sr_config_list(driver, NULL, NULL, SR_CONF_DEVICE_OPTIONS,
+                       &gvar_opts) == SR_OK)) {
+               opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
+                               sizeof(uint32_t));
+               if (num_elements) {
+                       printf("Driver functions:\n");
+                       for (i = 0; i < num_elements; i++) {
+                               if (!(srci = sr_config_info_get(opts[i] & SR_CONF_MASK)))
+                                       continue;
+                               printf("    %s\n", srci->name);
+                       }
+               }
+               g_variant_unref(gvar_opts);
+       }
+
+       if ((sr_config_list(driver, NULL, NULL, SR_CONF_SCAN_OPTIONS,
+                       &gvar_opts) == SR_OK)) {
+               opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
+                               sizeof(uint32_t));
+               if (num_elements) {
+                       printf("Scan options:\n");
+                       for (i = 0; i < num_elements; i++) {
+                               if (!(srci = sr_config_info_get(opts[i] & SR_CONF_MASK)))
+                                       continue;
+                               printf("    %s\n", srci->id);
+                       }
+               }
+               g_variant_unref(gvar_opts);
+       }
+}
+
 void show_dev_detail(void)
 {
+       struct sr_dev_driver *driver;
        struct sr_dev_inst *sdi;
        const struct sr_config_info *srci;
        struct sr_channel *ch;
@@ -212,6 +251,11 @@ void show_dev_detail(void)
        char *tmp_str, *s, c;
        const char **stropts;
 
+       if (parse_driver(opt_drv, &driver, NULL)) {
+               /* A driver was specified, report driver-wide options now. */
+               show_drv_detail(driver);
+       }
+
        if (!(devices = device_scan())) {
                g_critical("No devices found.");
                return;
@@ -233,19 +277,6 @@ void show_dev_detail(void)
                return;
        }
 
-       if ((sr_config_list(sdi->driver, NULL, NULL, SR_CONF_SCAN_OPTIONS,
-                       &gvar_opts) == SR_OK)) {
-               opts = g_variant_get_fixed_array(gvar_opts, &num_elements,
-                               sizeof(int32_t));
-               printf("Supported driver options:\n");
-               for (i = 0; i < num_elements; i++) {
-                       if (!(srci = sr_config_info_get(opts[i])))
-                               continue;
-                       printf("    %s\n", srci->id);
-               }
-               g_variant_unref(gvar_opts);
-       }
-
        /* Selected channels and channel group may affect which options are
         * returned, or which values for them. */
        select_channels(sdi);