X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=output%2Foutput_gnuplot.c;fp=output%2Foutput_gnuplot.c;h=dfa91eb78b39f8a8db1638cba7409bf497684572;hb=50959ddcdc455c930397fbc9f85c3a745ff45fda;hp=c3417c45173f8d5962878a862f890880838dddca;hpb=15f2d0c0f2e39bc4338b0781b581aced0fca8e0c;p=libsigrok.git diff --git a/output/output_gnuplot.c b/output/output_gnuplot.c index c3417c45..dfa91eb7 100644 --- a/output/output_gnuplot.c +++ b/output/output_gnuplot.c @@ -195,7 +195,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in, struct context *ctx; unsigned int max_linelen, outsize, p, curbit, i; uint64_t sample; - static uint64_t samplecount = 0; + static uint64_t samplecount = 0, old_sample = 0; char *outbuf, *c; if (!o) { @@ -243,8 +243,19 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in, } for (i = 0; i <= length_in - ctx->unitsize; i += ctx->unitsize) { + memcpy(&sample, data_in + i, ctx->unitsize); + /* + * Don't output the same samples multiple times. However, make + * sure to output at least the first and last sample. + */ + if (samplecount++ != 0 && sample == old_sample) { + if (i != (length_in - ctx->unitsize)) + continue; + } + old_sample = sample; + /* The first column is a counter (needed for gnuplot). */ c = outbuf + strlen(outbuf); sprintf(c, "%" PRIu64 "\t", samplecount++);