]> sigrok.org Git - sigrok-cli.git/commitdiff
cli: support for new output module API
authorBert Vermeulen <redacted>
Sat, 8 Sep 2012 01:04:55 +0000 (03:04 +0200)
committerBert Vermeulen <redacted>
Sat, 8 Sep 2012 01:04:55 +0000 (03:04 +0200)
sigrok-cli.c

index 1b967814508ed76d906a9474faecd75e84df9ae1..9ca28a310236b37008f7b6649b54500fb4affcdf 100644 (file)
@@ -545,6 +545,7 @@ static void datafeed_in(const struct sr_dev_inst *sdi,
        int num_enabled_probes, sample_size, ret, i;
        uint64_t output_len, filter_out_len;
        uint8_t *output_buf, *filter_out;
        int num_enabled_probes, sample_size, ret, i;
        uint64_t output_len, filter_out_len;
        uint8_t *output_buf, *filter_out;
+       GString *out;
 
        /* If the first packet to come in isn't a header, don't even try. */
        if (packet->type != SR_DF_HEADER && o == NULL)
 
        /* If the first packet to come in isn't a header, don't even try. */
        if (packet->type != SR_DF_HEADER && o == NULL)
@@ -593,6 +594,9 @@ static void datafeed_in(const struct sr_dev_inst *sdi,
                               received_samples);
                if (outfile && outfile != stdout)
                        fclose(outfile);
                               received_samples);
                if (outfile && outfile != stdout)
                        fclose(outfile);
+
+               if (o->format->cleanup)
+                       o->format->cleanup(o);
                g_free(o);
                o = NULL;
                break;
                g_free(o);
                o = NULL;
                break;
@@ -783,6 +787,14 @@ static void datafeed_in(const struct sr_dev_inst *sdi,
                g_message("received unknown packet type %d", packet->type);
        }
 
                g_message("received unknown packet type %d", packet->type);
        }
 
+       if (o && o->format->recv) {
+               out = o->format->recv(o, sdi, packet);
+               if (out && out->len) {
+                       fwrite(out->str, 1, out->len, outfile);
+                       fflush(outfile);
+               }
+       }
+
 }
 
 /* Register the given PDs for this session.
 }
 
 /* Register the given PDs for this session.