From b4584f8dc3b0e7209b7ff819de2991cb09f5a4af Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Sun, 10 Nov 2013 12:50:52 +0100 Subject: [PATCH] Show only one output type at the same time. OUTPUT_BINARY takes precedence if specified, and is always output 'raw', without extra information, so it can be piped into other programs. Otherwise, if specified, OUTPUT_META is shown. If none of these is specified, the default is to show OUTPUT_ANN (all classes) of the top PD in the stack. --- sigrok-cli.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sigrok-cli.c b/sigrok-cli.c index ac860e4..ac84e1d 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -2015,20 +2015,29 @@ int main(int argc, char **argv) } if (register_pds(NULL, opt_pds) != 0) goto done; - if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_ANN, - show_pd_annotations, NULL) != SRD_OK) - goto done; if (setup_pd_stack() != 0) goto done; - if (opt_pd_annotations) - if (setup_pd_annotations() != 0) + + /* Only one output type is ever shown. */ + if (opt_pd_binary) { + if (setup_pd_binary() != 0) + goto done; + if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_BINARY, + show_pd_binary, NULL) != SRD_OK) goto done; - if (opt_pd_meta) { + } else if (opt_pd_meta) { if (setup_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) + goto done; + if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_ANN, + show_pd_annotations, NULL) != SRD_OK) + goto done; } } #endif -- 2.30.2