]> sigrok.org Git - sigrok-cli.git/blobdiff - sigrok-cli.c
Fix issue with optional PD probes.
[sigrok-cli.git] / sigrok-cli.c
index 6dbc373c6e90521ab8d4153e8ce64dd16b156e72..8521b9546128d17ff2c4f5fa5cae259d7d41d1a8 100644 (file)
@@ -252,6 +252,7 @@ static void show_version(void)
        outputs = sr_output_list();
        for (i = 0; outputs[i]; i++)
                printf("  %-20s %s\n", outputs[i]->id, outputs[i]->description);
+       printf("  %-20s %s\n", "sigrok", "Default file output format");
        printf("\n");
 
 #ifdef HAVE_SRD
@@ -943,7 +944,7 @@ static void datafeed_in(const struct sr_dev_inst *sdi,
                if (outfile && outfile != stdout)
                        fclose(outfile);
 
-               if (opt_output_file && default_output_format) {
+               if (opt_output_file && default_output_format && savebuf->len) {
                        if (sr_session_save(opt_output_file, sdi, savebuf->data,
                                        unitsize, savebuf->len / unitsize) != SR_OK)
                                g_critical("Failed to save session.");
@@ -1013,7 +1014,7 @@ static int probes_to_gvar(struct srd_decoder *dec, GHashTable *hash,
                        (GDestroyNotify)g_variant_unref);
 
        all_probes = g_slist_copy(dec->probes);
-       all_probes = g_slist_concat(all_probes, dec->opt_probes);
+       all_probes = g_slist_concat(all_probes, g_slist_copy(dec->opt_probes));
        for (l = all_probes; l; l = l->next) {
                p = l->data;
                if (!(val_str = g_hash_table_lookup(hash, p->id)))
@@ -1268,6 +1269,13 @@ int setup_output_format(void)
        int i;
        char *fmtspec;
 
+       if (opt_output_format && !strcmp(opt_output_format, "sigrok")) {
+               /* Doesn't really exist as an output module - this is
+                * the session save mode. */
+               g_free(opt_output_format);
+               opt_output_format = NULL;
+       }
+
        if (!opt_output_format) {
                opt_output_format = DEFAULT_OUTPUT_FORMAT;
                /* we'll need to remember this so when saving to a file
@@ -1741,6 +1749,7 @@ static void run_session(void)
        if (opt_continuous)
                clear_anykey();
 
+       sr_session_datafeed_callback_remove_all();
        sr_session_destroy();
        g_slist_free(devices);