diff --git a/datalink814_ge/src/linklayer/linklayer814.c b/datalink814_ge/src/linklayer/linklayer814.c index cfff0ed..9caf392 100644 --- a/datalink814_ge/src/linklayer/linklayer814.c +++ b/datalink814_ge/src/linklayer/linklayer814.c @@ -1263,16 +1263,16 @@ static int32_t Linklayer_Routine (L2_INST* instPtr) { uint32_t tableIndx, entryIndx; // FIXME: Consider time wrapping. - uint32_t currTime = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr)/L2_SLOTS_PER_FRAME; - if(currTime < instPtr->netStartTime) { - DBG_WARNING("Linklayer not start yet, current time unit: %u, start time unit: %u.\n", - currTime, instPtr->netStartTime); + uint32_t nextTimeUnit = (TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1)/L2_SLOTS_PER_FRAME; + if(nextTimeUnit < instPtr->netStartTime) { + DBG_WARNING("Linklayer not start yet, next time unit: %u, start time unit: %u.\n", + nextTimeUnit, instPtr->netStartTime); return EIGNORE; } // Determine which routine entry is going to be performed. - tableIndx = L2_GetCurrentFrameNum(instPtr) % instPtr->rtneConfig.rtnePrd; - entryIndx = L2_GetCurrentSlotNum(instPtr); + tableIndx = L2_GetNextFrameNum(instPtr) % instPtr->rtneConfig.rtnePrd; + entryIndx = L2_GetNextSlotNum(instPtr); L2_RTNE_TABLE_ENTRY rtneEntry = {0}; // Shift routine entry record.