diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-05-26 12:53:20 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-05-26 12:53:20 +0300 |
commit | 285d492964eaa829603350a2bf0a9d9e05d64fa4 (patch) | |
tree | 9a47a63d0b56e5236a8c680acc8928744b15c05b | |
parent | 0ccbadc71be4ea7812236f099ea90180a0df424a (diff) |
Report CAN resyncs due to timeout and excessive jitter separately
-rw-r--r-- | src/Movement/StepTimer.cpp | 11 | ||||
-rw-r--r-- | src/Movement/StepTimer.h | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp index 72598a02..5fd0d366 100644 --- a/src/Movement/StepTimer.cpp +++ b/src/Movement/StepTimer.cpp @@ -43,7 +43,8 @@ int32_t StepTimer::peakPosJitter = 0; int32_t StepTimer::peakNegJitter = 0; uint32_t StepTimer::peakReceiveDelay = 0; volatile unsigned int StepTimer::syncCount = 0; -unsigned int StepTimer::numResyncs = 0; +unsigned int StepTimer::numJitterResyncs = 0; +unsigned int StepTimer::numTimeoutResyncs = 0; #endif @@ -253,7 +254,7 @@ void StepTimer::DisableTimerInterrupt() noexcept if (millis() - wls > MinSyncInterval) { syncCount = 0; - ++numResyncs; + ++numTimeoutResyncs; } } return syncCount == MaxSyncCount; @@ -310,7 +311,7 @@ void StepTimer::DisableTimerInterrupt() noexcept if ((uint32_t)labs(diff) > MaxSyncJitter && locSyncCount > 1) { syncCount = 0; - ++numResyncs; + ++numJitterResyncs; } else { @@ -513,9 +514,9 @@ extern "C" uint32_t StepTimerGetTimerTicks() noexcept // Remote diagnostics /*static*/ void StepTimer::Diagnostics(const StringRef& reply) noexcept { - reply.lcatf("Peak sync jitter %" PRIi32 "/%" PRIi32 ", peak Rx sync delay %" PRIu32 ", resyncs %u, ", peakNegJitter, peakPosJitter, peakReceiveDelay, numResyncs); + reply.lcatf("Peak sync jitter %" PRIi32 "/%" PRIi32 ", peak Rx sync delay %" PRIu32 ", resyncs %u/%u, ", peakNegJitter, peakPosJitter, peakReceiveDelay, numTimeoutResyncs, numJitterResyncs); peakNegJitter = peakPosJitter = 0; - numResyncs = 0; + numTimeoutResyncs = numJitterResyncs = 0; peakReceiveDelay = 0; StepTimer *pst = pendingList; diff --git a/src/Movement/StepTimer.h b/src/Movement/StepTimer.h index 19e00fc0..d3f3b550 100644 --- a/src/Movement/StepTimer.h +++ b/src/Movement/StepTimer.h @@ -86,7 +86,8 @@ public: static bool IsSynced() noexcept; static void Diagnostics(const StringRef& reply) noexcept; - static constexpr uint32_t MinSyncInterval = 1000; // maximum interval in milliseconds between sync messages for us to remain synced + static constexpr uint32_t MinSyncInterval = 2000; // maximum interval in milliseconds between sync messages for us to remain synced + // increased from 1000 because of workaround we added for bad Tx time stamps on SAME70 #endif #if STEP_TIMER_DEBUG @@ -116,7 +117,7 @@ private: static int32_t peakPosJitter, peakNegJitter; // the max and min corrections we made to local time offset while synced static uint32_t peakReceiveDelay; // the maximum receive delay we measured by using the receive time stamp static volatile unsigned int syncCount; // the number of messages we have received since starting sync - static unsigned int numResyncs; + static unsigned int numJitterResyncs, numTimeoutResyncs; static constexpr uint32_t MaxSyncJitter = StepClockRate/100; // 10ms static constexpr unsigned int MaxSyncCount = 10; |