📄 cmdtest.c
字号:
art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);
if(configSetup.rangeLogging) {
fprintf(rangeLogFileHandle, "\n");
}
return(reasonFailMask);
}
A_UINT32 analyzeThroughputResults
(
A_UINT32 devNum,
A_UINT32 rateIndex,
A_UINT32 testMode,
A_UINT32 turbo,
A_BOOL remoteStats,
A_UINT16 antenna,
A_UINT32 testChannel,
A_CHAR *testString
)
{
// RX_STATS_STRUCT rStats;
RX_STATS_STRUCT rRateStats;
// TX_STATS_STRUCT tStats;
TX_STATS_STRUCT tRateStats;
A_UINT32 reasonFailMask = 0;
float tpThreshold;
A_INT32 rssiThreshold;
A_UINT16 antennaMaskOffset = 0;
A_UINT32 numPackets;
A_UINT32 missedPackets;
A_CHAR antString[10];
const A_CHAR *rateString;
char *modeStr[] = {"11a", "11g", "11b", "11o", "11t", "11u"};
A_UINT16 modeOffset = 0;
if(turbo == TURBO_ENABLE) {
modeOffset = 4;
}
if(antenna == DESC_ANT_B) {
//shift masks by 1 to get to the B antenna mask
antennaMaskOffset = 1;
strcpy(antString, "B");
}
else {
strcpy(antString, "A");
}
if((rateIndex > 7) || (testMode == MODE_11B)){
numPackets = testSetup.numPacketsTP_CCK;
}
else {
numPackets = testSetup.numPacketsTP;
}
rateString = DataRateShortStr[rateIndex];
switch(testMode) {
case MODE_11A:
tpThreshold = (float)testSetup.throughputThreshold11a;
switch(antenna) {
case DESC_ANT_A:
rssiThreshold = testSetup.rssiThreshold11a_antA;
break;
case DESC_ANT_B:
rssiThreshold = testSetup.rssiThreshold11a_antB;
break;
} //end switch antenna
break;
case MODE_11B:
tpThreshold = (float)testSetup.throughputThreshold11b;
rateString = DataRateShortStr_11b[rateIndex];
switch(antenna) {
case DESC_ANT_A:
rssiThreshold = testSetup.rssiThreshold11b_antA;
break;
case DESC_ANT_B:
rssiThreshold = testSetup.rssiThreshold11b_antB;
break;
} //end switch antenna
break;
case MODE_11G:
tpThreshold = (float)testSetup.throughputThreshold11g;
switch(antenna) {
case DESC_ANT_A:
rssiThreshold = testSetup.rssiThreshold11g_antA;
break;
case DESC_ANT_B:
rssiThreshold = testSetup.rssiThreshold11g_antB;
break;
} //end switch antenna
break;
} //end switch mode
memset(&rRateStats, 0, sizeof(RX_STATS_STRUCT));
memset(&tRateStats, 0, sizeof(TX_STATS_STRUCT));
// art_rxGetStats(devNum, 0, !remoteStats, &rStats);
// art_txGetStats(devNum, 0, remoteStats, &tStats);
//#################Get the rate related stats and print also
art_rxGetStats(devNum, DataRate[rateIndex], !remoteStats, &rRateStats);
art_txGetStats(devNum, DataRate[rateIndex], remoteStats, &tRateStats);
missedPackets = numPackets - (rRateStats.goodPackets + rRateStats.crcPackets);
uiPrintf("% 4d %6.2f % 4d % 4d % 4d % 4d",
tRateStats.goodPackets,
(float)tRateStats.newThroughput/1000,
rRateStats.goodPackets,
rRateStats.DataSigStrengthAvg,
rRateStats.crcPackets,
missedPackets);
if(configSetup.rangeLogging) {
fprintf(rangeLogFileHandle, " %s %d tput %s %s %s %c %c %s * %6.2f % 4d % 3d % 3d\n",
modeStr[testMode + modeOffset],
testChannel,
testString,
antString,
goldAntString,
testSetup.dutOrientation,
testSetup.apOrientation,
rateString,
(float)tRateStats.newThroughput/1000,
rRateStats.DataSigStrengthAvg,
rRateStats.crcPackets,
missedPackets);
printFooter();
}
if(tRateStats.goodPackets < testSetup.perTPThreshold) {
reasonFailMask |= MASK_THROUGHPUT_PER_ANTA << antennaMaskOffset;
}
if (rRateStats.DataSigStrengthAvg < rssiThreshold) {
reasonFailMask |= MASK_THROUGHPUT_RSSI_ANTA << antennaMaskOffset;
}
if ((float)tRateStats.newThroughput/1000 < tpThreshold) {
reasonFailMask |= MASK_THROUGHPUT_THRESH_ANTA << antennaMaskOffset;
}
return(reasonFailMask);
}
A_BOOL prepareRangeLogging
(
void
)
{
if(configSetup.rangeLogFile == "") {
uiPrintf("Error: No range Log file specified\n");
return FALSE;
}
rangeLogFileHandle = fopen(configSetup.rangeLogFile, "r+");
if (rangeLogFileHandle == NULL) {
//file may not exist
//uiPrintf("Trying to open a new file\n");
rangeLogFileHandle = fopen(configSetup.rangeLogFile, "w+");
}
else
{
//position file pointer at end of file
fseek(rangeLogFileHandle, 0, SEEK_END);
}
if (rangeLogFileHandle == NULL) {
uiPrintf("Unable to open file %s for logging\n", configSetup.rangeLogFile);
configSetup.rangeLogging = FALSE;
return FALSE;
}
//write the header to the file
fprintf(rangeLogFileHandle, "\n#==================================================\n");
fprintf(rangeLogFileHandle, "DATASET_BEGIN\n");
fprintf(rangeLogFileHandle, "#==================================================\n\n");
fprintf(rangeLogFileHandle, "HEADER_BEGIN\n");
fprintf(rangeLogFileHandle, " ap_id: %s\n", testSetup.apType);
fprintf(rangeLogFileHandle, " dut_id: %s\n", testSetup.dutType);
fprintf(rangeLogFileHandle, "HEADER_END\n\n");
fprintf(rangeLogFileHandle, "# mode ch type dir dut ap dut ap rate tput rssi crc miss\n");
fprintf(rangeLogFileHandle, "# ant ant ori or \n");
fprintf(rangeLogFileHandle, "# ent en \n");
fprintf(rangeLogFileHandle, "\nDATA_BEGIN\n\n");
return TRUE;
}
//print the footer then rewind file pointer to start of footer
A_BOOL printFooter
(
void
)
{
fpos_t pos; //mark the position of where the footer starts
if(!rangeLogFileHandle) {
uiPrintf("Error: range log file not opened\n");
return FALSE;
}
fgetpos(rangeLogFileHandle, &pos);
fprintf(rangeLogFileHandle, "\nDATA_END\n\n");
fprintf(rangeLogFileHandle, "DATASET_END\n");
fsetpos(rangeLogFileHandle, &pos);
return TRUE;
}
void dutSendWakeupCall
(
A_UINT32 devNum,
A_UINT32 testType,
A_UINT32 testChannel,
A_UINT32 testMode,
A_UINT32 turbo,
A_UINT16 goldAntenna,
A_UINT32 miscParam
)
{
// txDataSetup
A_UINT32 rate_mask = RATE_6; //0xff; // all rates
A_UINT32 num_tx_desc = 15; //2;
A_UINT32 tx_length = sizeof(TEST_INFO_STRUCT);
A_UINT32 retry = 0xf;
A_UINT32 broadcast = 0;
// rxDataSetup
A_UINT32 num_rx_desc = 100;
A_UINT32 rx_length = 100;
A_UINT32 enable_ppm = 0;
A_UINT32 compare = 0;
// txrxDataBegin
A_UINT32 start_timeout = 0; // no wait time for transmit
A_UINT32 complete_timeout = 5000;
A_UINT32 stats_mode = 0;
A_UINT16 ii=0;
A_UCHAR pattern[] = {0xaa, 0x55};
A_UINT32 channel = testSetup.sideChannel2G;
TEST_INFO_STRUCT testInfo;
A_UINT32 i;
#ifdef _DEBUG
uiPrintf("\n\nDUT send wakeup call to wakeup Golden Receiver");
#endif
art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);
if(configSetup.mode == MODE_11A){
channel = testSetup.sideChannel5G;
}
testInfo.channel = testChannel;
testInfo.numIterations = testSetup.numIterations;
testInfo.testType = testType;
testInfo.goldAntenna = goldAntenna;
testInfo.turbo = turbo;
if((testType == THROUGHPUT_UP_TEST)|| (testType == THROUGHPUT_DOWN_TEST)) {
testInfo.packetSize = testSetup.packetSizeTP;
testInfo.rateMask = miscParam;
if(configSetup.enableXR) {
testInfo.rateMask &= 0xf80ff;
}
else if(((swDeviceID & 0xff) < 0x0013) || (testMode != MODE_11G)) {
testInfo.rateMask &= 0xff;
}
if((testInfo.rateMask & 0xff00) || (testMode == MODE_11B)) {
testInfo.numPackets = testSetup.numPacketsTP_CCK;
}
else {
testInfo.numPackets = testSetup.numPacketsTP;
}
}
else {
testInfo.numPackets = testSetup.numPackets;
testInfo.rateMask = configSetup.rateMask;
testInfo.packetSize = testSetup.packetSize;
if(testMode == MODE_11B) {
testInfo.rateMask = testInfo.rateMask & 0xfd;
}
if(((swDeviceID & 0xff) < 0x0013) || (testMode != MODE_11G)) {
testInfo.rateMask &= 0xff;
}
}
testInfo.mode = testMode;
#if 0
uiPrintf("SNOOP: sending wakeup call \n");
uiPrintf("Num Iterations = %d\n", testInfo.numIterations);
uiPrintf("Num Packets = %d\n", testInfo.numPackets);
uiPrintf("Packet size = %d\n", testInfo.packetSize);
uiPrintf("Channel = %d\n", testInfo.channel);
uiPrintf("Test type = %d\n", testInfo.testType);
uiPrintf("Rate mask = %x\n", testInfo.rateMask);
uiPrintf("Mode = %d\n", testInfo.mode);
#endif //_DEBUG
for(i = 0; i < MAX_WAKEUP_ATTEMPTS; i++) {
art_resetDevice(devNum, dutStation, bssID, channel, configSetup.turbo);
art_txDataSetup(devNum, rate_mask, goldenStation, num_tx_desc, tx_length,
(A_UCHAR *)&testInfo, sizeof(TEST_INFO_STRUCT), retry,configSetup.antenna, broadcast);
art_setAntenna(devNum, configSetup.antenna);
if(configSetup.enableXR) {
art_txDataBegin(devNum, complete_timeout, 0);
}
else {
art_rxDataSetup(devNum, num_rx_desc, rx_length, enable_ppm);
art_txrxDataBegin(devNum, start_timeout, complete_timeout, stats_mode, compare, pattern, 2);
}
if(art_mdkErrNo==0) {
#ifdef _DEBUG
uiPrintf("\nGolden Unit is awake now!\n");
#endif
break;
}
// Sleep(100);
}
while(kbhit())
getch(); // clean up buffer
if(i == MAX_WAKEUP_ATTEMPTS) {
uiPrintf("Given up trying to wakeup golden unit. Exiting...\n");
exit(0);
}
}
void goldenWait4WakeupCall
(
A_UINT32 devNum,
TEST_INFO_STRUCT *pTestInfo //for return
)
{
A_UINT32 rate_mask = RATE_6;
A_UINT32 turbo = 0;
A_UINT32 num_tx_desc = 2;
A_UINT32 tx_length = 100;
A_UINT32 retry = 5; // broadcast mode, disable retry
A_UINT32 antenna = USE_DESC_ANT | DESC_ANT_A;
A_UINT32 broadcast = 0; // disable broadcast mode
// for rx
A_UINT32 num_rx_desc = 1000;
A_UINT32 rx_length = sizeof(TEST_INFO_STRUCT);
A_UINT32 enable_ppm = 0;
// for rxDataBegin
A_UINT32 start_timeout = 30000; //100;
A_UINT32 complete_timeout = 10000;
A_UINT32 stats_mode = 0; //ENABLE_STATS_SEND | ENABLE_STATS_RECEIVE;
A_UINT32 compare = 0;
A_UCHAR pattern[] = {0xaa, 0x55};
A_UINT32 channel = testSetup.sideChannel2G;
A_UCHAR buffer[500];
A_UINT16 *mdkPacketType;
// uiPrintf("\nWaiting for transmitter to ring the bell ...\n");
if(configSetup.mode == MODE_11A){
channel = testSetup.sideChannel5G;
}
art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);
while(!kbhit()) {
art_resetDevice(devNum, goldenStation, bssID, channel, configSetup.turbo);
art_mdkErrNo=0;
art_setAntenna(devNum, configSetup.antenna);
art_rxDataSetup(devNum, num_rx_desc, rx_length, enable_ppm);
art_rxDataBegin(devNum, start_timeout, complete_timeout, stats_mode, compare, pattern, 2);
// Sleep(100);
if (art_mdkErrNo==0) {
#ifdef _DEBUG
uiPrintf("\nReceived wakeup by DUT, setting up for test\n");
#endif
//extract the info from the packet
art_rxGetData(devNum, 0, buffer, rx_length + MDK_PACKET_OVERHEAD);
memcpy(pTestInfo, buffer + MDK_PACKET_OVERHEAD, sizeof(TEST_INFO_STRUCT));
//SNOOP
// tempPtr = (A_UINT32 *)buffer;
// for(i = 0; i < 16; i++, tempPtr++) {
// uiPrintf("%x ", *tempPtr);
// }
// uiPrintf("\n");
//end snoop
mdkPacketType = (A_UINT16 *)(buffer + sizeof(WLAN_DATA_MAC_HEADER3));
if(*mdkPacketType != MDK_NORMAL_PKT) {
//this is not the correct packet, so go back to waiting
uiPrintf("SNOOP: handshake is not normal packet\n");
continue;
}
break;
}
}
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -