diff --git a/datalink814_ge/src/linklayer/linklayer814.c b/datalink814_ge/src/linklayer/linklayer814.c index a96daa9..d6a34e9 100644 --- a/datalink814_ge/src/linklayer/linklayer814.c +++ b/datalink814_ge/src/linklayer/linklayer814.c @@ -640,7 +640,7 @@ void L2_FrameStateUpdate(L2_INST* instPtr) { int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE frameType) { ASSERT(instPtr != NULL); PHY_INST* phyRef = instPtr->config.phyInstPtr; - int32_t Status = SUCCESS; + int32_t Status; if (frameType < L2_INTER_SCAN_FRAME || frameType > L2_INTRA_SVC_FRAME) { return FAILURE; } @@ -714,7 +714,7 @@ int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f if(Status != SUCCESS){ DBG_ERROR("Physical set pull time failed, with error code: %d\n", Status); } - + PHY_TOR_TYPE tor; switch(txrxMode) { case L2_TOR_SUSPEND: @@ -905,6 +905,12 @@ int32_t Linklayer_Init(L2_INST** instPtr, const L2_CONFIG *config) { (*instPtr)->isEnable = false; (*instPtr)->cxn2Net = false; (*instPtr)->dataAvail = false; + (*instPtr)->frameNum.last = 0; + (*instPtr)->frameNum.curr = 0; + (*instPtr)->frameNum.next = 0; + (*instPtr)->slotNum.last = 0; + (*instPtr)->slotNum.curr = 0; + (*instPtr)->slotNum.next = 0; (*instPtr)->frame.last = L2_NONE_FRAME; (*instPtr)->frame.curr = L2_NONE_FRAME; (*instPtr)->frame.next = L2_NONE_FRAME; @@ -915,15 +921,10 @@ int32_t Linklayer_Init(L2_INST** instPtr, const L2_CONFIG *config) { (*instPtr)->rtneConfig.rtnePrd = ARRAY_SIZE(initTable); (*instPtr)->mainState = INIT_STATE; (*instPtr)->nextState = INIT_STATE; - (*instPtr)->frameNum.last = 0; - (*instPtr)->frameNum.curr = 0; - (*instPtr)->frameNum.next = 0; - (*instPtr)->slotNum.last = 0; - (*instPtr)->slotNum.curr = 0; - (*instPtr)->slotNum.next = 0; - (*instPtr)->myInfo.nodeType = config->myType; (*instPtr)->myInfo.nodeId = config->myId; (*instPtr)->myInfo.clustId = config->clustId; + (*instPtr)->myInfo.headId = config->headId; + (*instPtr)->myInfo.nodeType = config->myType; (*instPtr)->myInfo.pos.x = 0; (*instPtr)->myInfo.pos.y = 0; (*instPtr)->myInfo.pos.z = 0; @@ -989,6 +990,12 @@ int32_t Linklayer_Reconfig(L2_INST* instPtr, const L2_CONFIG *config) { instPtr->rtneConfig.next = NULL; instPtr->cxn2Net = false; instPtr->dataAvail = false; + instPtr->frameNum.last = 0; + instPtr->frameNum.curr = 0; + instPtr->frameNum.next = 0; + instPtr->slotNum.last = 0; + instPtr->slotNum.curr = 0; + instPtr->slotNum.next = 0; instPtr->frame.last = L2_NONE_FRAME; instPtr->frame.curr = L2_NONE_FRAME; instPtr->frame.next = L2_NONE_FRAME; @@ -999,15 +1006,10 @@ int32_t Linklayer_Reconfig(L2_INST* instPtr, const L2_CONFIG *config) { instPtr->rtneConfig.rtnePrd = ARRAY_SIZE(initTable); instPtr->mainState = INIT_STATE; instPtr->nextState = INIT_STATE; - instPtr->frameNum.last = 0; - instPtr->frameNum.curr = 0; - instPtr->frameNum.next = 0; - instPtr->slotNum.last = 0; - instPtr->slotNum.curr = 0; - instPtr->slotNum.next = 0; - instPtr->myInfo.nodeType = config->myType; instPtr->myInfo.nodeId = config->myId; instPtr->myInfo.clustId = config->clustId; + instPtr->myInfo.headId = config->headId; + instPtr->myInfo.nodeType = config->myType; instPtr->myInfo.pos.x = 0; instPtr->myInfo.pos.y = 0; instPtr->myInfo.pos.z = 0; @@ -1103,7 +1105,7 @@ int32_t Linklayer_EventHandler(L2_INST* instPtr, const L2_EVENT* l2Event) { } case L2_EV_NET_SETUP_DONE: { DBG_INFO("Event L2_EV_NETSETUP_DONE asserted....\n"); - if(instPtr->myInfo.nodeType != HEAD_NODE){ + if(L2_GetNodeType(instPtr) != HEAD_NODE){ instPtr->cxn2Net = true; } else{ // Head node @@ -1121,7 +1123,7 @@ int32_t Linklayer_EventHandler(L2_INST* instPtr, const L2_EVENT* l2Event) { } case L2_EV_LOST_CXN: { DBG_INFO("Event L2_EV_LOST_CXN asserted....\n"); - DBG_WARNING("Lost connection with head node [%d].\n", instPtr->config.headId); + DBG_WARNING("Lost connection with head node [%d].\n", L2_GetHeadId(instPtr)); instPtr->cxn2Net = false; break; } @@ -1355,11 +1357,11 @@ int32_t Linklayer_Proc(L2_INST* instPtr) { // Handle frame received in last slot. if(L2_isDataAvail(instPtr) == true){ - Linklayer_PktHandler(instPtr, L2_GetLastRcvFrameType(instPtr)); + Linklayer_PktHandler(instPtr, L2_GetLastFrameType(instPtr)); } // Run Link layer routine, setup next slot procedure. - if (instPtr->myInfo.nodeType == HEAD_NODE) { + if (L2_GetNodeType(instPtr) == HEAD_NODE) { Phy_SetMode(instPtr->config.phyInstPtr, PHY_MODE_PULL); Status = Linklayer_Routine(instPtr); }