From: Bert Vermeulen Date: Sat, 8 Sep 2012 01:04:55 +0000 (+0200) Subject: cli: support for new output module API X-Git-Tag: sigrok-cli-0.4.0~79 X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=commitdiff_plain;h=05e7fa2cf0de4faba11929fa3f0f6848d11830d4 cli: support for new output module API --- diff --git a/sigrok-cli.c b/sigrok-cli.c index 1b96781..9ca28a3 100644 --- a/sigrok-cli.c +++ b/sigrok-cli.c @@ -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; + 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) @@ -593,6 +594,9 @@ static void datafeed_in(const struct sr_dev_inst *sdi, received_samples); if (outfile && outfile != stdout) fclose(outfile); + + if (o->format->cleanup) + o->format->cleanup(o); 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); } + 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.