*rewrite linklayer logging

This commit is contained in:
Gatsby Van
2024-01-31 19:44:20 +08:00
parent d2eee6548f
commit d310647fa6
@@ -385,54 +385,6 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
L2_DataAvailUpdate(instPtr, false);
}
}
// Logging status.
// -- send slot status
if (instPtr->tor.curr == L2_TOR_RX)
{
instPtr->rxSlotLog.tuNo = L2_GetCurrentFrameNum(instPtr);
instPtr->rxSlotLog.slotNo = L2_GetCurrentSlotNum(instPtr);
instPtr->rxSlotLog.frameType = recvType;
memset(instPtr->rxSlotLog.payload, 0x00, sizeof(instPtr->rxSlotLog.payload));
if (isValid == true)
{
memcpy(instPtr->rxSlotLog.payload,
instPtr->recvPktData,
Phy_GetFrameLen(L2_L2frame2L1frame(recvType)));
TIME_WORD timeWrod;
Phy_GetLastReceivedFrameSyncTimeStamp(phyRef, &timeWrod);
instPtr->rxSlotLog.tmStamp = timeWrod.frac_part;
instPtr->rxSlotLog.tmStamp += (uint64_t)timeWrod.int_part * TIME_FRAC_MAX;
// Log time deviation.
instPtr->txSlotLog.tmDevi = 0; // TODO:
// Log frequency deviation
instPtr->rxSlotLog.freqDevi = (uint32_t)Phy_GetFreqEst(phyRef);
}
else
{
instPtr->rxSlotLog.tmStamp = 0;
instPtr->rxSlotLog.tmDevi = 0;
instPtr->rxSlotLog.freqDevi = 0;
memset(instPtr->rxSlotLog.payload, 0x00, sizeof(instPtr->rxSlotLog.payload));
}
SysMonitor_UpdateRecvSlotLog(&(instPtr->rxSlotLog));
}
// -- send slot status
if (instPtr->tor.next == L2_TOR_TX)
{
instPtr->txSlotLog.tuNo = L2_GetCurrentFrameNum(instPtr);
instPtr->txSlotLog.slotNo = L2_GetCurrentSlotNum(instPtr);
instPtr->txSlotLog.frameType = sendType;
memset(instPtr->rxSlotLog.payload, 0x00, sizeof(instPtr->txSlotLog.payload));
memcpy(instPtr->txSlotLog.payload,
instPtr->sendPktData,
Phy_GetFrameLen(L2_L2frame2L1frame(sendType)));
instPtr->txSlotLog.tmStamp = 0;
instPtr->txSlotLog.tmDevi = 0;
instPtr->txSlotLog.freqDevi = 0;
SysMonitor_UpdateSendSlotLog(&(instPtr->txSlotLog));
}
}
/*****************************************************************************/
@@ -1276,25 +1228,32 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
// Check and execute scheduled event.
L2_EventPoolHandler(instPtr);
PHY_INST* phyRef = instPtr->config.phyInstPtr;
TMC_INST* tmcRef = instPtr->config.tmcInstPtr;
TIME_WORD timeWord;
// Update Protocol log
instPtr->prtcLog.tmSys = instPtr->frameNum.last * L2_SLOTS_PER_FRAME + instPtr->slotNum.last;
instPtr->prtcLog.phySt = 0; // TODO: Update physical state.
TimeCtrl_GetCurrentTime(tmcRef, &timeWord);
instPtr->prtcLog.tmLocal = timeWord.frac_part; // us
instPtr->prtcLog.tmLocal += (uint64_t)timeWord.int_part * TIME_FRAC_MAX; // us
instPtr->prtcLog.beamNo = phyRef->beamNo.last;
instPtr->prtcLog.beamNo = phyRef->beamWd.last;
instPtr->prtcLog.stage = instPtr->mainState;
instPtr->prtcLog.recvCnt = instPtr->log.frameRecv;
instPtr->prtcLog.recvCorrect = instPtr->log.frameCorrect;
SysMonitor_UpdateProtocolLog(&(instPtr->prtcLog));
// Update link layer state.
instPtr->mainState = instPtr->nextState;
instPtr->linkLog.tuNum = instPtr->frameNum.curr;
instPtr->linkLog.slotNum = (uint8_t)instPtr->slotNum.curr;
instPtr->linkLog.nodeType = (instPtr->config.myType == L2_NODE_HEAD) ? 0xAA : 0xCC;
instPtr->linkLog.cxnStatus = (instPtr->cxn2Net) ? 0x11 : 0x00;
instPtr->linkLog.linkStage = (instPtr->mainState == L2_INIT_STATE) ? 0x00 : 0x11;
// TODO:
// instPtr->linkLog.recxnCnt =
// instPtr->linkLog.beamNo =
// instPtr->linkLog.beamAz =
// instPtr->linkLog.beamEl =
instPtr->linkLog.advTxCnt = (uint16_t)instPtr->log.advTxCnt;
instPtr->linkLog.advRecvCnt = (uint16_t)instPtr->log.advRecvCnt;
instPtr->linkLog.advCorrectCnt = (uint16_t)instPtr->log.advCorrectCnt;
instPtr->linkLog.cfmTxCnt = instPtr->log.cfmTxCnt;
instPtr->linkLog.cfmRecvCnt = instPtr->log.cfmRecvCnt;
instPtr->linkLog.cfmCorrectCnt = instPtr->log.cfmCorrectCnt;
instPtr->linkLog.svcTxCnt = instPtr->log.svcTxCnt;
instPtr->linkLog.svcRecvCnt = instPtr->log.svcRecvCnt;
instPtr->linkLog.svcCorrectCnt = instPtr->log.svcCorrectCnt;
instPtr->linkLog.timeDev = instPtr->log.timeDev;
instPtr->linkLog.sendId = instPtr->serviceFSM->txLog.dataId;
instPtr->linkLog.recvId = instPtr->serviceFSM->rxLog.dataId;
SysMonitor_UpdateLinklayerLog(&(instPtr->linkLog));
return SUCCESS;
}