From 1de453c92fdbf4d32064cb0cb04180b948acf904 Mon Sep 17 00:00:00 2001 From: Janez Date: Fri, 31 Jan 2020 12:25:22 +0100 Subject: [PATCH] Update CO_SYNC.c `*timerNext_us` added also to 'Verify timeout' --- stack/CO_SYNC.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stack/CO_SYNC.c b/stack/CO_SYNC.c index c299ef0..3de1f9f 100644 --- a/stack/CO_SYNC.c +++ b/stack/CO_SYNC.c @@ -363,8 +363,17 @@ uint8_t CO_SYNC_process( } /* Verify timeout of SYNC */ - if(SYNC->periodTime && SYNC->timer > SYNC->periodTimeoutTime && *SYNC->operatingState == CO_NMT_OPERATIONAL) - CO_errorReport(SYNC->em, CO_EM_SYNC_TIME_OUT, CO_EMC_COMMUNICATION, SYNC->timer); + if(SYNC->periodTime && *SYNC->operatingState == CO_NMT_OPERATIONAL) { + if(SYNC->timer > SYNC->periodTimeoutTime) { + CO_errorReport(SYNC->em, CO_EM_SYNC_TIME_OUT, CO_EMC_COMMUNICATION, SYNC->timer); + } + else if(timerNext_us != NULL) { + uint32_t diff = SYNC->periodTimeoutTime - SYNC->timer; + if(*timerNext_us > diff){ + *timerNext_us = diff; + } + } + } } else { CO_CANrxNew_CLEAR(SYNC->CANrxNew);