]> sigrok.org Git - sigrok-cli.git/blobdiff - sigrok-cli.c
Merge branch 'master' of ssh://sigrok.org/data/git/sigrok-cli
[sigrok-cli.git] / sigrok-cli.c
index aeffeaa8d42f659aac62fde3d31d642e175cc138..d1544ac5867960f98bc2ccc791dad243918fed7b 100644 (file)
@@ -256,16 +256,16 @@ static void print_dev_line(const struct sr_dev_inst *sdi)
        if (sdi->probes) {
                if (g_slist_length(sdi->probes) == 1) {
                        probe = sdi->probes->data;
-                       printf("with 1 probe: %s\n", probe->name);
+                       printf("with 1 probe: %s", probe->name);
                } else {
-                       printf("with %d probes:\n", g_slist_length(sdi->probes));
+                       printf("with %d probes:", g_slist_length(sdi->probes));
                        for (l = sdi->probes; l; l = l->next) {
                                probe = l->data;
-                               printf("      %s\n", probe->name);
+                               printf(" %s", probe->name);
                        }
                }
-       } else
-               printf("\n");
+       }
+       printf("\n");
 }
 
 static void show_dev_list(void)
@@ -1062,31 +1062,23 @@ void show_pd_annotations(struct srd_proto_data *pdata, void *cb_data)
 
 static int select_probes(struct sr_dev_inst *sdi)
 {
-       char **probelist;
-       int max_probes, i;
+       struct sr_probe *probe;
+       GSList *selected_probes, *l;
 
        if (!opt_probes)
                return SR_OK;
 
-       /*
-        * This only works because a device by default initializes
-        * and enables all its probes.
-        */
-       max_probes = g_slist_length(sdi->probes);
-       probelist = parse_probestring(max_probes, opt_probes);
-       if (!probelist) {
+       if (!(selected_probes = parse_probestring(sdi, opt_probes)))
                return SR_ERR;
-       }
 
-       for (i = 0; i < max_probes; i++) {
-               if (probelist[i]) {
-                       sr_dev_probe_name_set(sdi, i, probelist[i]);
-                       g_free(probelist[i]);
-               } else {
-                       sr_dev_probe_enable(sdi, i, FALSE);
-               }
+       for (l = sdi->probes; l; l = l->next) {
+               probe = l->data;
+               if (g_slist_find(selected_probes, probe))
+                       probe->enabled = TRUE;
+               else
+                       probe->enabled = FALSE;
        }
-       g_free(probelist);
+       g_slist_free(selected_probes);
 
        return SR_OK;
 }