]> sigrok.org Git - sigrok-cli.git/blobdiff - main.c
main: terminate with error when -B was specified but -P is missing
[sigrok-cli.git] / main.c
diff --git a/main.c b/main.c
index c038b6f02697dfc73a330460a66e180fe2a640e1..02f69a2ebbb5d998bf609844b01c488a525c613b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -136,7 +136,7 @@ static void get_option(void)
                return;
        }
 
-       cg = select_channel_group(sdi);
+       cg = lookup_channel_group(sdi);
        if (!(ci = sr_key_info_name_get(SR_KEY_CONFIG, opt_get)))
                g_critical("Unknown option '%s'", opt_get);
 
@@ -224,6 +224,11 @@ int main(int argc, char **argv)
                goto done;
 
 #ifdef HAVE_SRD
+       if (opt_pd_binary && !opt_pds) {
+               g_critical("Option -B will not take effect in the absence of -P.");
+               goto done;
+       }
+
        /* Set the loglevel (amount of messages to output) for libsigrokdecode. */
        if (srd_log_loglevel_set(opt_loglevel) != SRD_OK)
                goto done;
@@ -242,6 +247,8 @@ int main(int argc, char **argv)
                if (opt_pd_binary) {
                        if (setup_pd_binary(opt_pd_binary) != 0)
                                goto done;
+                       if (setup_binary_stdout() != 0)
+                               goto done;
                        if (srd_pd_output_callback_add(srd_sess, SRD_OUTPUT_BINARY,
                                        show_pd_binary, NULL) != SRD_OK)
                                goto done;
@@ -259,6 +266,7 @@ int main(int argc, char **argv)
                                        show_pd_annotations, NULL) != SRD_OK)
                                goto done;
                }
+               show_pd_prepare();
        }
 #endif
 
@@ -266,6 +274,10 @@ int main(int argc, char **argv)
                show_version();
        else if (opt_list_supported)
                show_supported();
+       else if (opt_list_supported_wiki)
+               show_supported_wiki();
+       else if (opt_input_file && opt_show)
+               load_input_file(TRUE);
        else if (opt_input_format && opt_show)
                show_input();
        else if (opt_output_format && opt_show)
@@ -281,17 +293,21 @@ int main(int argc, char **argv)
        else if (opt_show)
                show_dev_detail();
        else if (opt_input_file)
-               load_input_file();
+               load_input_file(FALSE);
        else if (opt_get)
                get_option();
        else if (opt_set)
                set_options();
        else if (opt_samples || opt_time || opt_frames || opt_continuous)
                run_session();
+       else if (opt_list_serial)
+               show_serial_ports();
        else
                show_help();
 
 #ifdef HAVE_SRD
+       if (opt_pds)
+               show_pd_close();
        if (opt_pds)
                srd_exit();
 #endif