Date:2010-08-26 05:52:50 (9 years 20 days ago)
Author:Werner Almesberger
Commit:85ab2c41d56fa98fec44d1cb7bcd0fd086c639a7
Message:Picking time in the middle of the interval, not its edge, and reduce error bound.

- cntr/tools/cntr/cntr.c (measure): use the middle of a round-trip interval
for the sample's nominal time
- cntr/tools/cntr/cntr.c (measure): error bound is only +/- RTT/2, not
+/- RTT
Files: cntr/tools/cntr/cntr.c (2 diffs)

Change Details

cntr/tools/cntr/cntr.c
192192        usleep(100000);
193193        while (!get_sample(dev, &now));
194194        dc = now.cntr-start.cntr;
195        dt = now.t0-start.t0;
195        dt = (now.t0+now.t1)/2.0-(start.t0+start.t1)/2.0;
196196        f = dc/dt;
197197        if (f > 1000000.0) {
198198            f /= 1000000.0;
...... 
207207            error = 1.0/dc; /* one count */
208208        else
209209            error = 0;
210        error += (start.t1-start.t0)/dt;/* start sample read */
211        error += (now.t1-now.t0)/dt; /* last sample read */
212        error += clock_dev_s/dt; /* system clock deviation */
210        error += (start.t1-start.t0)/dt/2.0; /* start sample read */
211        error += (now.t1-now.t0)/dt/2.0; /* last sample read */
212        error += clock_dev_s/dt; /* system clock dev. */
213213        if (error >= 1) {
214214            printf("\r(wait) ");
215215            fflush(stdout);

Archive Download the corresponding diff file



interactive