⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdtest.c

📁 Atheros AP Test with Agilent N4010A source code
💻 C
📖 第 1 页 / 共 5 页
字号:
			//do nothing here
			break;
	
		default:
			uiPrintf("Fatal Error: Illegal TestType, should be trapped before this\n");
			return;
		}

		for(i = 0; i < testInfo.numIterations; i++) {
			switch(testInfo.testType) {
			//perform/complete transmit test. complete receive test here
			case TRANSMIT_TEST:		
				if(testInfo.rateMask > 0xff) {
					numRates = 15;
				}
				else {
					numRates = 8;
				}

				art_rxDataSetup(devNum, (testInfo.numPackets * numRates) + 40, testInfo.packetSize, enablePPM);
				art_rxDataStart(devNum);
				art_rxDataComplete(devNum, waitTime, timeOut, stats_mode, 0, pattern, 2);
				if (art_mdkErrNo!=0) {
					uiPrintf("Error: unable to receive packets from DUT\n");
				}
				break;
			case RECEIVE_TEST:
				Sleep(2000);
				art_resetDevice(devNum, goldenStation, bssID, testInfo.channel, testInfo.turbo);
				
				//set power if needed
				forcePowerOrPcdac(devNum);

				art_txDataSetup(devNum, testInfo.rateMask, dutStation, 
					testInfo.numPackets, testInfo.packetSize, pattern, 2, 0, configSetup.antenna, 0);
				art_txDataBegin(devNum, timeOut, 0);			
				if (art_mdkErrNo!=0) {
					uiPrintf("Transmit Iteration Failed - error %d\n", art_mdkErrNo);
					continue;
				}
				break;
			case THROUGHPUT_UP_TEST:		
//				Sleep(1000);
				//calculate how many rates
				rateMask = 0x80000;
				numRates = 0;
				while(rateMask) {
					if(rateMask & testInfo.rateMask) {
						numRates++;
					}
					rateMask >>= 1;
				}
				art_rxDataSetup(devNum, (testInfo.numPackets * numRates) + 40, testInfo.packetSize, 0);
				art_rxDataStart(devNum);
				art_rxDataComplete(devNum, waitTime, timeOut, stats_mode, 0, pattern, 2);
				if (art_mdkErrNo!=0) {
					uiPrintf("Error: unable to receive packets from DUT\n");
				}
//				Sleep(200);
				break;
			case THROUGHPUT_DOWN_TEST:		
				Sleep(2000);	// delay between packet sends
				art_resetDevice(devNum, goldenStation, bssID, testInfo.channel, testInfo.turbo);

				//set power if needed
				forcePowerOrPcdac(devNum);

				art_txDataSetup(devNum, testInfo.rateMask | RATE_GROUP, dutStation, 
					testInfo.numPackets, testInfo.packetSize, pattern, 2, 0, configSetup.antenna, 0);
				art_txDataBegin(devNum, timeOut, ENABLE_STATS_SEND);				
//				Sleep(200);
				break;
			}
			//cleanup descriptor queues, to free up mem
			art_cleanupTxRxMemory(devNum, TX_CLEAN | RX_CLEAN);

		} //end for numIterations
		//restore the mode and antenna back to default
		art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);		
		configSetup.antenna = origAntenna;

		//revert back to target power, in case DUT turns it back off in next test.
		configSetup.useTargetPower = 1;

	} //end while !kbhit

    while (kbhit())	{	// clean up the buffer
        getch();
    }
}

A_UINT32 transmitTest
(
 A_UINT32 devNum,
 A_UINT32 testChannel,
 A_UINT32 testMode,
 A_UINT32 turbo,
 A_UINT16 antenna,
 A_UINT16 goldAntenna
)
{
	// rxDataSetup
	A_UINT32 num_rx_desc = 50;
	A_UINT32 rx_length = 100;
	A_UINT32 enable_ppm = 0;
	A_UINT32 stats_mode =  ENABLE_STATS_RECEIVE; 

	// txrxDataBegin
	A_UINT32 start_timeout = 0;	// no wait time for transmit
	A_UINT32 complete_timeout = 10000;
	A_UINT32 compare = 0;
	A_UCHAR  pattern[] = {0xaa, 0x55};
	A_UINT32 broadcast = 1;
	
	A_UINT32 i;
	A_UINT32 reasonFailMask = 0;
	A_UINT32 iterationFailMask = 0;
	A_UINT32 rateMask = configSetup.rateMask;

	//send wakeup call to golden unit
	dutSendWakeupCall(devNum, TRANSMIT_TEST, testChannel, testMode, turbo, goldAntenna, 0);
//	Sleep(1000);  //need to give the golden unit time to setup the receive

	art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)testMode, configSetup.use_init);		
	art_resetDevice(devNum, dutStation, bssID, testChannel, turbo);

	//start the transmit test, golden should already be in receive mode by now
	if(testMode == MODE_11B) {
		uiPrintf("\n         1Mb/s   2Mb/s   2Mb/s  5.5Mb/s 5.5Mb/s 11Mb/s  11Mb/s \n"); 
		uiPrintf("Preamble: long   long    short  long    short   long    short   CRCs  Result\n"); 
		rateMask = rateMask & 0xfd;
	} 
	else if ((testMode == MODE_11G) &&
		((swDeviceID & 0xff) >= 0x0013) && (turbo != TURBO_ENABLE) && (rateMask > 0xff)) {
		uiPrintf("\n  6   9   12  18  24  36  48  54  1L  2L  2S  5L  5S 11L 11S  CRCs Result\n"); 	
		uiPrintf("  --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---  ---- ------\n");
	}
	else {
		if(turbo == TURBO_ENABLE) {
			uiPrintf("\n12Mb/s  18Mb/s  24Mb/s  36Mb/s  48Mb/s  72Mb/s  96Mb/s  108Mb/s CRCs PPM Result\n"); 
		} 
		else if (turbo == HALF_SPEED_MODE) {
			uiPrintf("\n 3Mb/s 4.5Mb/s   6Mb/s   9Mb/s  12Mb/s  18Mb/s  24Mb/s  27Mb/s  CRCs PPM Result\n"); 	
		} else {
			uiPrintf("\n 6Mb/s   9Mb/s  12Mb/s  18Mb/s  24Mb/s  36Mb/s  48Mb/s  54Mb/s  CRCs PPM Result\n"); 	
		}
		rateMask = rateMask & 0xff;
	}

	for(i = 0; i < testSetup.numIterations; i++) {
//		uiPrintf("Starting transmit iteration number %d, out of %d\n", i, testSetup.numIterations);
		Sleep(1500);	// delay between packet sends
		art_resetDevice(devNum, dutStation, bssID, testChannel, turbo);
	
		//set the txPower if needed
		forcePowerOrPcdac(devNum);

		art_txDataSetup(devNum, rateMask, goldenStation, 
			testSetup.numPackets, testSetup.packetSize, pattern, 2, 0, configSetup.antenna, broadcast);
		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) {
			reasonFailMask |= MASK_COMMS_FAILURE;
			continue;
		}
		
		if(testMode == MODE_11B) {
			uiPrintf("        ");
		}

		iterationFailMask = analyzeLinkResults(devNum, rateMask, testMode, turbo, 1, antenna);

		if(iterationFailMask) {
			reasonFailMask |= iterationFailMask;
			uiPrintf(" X:");
			printFailLetters(iterationFailMask);
		}
		uiPrintf("\n");
	}
	
	if(reasonFailMask) {
		uiPrintf("\nTransmit Test FAIL, due to: \n");
		printFailures(reasonFailMask);
		uiPrintf("\n");
	}
	else {
		uiPrintf("\nTransmit Test Pass\n");
	}

	//restore the mode
	art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);		
	return (reasonFailMask);
}



A_UINT32 receiveTest
(
 A_UINT32 devNum,
 A_UINT32 testChannel,
 A_UINT32 testMode,
 A_UINT32 turbo,
 A_UINT16 antenna,
 A_UINT16 goldAntenna
)
{
	A_UINT32 start_timeout = 5000;	
	A_UINT32 complete_timeout = 10000;
	A_UINT32 stats_mode = 0; 
	A_UINT32 compare = 0;
	A_UCHAR  pattern[] = {0xaa, 0x55};
	A_UINT32 i;
	A_UINT32 rateMask = configSetup.rateMask;
	A_UINT32 reasonFailMask = 0;
	A_UINT32 iterationFailMask = 0;
	A_BOOL   enablePPM = 1;
	A_UINT32 numRates = 8;

	if((testMode == MODE_11B) || ((testMode == MODE_11G) && ((swDeviceID & 0xff) >= 0x0013))) {
		enablePPM = 0;
	}

	//send wakeup call to golden unit, note this waits for reply from GU before exit
	dutSendWakeupCall(devNum, RECEIVE_TEST, testChannel, testMode, turbo, goldAntenna, 0);

	art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)testMode, configSetup.use_init);		

	//start the receive test
	if(testMode == MODE_11B) {
		uiPrintf("\n         1Mb/s   2Mb/s   2Mb/s  5.5Mb/s 5.5Mb/s 11Mb/s  11Mb/s \n"); 
		uiPrintf("Preamble: long   long    short  long    short   long    short   CRCs Result\n"); 
		rateMask = rateMask & 0xfd;
	}
	else if ((testMode == MODE_11G) &&
		((swDeviceID & 0xff) >= 0x0013) && (turbo != TURBO_ENABLE) && (rateMask > 0xff)) {
		uiPrintf("\n  6   9   12  18  24  36  48  54  1L  2L  2S  5L  5S 11L 11S  CRCs Result\n"); 	
		uiPrintf("  --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---  ---- ------\n");
		numRates = 15;
	}
	else {
		if(turbo == TURBO_ENABLE) {
			uiPrintf("\n12Mb/s  18Mb/s  24Mb/s  36Mb/s  48Mb/s  72Mb/s  96Mb/s  108Mb/s CRCs PPM Result\n"); 
		} 
		else if (turbo == HALF_SPEED_MODE) {
			uiPrintf("\n 3Mb/s 4.5Mb/s   6Mb/s   9Mb/s  12Mb/s  18Mb/s  24Mb/s  27Mb/s  CRCs PPM Result\n"); 	
		} else {
			uiPrintf("\n 6Mb/s   9Mb/s  12Mb/s  18Mb/s  24Mb/s  36Mb/s  48Mb/s  54Mb/s  CRCs PPM Result\n"); 	
		}
		rateMask = rateMask & 0xff;
	}
	for(i = 0; i < testSetup.numIterations; i++) {
		art_resetDevice(devNum, dutStation, bssID, testChannel, turbo);
		art_setAntenna(devNum, configSetup.antenna);
		art_rxDataSetup(devNum, (testSetup.numPackets * numRates) + 40, testSetup.packetSize, enablePPM);
		art_rxDataBegin(devNum, start_timeout, complete_timeout, stats_mode, compare, pattern, 2);
		if (art_mdkErrNo!=0) {
			reasonFailMask |= MASK_COMMS_FAILURE;
			continue;
		}
		iterationFailMask = 0;
		if(testMode == MODE_11B) {
			uiPrintf("        ");
		}
		
		
		iterationFailMask = analyzeLinkResults(devNum, rateMask, testMode, turbo, 0, antenna);

		if(iterationFailMask) {
			reasonFailMask |= iterationFailMask;
			uiPrintf(" X:");
			printFailLetters(iterationFailMask);
		}
		uiPrintf("\n");
	}
	
	if(reasonFailMask) {
		uiPrintf("\nReceive Test FAIL, due to: \n");
		printFailures(reasonFailMask);
		uiPrintf("\n");
	}
	else {
		uiPrintf("\nReceive Test Pass, return code 0\n");
	}
	//restore the mode
	art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
			(A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);		
	return(reasonFailMask);
}


A_UINT32 analyzeLinkResults
(
 A_UINT32 devNum,
 A_UINT32 rateMask,
 A_UINT32 testMode,
 A_UINT32 turbo,
 A_BOOL remoteStats,
 A_UINT16 antenna
)
{
	A_UINT32 mask;
	A_UINT32 j;
    RX_STATS_STRUCT rStats;
	A_UINT32 reasonFailMask = 0;
	A_INT32 rssiThreshold;
	A_UINT16 antennaMaskOffset = 0;
	A_UINT32 numLoops = 8;
	A_UINT32 startLoop = 0;

	if(antenna == DESC_ANT_B) {
		//shift masks by 1 to get to the B antenna mask
		antennaMaskOffset = 1;
	}

	switch(testMode) {
	case MODE_11A:
		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:
		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:
		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(&rStats, 0, sizeof(RX_STATS_STRUCT));
	mask = 0x01;
	if (((testMode == MODE_11G) || (testMode == MODE_11B))&&
		((swDeviceID & 0xff) >= 0x0013) && (turbo != TURBO_ENABLE) ) {
		numLoops = 15;
		if(testMode == MODE_11B) {
			startLoop = 8;
		}
		else {
			uiPrintf("\n ");
		}
	}
	for(j = startLoop; j < numLoops; j++, mask <<= 1) {
		if(!(( j == 1) && (testMode ==MODE_11B))) {
			art_rxGetStats(devNum, DataRate[j], remoteStats, &rStats);
			if ((testMode == MODE_11G) &&
				((swDeviceID & 0xff) >= 0x0013) && (turbo != TURBO_ENABLE) && (rateMask > 0xff)) {
					uiPrintf("%3d", rStats.goodPackets);
			}
			else {
				uiPrintf("%3d(%2d)", rStats.goodPackets, rStats.DataSigStrengthAvg);
			}
			if(rStats.goodPackets < testSetup.perPassThreshold) {
				if(remoteStats) {
					//means dut was doing transmit test
					reasonFailMask |= (MASK_LINKTEST_TX_PER_ANTA << antennaMaskOffset);
				}
				else {
					//dut was doing a receive test
					reasonFailMask |= (MASK_LINKTEST_RX_PER_ANTA << antennaMaskOffset);
				}
			}
			
			if (rStats.DataSigStrengthAvg < rssiThreshold) {
				if(remoteStats) {
					//means dut was doing transmit test
					reasonFailMask |= (MASK_LINKTEST_TX_RSSI_ANTA << antennaMaskOffset);
				}
				else {
					//dut was doing a receive test
					reasonFailMask |= (MASK_LINKTEST_RX_RSSI_ANTA << antennaMaskOffset);
				}
			}
			uiPrintf(" ");
		}

	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -