mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-12-22 23:04:36 +02:00
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
This commit is contained in:
parent
5b73e8bb75
commit
85ab2c41d5
@ -192,7 +192,7 @@ static void measure(usb_dev_handle *dev, double clock_dev_s, double error_goal)
|
||||
usleep(100000);
|
||||
while (!get_sample(dev, &now));
|
||||
dc = now.cntr-start.cntr;
|
||||
dt = now.t0-start.t0;
|
||||
dt = (now.t0+now.t1)/2.0-(start.t0+start.t1)/2.0;
|
||||
f = dc/dt;
|
||||
if (f > 1000000.0) {
|
||||
f /= 1000000.0;
|
||||
@ -207,9 +207,9 @@ static void measure(usb_dev_handle *dev, double clock_dev_s, double error_goal)
|
||||
error = 1.0/dc; /* one count */
|
||||
else
|
||||
error = 0;
|
||||
error += (start.t1-start.t0)/dt;/* start sample read */
|
||||
error += (now.t1-now.t0)/dt; /* last sample read */
|
||||
error += clock_dev_s/dt; /* system clock deviation */
|
||||
error += (start.t1-start.t0)/dt/2.0; /* start sample read */
|
||||
error += (now.t1-now.t0)/dt/2.0; /* last sample read */
|
||||
error += clock_dev_s/dt; /* system clock dev. */
|
||||
if (error >= 1) {
|
||||
printf("\r(wait) ");
|
||||
fflush(stdout);
|
||||
|
Loading…
Reference in New Issue
Block a user