Commit 98809a7e authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Change difference calculation with clock.

parent 032fdea3
Pipeline #100 passed with stage
......@@ -41,8 +41,9 @@ bool PrrtClock_update(PrrtClock *clock, uint32_t referenceTime, uint32_t rtt)
prrtTimestamp_t currentTime = PrrtClock_get_current_time_us();
prrtTimestamp_t virtualTime = clock->virtualTime;
int32_t clockSkew = clock->skew;
prrtTimestamp_t delay = rtt >> 1; // half the rtt
int32_t phaseError = referenceTime - virtualTime + delay;
prrtTimedelta_t delay = rtt /2; // half the rtt
int32_t phaseError = (int32_t) diff_ts(referenceTime, virtualTime) + delay;
//debug("Virtual Time: %u, Current Time: %u, Phase Error: %d, Delay: %u, Skew: %d", virtualTime, currentTime, phaseError, delay, clockSkew);
if(abs(phaseError) > 10000) {
clock->meanDeviation = 0;
......@@ -67,7 +68,7 @@ bool PrrtClock_update(PrrtClock *clock, uint32_t referenceTime, uint32_t rtt)
clock->lastMeasurement = currentTime;
clock->virtualTime = virtualTime;
debug("Current Time: %d; Virtual Time %d; Skew: %d", currentTime, virtualTime, clockSkew);
//debug("Current Time: %u; Virtual Time %u; Skew: %d; Mean Deviation: %u", currentTime, virtualTime, clockSkew, meanDeviation);
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment