add rtt test.
This commit is contained in:
@@ -96,7 +96,7 @@ uint8_t mgmtTemplate[INTRA_MGMT_FRAME_LENGTH_MAX] __attribute__ ((aligned (8)))
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
uint8_t rttReqTemplate[INTRA_RTT_FRAME_LENGTH_MAX] __attribute__ ((aligned (8))) = {
|
uint8_t rttTemplate[INTRA_RTT_FRAME_LENGTH_MAX] __attribute__ ((aligned (8))) = {
|
||||||
0xDC, 0xA3, 0x10, 0x44, 0x98, 0x99, 0x99, 0x99,
|
0xDC, 0xA3, 0x10, 0x44, 0x98, 0x99, 0x99, 0x99,
|
||||||
0x99, 0x05, 0x00, 0x00, 0x00, 0x50, 0x32, 0x01,
|
0x99, 0x05, 0x00, 0x00, 0x00, 0x50, 0x32, 0x01,
|
||||||
0x00, 0x90, 0x99, 0xFF, 0xFF, 0xFF, 0x99, 0x99,
|
0x00, 0x90, 0x99, 0xFF, 0xFF, 0xFF, 0x99, 0x99,
|
||||||
@@ -130,9 +130,6 @@ uint8_t rttReqTemplate[INTRA_RTT_FRAME_LENGTH_MAX] __attribute__ ((aligned (8)))
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
uint8_t rttRspTemplate[INTRA_RTT_FRAME_LENGTH_MAX] __attribute__ ((aligned (8))) = {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
uint8_t svcTemplate[INTRA_SVC_FRAME_LENGTH_MAX] __attribute__ ((aligned (8))) = {
|
uint8_t svcTemplate[INTRA_SVC_FRAME_LENGTH_MAX] __attribute__ ((aligned (8))) = {
|
||||||
0xF0, 0xFF, 0x00, 0x21, 0x88, 0x00, 0x00, 0xF0,
|
0xF0, 0xFF, 0x00, 0x21, 0x88, 0x00, 0x00, 0xF0,
|
||||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x56, 0x00, 0x00,
|
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0x56, 0x00, 0x00,
|
||||||
@@ -165,7 +162,7 @@ uint8_t svcTemplate[INTRA_SVC_FRAME_LENGTH_MAX] __attribute__ ((aligned (8))) =
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0xB5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -332,25 +329,58 @@ void forge_mgmt_frame(uint8_t* buff, L2_NODE_STATE state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void forge_rtt_frame(uint8_t* buff) {
|
void forge_rtt_frame(uint8_t* buff, uint16_t srcId, uint16_t destId,
|
||||||
// BIT_ARRAY bitarr = {
|
uint16_t clustId, const TIME_WORD* timeStamp, uint32_t doppler) {
|
||||||
// .words = (uint64_t*)buff,
|
BIT_ARRAY bitarr = {
|
||||||
// .num_of_bits = INTRA_BM_FRAME_LENGTH_MAX*8,
|
.words = (uint64_t*)buff,
|
||||||
// .num_of_words = roundup_bits2words64(INTRA_BM_FRAME_LENGTH_MAX*8),
|
.num_of_bits = INTRA_BM_FRAME_LENGTH_MAX*8,
|
||||||
// .capacity_in_words = roundup_bits2words64(INTRA_BM_FRAME_LENGTH_MAX*8),
|
.num_of_words = roundup_bits2words64(INTRA_BM_FRAME_LENGTH_MAX*8),
|
||||||
// };
|
.capacity_in_words = roundup_bits2words64(INTRA_BM_FRAME_LENGTH_MAX*8),
|
||||||
memcpy(buff, rttReqTemplate, INTRA_BM_FRAME_LENGTH_MAX);
|
};
|
||||||
|
memcpy(buff, rttTemplate, INTRA_BM_FRAME_LENGTH_MAX);
|
||||||
|
uint64_t dataChunk;
|
||||||
|
// INIT MSG
|
||||||
|
// --source node address.
|
||||||
|
dataChunk = (srcId & 0x001F) | ((clustId & 0x001F) << 5);
|
||||||
|
FrameInsertChunk(&bitarr, RTT_REQ_SRC_ADDR_OFFSET, RTT_REQ_SRC_ADDR_LEN, dataChunk);
|
||||||
|
// --destination node address.
|
||||||
|
dataChunk = (destId & 0x001F) | ((clustId & 0x001F) << 5);
|
||||||
|
FrameInsertChunk(&bitarr, RTT_REQ_DST_ADDR_OFFSET, RTT_REQ_DST_ADDR_LEN, dataChunk);
|
||||||
|
|
||||||
|
// EXTD MSG
|
||||||
|
// --Time tag Low
|
||||||
|
dataChunk = timeStamp->frac_part;
|
||||||
|
FrameInsertChunk(&bitarr, RTT_RSP_EX_TTAGL_OFFSET + RTT_MSG_LEN, RTT_RSP_EX_TTAGL_LEN, dataChunk);
|
||||||
|
// --Time tag High.
|
||||||
|
dataChunk = timeStamp->int_part;
|
||||||
|
FrameInsertChunk(&bitarr, RTT_RSP_EX_TTAGH_OFFSET + RTT_MSG_LEN, RTT_RSP_EX_TTAGH_LEN, dataChunk);
|
||||||
|
|
||||||
|
// CONT MSG
|
||||||
|
// -- Doppler
|
||||||
|
dataChunk = doppler;
|
||||||
|
FrameInsertChunk(&bitarr, RTT_RSP_CONT_DOP_OFFSET + RTT_MSG_LEN * 2, RTT_RSP_CONT_DOP_LEN, dataChunk);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(linklayer_master_routine) {
|
TEST(linklayer_master_routine) {
|
||||||
int32_t Status;
|
int32_t Status;
|
||||||
Linklayer_Start(linkInstPtr);
|
Linklayer_Start(linkInstPtr);
|
||||||
|
TIME_WORD timeStampA, timeStampB, timeGap;
|
||||||
|
uint32_t timeDiff;
|
||||||
// 30 seconds
|
// 30 seconds
|
||||||
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_RX && rand() < (RAND_MAX*0.8))
|
if (L2_GetLastTor(linkInstPtr) == L2_TOR_TX)
|
||||||
|
{
|
||||||
|
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_TSYNC_FRAME)
|
||||||
|
{
|
||||||
|
TimeCtrl_GetCurrentTime(tmcInstPtr, &timeStampA);
|
||||||
|
timeStampA.int_part--;
|
||||||
|
timeStampA.frac_part = rand()%1000; // 10us deviation.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (L2_GetLastTor(linkInstPtr) == L2_TOR_RX)
|
||||||
{
|
{
|
||||||
if(L2_GetLastFrameType(linkInstPtr) == L2_INTRA_W2_ACQ_FRAME) {
|
if(L2_GetLastFrameType(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);
|
||||||
@@ -364,6 +394,16 @@ TEST(linklayer_master_routine) {
|
|||||||
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)
|
||||||
|
{
|
||||||
|
timeDiff = Phy_GetTimeComp(L2_L2frame2L1frame(L2_INTRA_TSYNC_FRAME)) + (rand()-RAND_MAX)%1000;
|
||||||
|
TimeCtrl_CalculateTimeGap(&timeStampA, &timeStampB, &timeGap);
|
||||||
|
forge_rtt_frame((uint8_t*)phyInstPtr->recvDataAddr, 2, 1, 1, &timeGap , rand()%200000);
|
||||||
|
PhyWrite(phyInstPtr, TXRX_STATE, 0x01010101);
|
||||||
|
PhyWrite(phyInstPtr, FSTIME_H, L2_GetLastFrameNum(linkInstPtr));
|
||||||
|
PhyWrite(phyInstPtr, FSTIME_L, timeDiff);
|
||||||
|
PhyWrite(phyInstPtr, RECVDATA_STATE, INTRA_MGMT_FRAME_LENGTH_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_SVC_FRAME)
|
if (L2_GetLastFrameType(linkInstPtr) == L2_INTRA_SVC_FRAME)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user