X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=main.c;h=271d28a99271f6c61f77570e897fe45aee32b1d4;hp=50826a5f31c2a51625e8d96823c1e2e7ac068dc6;hb=dd2f206a287e1b13abf4307c940f874668d30113;hpb=2be182e6437fb082aedca653fdc106d702518db0
diff --git a/main.c b/main.c
index 50826a5..271d28a 100644
--- a/main.c
+++ b/main.c
@@ -17,13 +17,10 @@
* along with this program. If not, see .
*/
+#include "sigrok-cli.h"
#include "config.h"
+#include
#include
-#include
-#ifdef HAVE_SRD
-#include /* First, so we avoid a _POSIX_C_SOURCE warning. */
-#endif
-#include "sigrok-cli.h"
struct sr_context *sr_ctx = NULL;
#ifdef HAVE_SRD
@@ -43,10 +40,10 @@ gchar *opt_probe_group = NULL;
gchar *opt_triggers = NULL;
gchar *opt_pds = NULL;
#ifdef HAVE_SRD
-gchar *opt_pd_stack = NULL;
-gchar *opt_pd_annotations = NULL;
-gchar *opt_pd_meta = NULL;
-gchar *opt_pd_binary = NULL;
+static gchar *opt_pd_stack = NULL;
+static gchar *opt_pd_annotations = NULL;
+static gchar *opt_pd_meta = NULL;
+static gchar *opt_pd_binary = NULL;
#endif
gchar *opt_input_format = NULL;
gchar *opt_output_format = NULL;
@@ -137,21 +134,22 @@ int select_probes(struct sr_dev_inst *sdi)
struct sr_probe *probe;
GSList *selected_probes, *l;
- if (!opt_probes)
- return SR_OK;
-
- if (!(selected_probes = parse_probestring(sdi, opt_probes)))
- return SR_ERR;
+ if (opt_probes) {
+ if (!(selected_probes = parse_probestring(sdi, opt_probes)))
+ return SR_ERR;
- 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;
+ 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_slist_free(selected_probes);
}
- g_slist_free(selected_probes);
-
+#ifdef HAVE_SRD
+ map_pd_probes(sdi);
+#endif
return SR_OK;
}
@@ -226,27 +224,27 @@ int main(int argc, char **argv)
g_critical("Failed to create new decode session.");
goto done;
}
- if (register_pds(opt_pds) != 0)
+ if (register_pds(opt_pds, opt_pd_annotations) != 0)
goto done;
- if (setup_pd_stack() != 0)
+ if (setup_pd_stack(opt_pds, opt_pd_stack, opt_pd_annotations) != 0)
goto done;
/* Only one output type is ever shown. */
if (opt_pd_binary) {
- if (setup_pd_binary() != 0)
+ if (setup_pd_binary(opt_pd_binary) != 0)
goto done;
if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_BINARY,
show_pd_binary, NULL) != SRD_OK)
goto done;
} else if (opt_pd_meta) {
- if (setup_pd_meta() != 0)
+ if (setup_pd_meta(opt_pd_meta) != 0)
goto done;
if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_META,
show_pd_meta, NULL) != SRD_OK)
goto done;
} else {
if (opt_pd_annotations)
- if (setup_pd_annotations() != 0)
+ if (setup_pd_annotations(opt_pd_annotations) != 0)
goto done;
if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_ANN,
show_pd_annotations, NULL) != SRD_OK)