fix: correct auto timesync and node ttlCnt mechanism for BERTEST mode
This commit is contained in:
@@ -261,26 +261,54 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
|||||||
}
|
}
|
||||||
return Status;
|
return Status;
|
||||||
#else
|
#else
|
||||||
|
NODE_ENTRY *node;
|
||||||
|
uint8_t nodeId = (L2_GetNodeType(instPtr) == L2_NODE_HEAD) ? 0x02 : 0x01;
|
||||||
|
node = L2_GetNodeById(instPtr->nodeList, nodeId);
|
||||||
|
if (node == NULL)
|
||||||
|
{
|
||||||
|
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||||
|
if (node == NULL)
|
||||||
|
{
|
||||||
|
DBG_ERROR("Failed to append new node [id: %" PRIu8 "]", nodeId);
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Reset node ttl
|
||||||
|
node->ttlCnt = 0;
|
||||||
|
|
||||||
// Calculate time deviation
|
// Calculate time deviation
|
||||||
Status = L2_GetTimeDeviation(instPtr, L2_GetLastFrameNum(instPtr), L2_GetLastSlotNum(instPtr), true, &(instPtr->log.timeDev));
|
uint32_t frameNum = L2_GetCurrentFrameNum(instPtr);
|
||||||
if (Status != SUCCESS)
|
uint32_t slotNum = L2_GetCurrentSlotNum(instPtr);
|
||||||
{
|
|
||||||
DBG_ERROR("Failed to compute time deviation.\n")
|
// //NOTE: Service frame length is 20ms with 5ms idle
|
||||||
return Status;
|
// if(slotNum < 5)
|
||||||
}
|
// {
|
||||||
// Implement a auto time sync.
|
// slotNum = L2_SLOTS_PER_FRAME - 5;
|
||||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
// frameNum = frameNum - 1;
|
||||||
{
|
// }
|
||||||
// Time sync.
|
// else
|
||||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
// {
|
||||||
}
|
// slotNum = slotNum / 5 * 5 - 5;
|
||||||
|
// }
|
||||||
|
// Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||||
|
// if (Status != SUCCESS)
|
||||||
|
// {
|
||||||
|
// DBG_ERROR("Failed to compute time deviation.\n")
|
||||||
|
// return Status;
|
||||||
|
// }
|
||||||
|
// // Implement a auto time sync.
|
||||||
|
// if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||||
|
// {
|
||||||
|
// // Time sync.
|
||||||
|
// L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||||
|
// }
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool L2_Service_PktCheck(L2_INST *instPtr, uint8_t *msg)
|
bool L2_Service_PktCheck(L2_INST *instPtr, uint8_t *msg)
|
||||||
{
|
{
|
||||||
size_t packLen = Phy_GetFrameLen(L2_L2frame2L1frame(L2_SVC_FRAME));
|
size_t packLen = Phy_GetFrameLen(L2_L2frame2L1frame(L2_SVC_FRAME)) & 0xFFFFFFFE;
|
||||||
uint32_t errorBits = 0;
|
uint32_t errorBits = 0;
|
||||||
for (int i = 0; i < packLen; i++)
|
for (int i = 0; i < packLen; i++)
|
||||||
{
|
{
|
||||||
@@ -433,4 +461,4 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @} LinkLayer_Service*/
|
/** @} LinkLayer_Service*/
|
||||||
/** @} LinkLayer*/
|
/** @} LinkLayer*/
|
||||||
|
|||||||
Reference in New Issue
Block a user