]> sigrok.org Git - sigrok-cli.git/blobdiff - device.c
Use a non-recursive automake setup.
[sigrok-cli.git] / device.c
index 28184ce1e5451e732b410fa1ffc9eaefd1a0c456..b8709dc2bf0a7a4cca8eb559fdb21f34cc7ecf70 100644 (file)
--- a/device.c
+++ b/device.c
 #include "sigrok-cli.h"
 #include "config.h"
 #include <glib.h>
+#include <string.h>
 
 extern struct sr_context *sr_ctx;
 extern gchar *opt_drv;
-extern gchar *opt_probe_group;
+extern gchar *opt_channel_group;
 
 /* Convert driver options hash to GSList of struct sr_config. */
 static GSList *hash_to_hwopt(GHashTable *hash)
 {
-       const struct sr_config_info *srci;
        struct sr_config *src;
        GList *gl, *keys;
        GSList *opts;
-       char *key, *value;
+       char *key;
 
        keys = g_hash_table_get_keys(hash);
        opts = NULL;
        for (gl = keys; gl; gl = gl->next) {
                key = gl->data;
-               if (!(srci = sr_config_info_name_get(key))) {
-                       g_critical("Unknown option %s", key);
+               src = g_malloc(sizeof(struct sr_config));
+               if (opt_to_gvar(key, g_hash_table_lookup(hash, key), src) != 0)
                        return NULL;
-               }
-               src = g_try_malloc(sizeof(struct sr_config));
-               src->key = srci->key;
-               value = g_hash_table_lookup(hash, key);
-               src->data = g_variant_new_string(value);
                opts = g_slist_append(opts, src);
        }
        g_list_free(keys);
@@ -121,23 +116,23 @@ GSList *device_scan(void)
        return devices;
 }
 
-struct sr_probe_group *select_probe_group(struct sr_dev_inst *sdi)
+struct sr_channel_group *select_channel_group(struct sr_dev_inst *sdi)
 {
-       struct sr_probe_group *pg;
+       struct sr_channel_group *cg;
        GSList *l;
 
-       if (!opt_probe_group)
+       if (!opt_channel_group)
                return NULL;
 
-       if (!sdi->probe_groups) {
-               g_critical("This device does not have any probe groups.");
+       if (!sdi->channel_groups) {
+               g_critical("This device does not have any channel groups.");
                return NULL;
        }
 
-       for (l = sdi->probe_groups; l; l = l->next) {
-               pg = l->data;
-               if (!strcasecmp(opt_probe_group, pg->name)) {
-                       return pg;
+       for (l = sdi->channel_groups; l; l = l->next) {
+               cg = l->data;
+               if (!strcasecmp(opt_channel_group, cg->name)) {
+                       return cg;
                }
        }