bugfix: correct record shit mechanism.
This commit is contained in:
@@ -450,8 +450,9 @@ int32_t L2_SetupNextSlot(L2_INST* instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Update frame and tx/rx mode record.
|
// Update frame and tx/rx mode record.
|
||||||
instPtr->frame.next = frameType;
|
// Frame types shift (last <- curr <- next)
|
||||||
instPtr->tor.next = txrxMode;
|
L2_RcdShift(&(instPtr->frame), frameType);
|
||||||
|
L2_RcdShift(&(instPtr->tor), txrxMode);
|
||||||
|
|
||||||
TIME_WORD pullTime = {0, 0};
|
TIME_WORD pullTime = {0, 0};
|
||||||
pullTime.int_part = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1;
|
pullTime.int_part = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1;
|
||||||
@@ -1106,6 +1107,9 @@ int32_t Linklayer_Proc(L2_INST* instPtr) {
|
|||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update slot number.
|
||||||
|
L2_UpdateSlotNum(instPtr);
|
||||||
|
|
||||||
DBG_INFO("######## Current frameNum: %u, SlotNo: %u ########\n",
|
DBG_INFO("######## Current frameNum: %u, SlotNo: %u ########\n",
|
||||||
instPtr->frameNum.curr, instPtr->slotNum.curr);
|
instPtr->frameNum.curr, instPtr->slotNum.curr);
|
||||||
|
|
||||||
@@ -1140,13 +1144,6 @@ int32_t Linklayer_Proc(L2_INST* instPtr) {
|
|||||||
// Check and execute scheduled event.
|
// Check and execute scheduled event.
|
||||||
L2_EventPoolHandler(instPtr);
|
L2_EventPoolHandler(instPtr);
|
||||||
|
|
||||||
// Update slot number.
|
|
||||||
L2_UpdateSlotNum(instPtr);
|
|
||||||
|
|
||||||
// Frame types shift (last <- curr <- next)
|
|
||||||
L2_RcdShift(&(instPtr->frame), L2_NONE_FRAME);
|
|
||||||
L2_RcdShift(&(instPtr->tor), L2_TOR_SUSPEND);
|
|
||||||
|
|
||||||
// Update link layer state.
|
// Update link layer state.
|
||||||
instPtr->mainState = instPtr->nextState;
|
instPtr->mainState = instPtr->nextState;
|
||||||
|
|
||||||
|
|||||||
@@ -371,30 +371,33 @@ TEST(linklayer_master_routine) {
|
|||||||
for(int i = 0; i < 200*30; i++) {
|
for(int i = 0; i < 200*30; i++) {
|
||||||
tmcReg[TIME_INT_REG]++;
|
tmcReg[TIME_INT_REG]++;
|
||||||
|
|
||||||
if (L2_GetLastTor(linkInstPtr) == L2_TOR_TX)
|
if (L2_GetNextTor(linkInstPtr) == L2_TOR_TX)
|
||||||
{
|
{
|
||||||
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_TSYNC_FRAME)
|
if (L2_GetNextFrameType(linkInstPtr) == L2_INTRA_TSYNC_FRAME)
|
||||||
{
|
{
|
||||||
TimeCtrl_GetCurrentTime(tmcInstPtr, &timeStampA);
|
TimeCtrl_GetCurrentTime(tmcInstPtr, &timeStampA);
|
||||||
timeStampA.int_part--;
|
// ASSERT_EQUAL(linkInstPtr->rttFSM->rttRecord.Tt1.int_part + linkInstPtr->netStartTime*L2_SLOTS_PER_FRAME,
|
||||||
|
// timeStampA.int_part);
|
||||||
|
// ASSERT_EQUAL(linkInstPtr->rttFSM->rttRecord.Tt1.frac_part, timeStampA.frac_part);
|
||||||
timeStampA.frac_part = rand()%1000; // 10us deviation.
|
timeStampA.frac_part = rand()%1000; // 10us deviation.
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (L2_GetLastTor(linkInstPtr) == L2_TOR_RX)
|
if (L2_GetCurrentTor(linkInstPtr) == L2_TOR_RX)
|
||||||
{
|
{
|
||||||
if(L2_GetLastFrameType(linkInstPtr) == L2_INTRA_W2_ACQ_FRAME) {
|
if(L2_GetCurrentFrameType(linkInstPtr) == L2_INTRA_W2_ACQ_FRAME) {
|
||||||
forge_w2acq_frame((uint8_t*)phyInstPtr->recvDataAddr, L2_NODE_MEMBER, 2, 1, 1, -1, L2_INIT_STATE);
|
forge_w2acq_frame((uint8_t*)phyInstPtr->recvDataAddr, L2_NODE_MEMBER, 2, 1, 1, -1, L2_INIT_STATE);
|
||||||
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
||||||
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_W2ACQ_FRAME_LENGTH_MAX);
|
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_W2ACQ_FRAME_LENGTH_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_MGMT_FRAME)
|
if (L2_GetCurrentFrameType(linkInstPtr) == L2_INTRA_MGMT_FRAME)
|
||||||
{
|
{
|
||||||
forge_mgmt_frame((uint8_t*)phyInstPtr->recvDataAddr, L2_NORMAL_STATE);
|
forge_mgmt_frame((uint8_t*)phyInstPtr->recvDataAddr, L2_NORMAL_STATE);
|
||||||
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
||||||
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_MGMT_FRAME_LENGTH_MAX);
|
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_MGMT_FRAME_LENGTH_MAX);
|
||||||
}
|
}
|
||||||
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_TSYNC_FRAME)
|
if (L2_GetCurrentFrameType(linkInstPtr) == L2_INTRA_TSYNC_FRAME)
|
||||||
{
|
{
|
||||||
timeDiff = Phy_GetTimeComp(L2_L2frame2L1frame(L2_INTRA_TSYNC_FRAME)) + (rand()-RAND_MAX)%1000;
|
timeDiff = Phy_GetTimeComp(L2_L2frame2L1frame(L2_INTRA_TSYNC_FRAME)) + (rand()-RAND_MAX)%1000;
|
||||||
TimeCtrl_CalculateTimeGap(&timeStampA, &timeStampB, &timeGap);
|
TimeCtrl_CalculateTimeGap(&timeStampA, &timeStampB, &timeGap);
|
||||||
@@ -405,7 +408,7 @@ TEST(linklayer_master_routine) {
|
|||||||
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_MGMT_FRAME_LENGTH_MAX);
|
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_MGMT_FRAME_LENGTH_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_SVC_FRAME)
|
if (L2_GetCurrentFrameType(linkInstPtr) == L2_INTRA_SVC_FRAME)
|
||||||
{
|
{
|
||||||
forge_mgmt_frame((uint8_t*)phyInstPtr->recvDataAddr, L2_NORMAL_STATE);
|
forge_mgmt_frame((uint8_t*)phyInstPtr->recvDataAddr, L2_NORMAL_STATE);
|
||||||
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
||||||
|
|||||||
Reference in New Issue
Block a user