Fix saving to session file.
[sigrok-cli.git] / input.c
diff --git a/input.c b/input.c
index 4d3f358ab1316abafee71587085de4a3e83615eb..566fd1d55dcf6b2f838f3de8b2f19b3db0245d46 100644 (file)
--- a/input.c
+++ b/input.c
@@ -27,7 +27,7 @@
 
 extern gchar *opt_input_file;
 extern gchar *opt_input_format;
-extern gchar *opt_probes;
+extern gchar *opt_channels;
 
 
 /**
@@ -131,7 +131,7 @@ static void load_input_file_format(void)
                }
        }
 
-       if (select_probes(in->sdi) > 0)
+       if (select_channels(in->sdi) != SR_OK)
                return;
 
        sr_session_new();
@@ -152,9 +152,23 @@ static void load_input_file_format(void)
 
 void load_input_file(void)
 {
+       GSList *sessions;
+       struct sr_dev_inst *sdi;
+       int ret;
 
        if (sr_session_load(opt_input_file) == SR_OK) {
                /* sigrok session file */
+               ret = sr_session_dev_list(&sessions);
+               if (ret != SR_OK || !sessions->data) {
+                       g_critical("Failed to access session device.");
+                       sr_session_destroy();
+                       return;
+               }
+               sdi = sessions->data;
+               if (select_channels(sdi) != SR_OK) {
+                       sr_session_destroy();
+                       return;
+               }
                sr_session_datafeed_callback_add(datafeed_in, NULL);
                sr_session_start();
                sr_session_run();
@@ -165,4 +179,3 @@ void load_input_file(void)
                load_input_file_format();
        }
 }
-