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

📄 test.c

📁 atheros ar5001 5002 driver
💻 C
📖 第 1 页 / 共 5 页
字号:
			configSetup.cmdLineTest = TRUE;
			configSetup.cmdLineTestMask = configSetup.cmdLineTestMask | MAC_ADDR_MASK;
		}
		else if(strncmp(argv[i - 1], "\\ch=", 4) == 0)
		{
			//parse the channel list
			if(!parseCmdChannelList(&argv[i - 1][4])) {
				return FALSE;
			}
		}
		else if (strncmp(argv[i - 1], "\\ant=", 5) == 0)
		{
			if((argv[i - 1][5] == 'a') || (argv[i - 1][5] == 'a')) {
				configSetup.antennaMask = ANTENNA_A_MASK;
			}
			else if ((argv[i - 1][5] == 'b') || (argv[i - 1][5] == 'b')) {
				configSetup.antennaMask = ANTENNA_B_MASK;
			}
			else if ((argv[i - 1][5] == 'm') || (argv[i - 1][5] == 'm')) {
				configSetup.antennaMask = ANTENNA_B_MASK | ANTENNA_A_MASK;
			}
			else {
				uiPrintf("Illegal value specified for antenna, valid choises are a, b or m (multiple/both)\n");
				return FALSE;
			}
		}
		else if (strncmp(argv[i - 1], "\\goldant=", 9) == 0)
		{
			if((argv[i - 1][9] == 'a') || (argv[i - 1][9] == 'a')) {
				configSetup.goldAntennaMask = ANTENNA_A_MASK;
			}
			else if ((argv[i - 1][9] == 'b') || (argv[i - 1][9] == 'b')) {
				configSetup.goldAntennaMask = ANTENNA_B_MASK;
			}
			else if ((argv[i - 1][9] == 'm') || (argv[i - 1][9] == 'm')) {
				configSetup.goldAntennaMask = ANTENNA_B_MASK | ANTENNA_A_MASK;
			}
			else {
				uiPrintf("Illegal value specified for golden antenna, valid choises are a, b or m (multiple/both)\n");
				return FALSE;
			}
		}
		else if (strncmp(argv[i - 1], "\\beacon=", 8) == 0) {
			//get the bssid string
			strncpy((char *)buffer, strtok(&argv[i - 1][8], " \\"), 256);
			getBssidFromString(configSetup.beaconBSSID.octets, buffer);
			configSetup.cmdLineTest = TRUE;
			configSetup.cmdLineTestMask = configSetup.cmdLineTestMask | BEACON_TEST_MASK;
		}
		else if (strncmp(argv[i-1],"\\log=",5) == 0)
		{
			configSetup.logging = 1;
			strncpy(configSetup.logFile, &(argv[i-1][5]), MAX_FILE_LENGTH);
		}
		else if (strncmp(argv[i-1],"\\rangelog=",10) == 0)
		{
			configSetup.rangeLogging = 1;
			strncpy(configSetup.rangeLogFile, &(argv[i-1][10]), MAX_FILE_LENGTH);
		}
		else if (strncmp(argv[i-1],"\\iterations=",12) == 0) {
			configSetup.iterations = atoi(&(argv[i-1][12]));
		}
		else if (strncmp(argv[i-1],"\\dutID=",7) == 0) {
			configSetup.dutSSID = atoi(&(argv[i-1][7]));
			configSetup.userDutIdOverride = TRUE;
		}
		else {
			uiPrintf("Command line cannot be parsed. \n");
#ifndef __ATH_DJGPPDOS__
			uiPrintf("Usage art [\\remote=<ip_addr>] [\\id=<subsystemID>] [\\prog] [\\instance=<instance_number>] \n");
#else
			uiPrintf("Usage art [\\id=<subsystemID] [\\instance=<instance_number>]\n ");
#endif
			return FALSE;
		}
	}

	return TRUE;
}



//each item in the channel list should be of the format NNNNx
//where NNNN is the channel in MHz x should be either a, b or g.
A_BOOL parseCmdChannelList
(
 A_CHAR *listString
)
{
	A_UINT16 roughChannelCount;
	A_CHAR *token;
	A_CHAR delimiters[]   = ",";
	A_UINT16 channelCount = 0;
	
	//get a rough channel count
	roughChannelCount = strlen(listString)/5;
	
	configSetup.testChannelList = (TEST_CHANNEL_INFO *)malloc(roughChannelCount * sizeof(TEST_CHANNEL_INFO));
	if(!configSetup.testChannelList) {
		uiPrintf("Unable to allocate memory for testChannel list\n");
		return FALSE;
	}
	token = strtok(listString, delimiters);
	while(token) {
		if(strlen(token) != 5) {
			uiPrintf("Syntax Error: channel should be of format NNNNx\n");
			uiPrintf("where NNNN is channel in MHz, x is mode: a, b or g\n");
			free(configSetup.testChannelList);
			return FALSE;
		}

		//extract mode
		switch (token[4]) {
		case 'a':
		case 'A':
			configSetup.testChannelList[channelCount].mode = MODE_11A;
			configSetup.testChannelList[channelCount].turbo = 0;
			break;
		case 't':
		case 'T':
			configSetup.testChannelList[channelCount].mode = MODE_11A;
			configSetup.testChannelList[channelCount].turbo = TURBO_ENABLE;
			break;
		case 'b':
		case 'B':
			configSetup.testChannelList[channelCount].mode = MODE_11B;
			configSetup.testChannelList[channelCount].turbo = 0;
			break;
		case 'g':
		case 'G':
			configSetup.testChannelList[channelCount].mode = MODE_11G;
			configSetup.testChannelList[channelCount].turbo = 0;
			break;
		case 'u':
		case 'U':
			configSetup.testChannelList[channelCount].mode = MODE_11G;
			configSetup.testChannelList[channelCount].turbo = TURBO_ENABLE;
			break;
		case 'o':
		case 'O':
			configSetup.testChannelList[channelCount].mode = MODE_11O;
			configSetup.testChannelList[channelCount].turbo = 0;
			break;
		default:
			uiPrintf("Illegal mode specified in channel list must be a, b or g\n");
			return FALSE;
		} //end switch
		
		token[4] = '\0';
		
        if(!sscanf(token, "%d", &(configSetup.testChannelList[channelCount].channel))) {
            uiPrintf("Unable to read channel from channel list\n");
			free(configSetup.testChannelList);
			return FALSE;
        }

		//error check the channel value
		if (configSetup.testChannelList[channelCount].mode == MODE_11A) {
			if((configSetup.testChannelList[channelCount].channel < MIN_CHANNEL) || 
				(configSetup.testChannelList[channelCount].channel > MAX_SOM_CHANNEL))
			{
				uiPrintf("Illegal channel value for mode 11a\n");
				free(configSetup.testChannelList);
				return FALSE;
			}
		}
		else { //mode is b or g
			if((configSetup.testChannelList[channelCount].channel < MIN_2G_CHANNEL) || 
				(configSetup.testChannelList[channelCount].channel > MAX_2G_CHANNEL))
			{
				uiPrintf("Illegal channel value for 2.4 GHz modes\n");
				free(configSetup.testChannelList);
				return FALSE;
			}

		}
#ifdef _DEBUG  
		uiPrintf("Added channel %d, mode %d to list\n", 
			configSetup.testChannelList[channelCount].channel, configSetup.testChannelList[channelCount].mode);
#endif
		token = strtok(NULL, delimiters);
		channelCount++;
	}
	//update exact number of channels
	configSetup.numListChannels = channelCount;

	return TRUE;
}

void contMenu(A_UINT32 devNum)
{
    A_BOOL done = FALSE;
    A_BOOL eol = FALSE;
	A_UINT32 frameLength = 1000;
	A_UINT32 waitTime = 0;
	A_UINT32 contMode;
	A_UINT32 maxRateIndex = 7;
	A_INT16		inputKey;
	A_UINT32 rateIndex = 0;
//	A_UINT32 time1;
	A_BOOL   scrambleModeOff = 0;

	A_BOOL	 newLadderState;
    A_UCHAR  pattern[2] = {0xaa, 0x55};		//hard coded for now, will external data pattern later

	A_UINT32 pcdac_pwr = OFDM_CCK_DEF_IDX;
	A_INT32 dBm_pwr;

//#if !defined(CUSTOMER_REL) && !defined(__ATH_DJGPPDOS__)
#if 1
	A_INT32		devSA_local, failNum=0 ;
#endif

	initializeGainLadder(pCurrGainLadder);
	programNewGain(pCurrGainLadder, devNum, 0);

	if(configSetup.powerOvr == 1)  {
		pCurrGainLadder->active = FALSE;
	}

	if((swDeviceID & 0xff) >= 0x0013)  {
		if(configSetup.mode == MODE_11G) {
			maxRateIndex = (configSetup.enableXR) ? 19 : 14;
		}
	}

	if (configSetup.useTargetPower == TRUE)
		configSetup.powerOutput = art_getMaxPowerForRate(devNum, (A_UINT16)configSetup.channel, DataRate[configSetup.dataRateIndex]);
    while(!done) {
		//do a reset device to clear any provious cont test, need to be in the correct
		//state incase we have to do a setSingleTransmitPower
		art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
		setInitialPowerControlMode(devNum, configSetup.dataRateIndex);
		
		if (configSetup.contMode == CONT_TX100) {
			contMode = CONT_DATA;
		}
		else if (configSetup.contMode == CONT_TX99) {
			contMode = CONT_FRAMED_DATA;
		}
		else if (configSetup.contMode == CONT_FRAME) {
			contMode = CONT_FRAMED_DATA;
		}
		switch(configSetup.contMode) {
			case CONT_TX100:	
				if((macRev == 0x40)&&(!(configSetup.mode == MODE_11B))) {
					configSetup.dataRateIndex = 0;
				}
			case CONT_TX99:
				
				rateIndex = configSetup.dataRateIndex;
			
				art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
			    forcePowerOrPcdac(devNum);
				setRegistersFromConfig(devNum);
//				time1 = milliTime();
//				uiPrintf("SNOOP: rateindex=%d, datarate=0x%x\n", rateIndex, DataRate[rateIndex]);
				art_txContBegin(devNum, contMode, configSetup.dataPattern, 
							DataRate[rateIndex], configSetup.antenna);
/*				if(configSetup.contMode == CONT_TX99) {
					time1 = milliTime();
					art_txContEnd(devNum);
					//Sleep(100);
					gainF = dump_a2_pc_out(devNum);
					uiPrintf("   [Gainf = %d]", gainF);					
				art_txContBegin(devNum, contMode, configSetup.dataPattern, 
							DataRate[rateIndex], configSetup.antenna);
				}
*/
				break;

			case CONT_FRAME:
				rateIndex = configSetup.dataRateIndex;
				art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
			    forcePowerOrPcdac(devNum);
				setRegistersFromConfig(devNum);

				if(configSetup.mode != MODE_11B) {
					switch(configSetup.dataRateIndex)	{
						case 0:
							frameLength = 224; //410;//386;//254;
							break;
						case 1:
							frameLength = 353; //632;//596;//383;
							break;
						case 2:
							frameLength = 482; //852;//806;//512;
							break;
						case 3:
							frameLength = 740; //1298;//1226;//770;
							break;
						case 4:
							frameLength = 998; //1742;//1646;//1028;
							break;
						case 5:
							frameLength = 1514; //2630;//2486;//1544;
							break;
						case 6:
							frameLength = 2030; //3518;//3326;//2060;
							break;
						case 7:
							frameLength = 2288; //3962;//3746;//2300;
							break;
					}
				}
				else {
					switch(configSetup.dataRateIndex)	{
						case 0:
							frameLength = 41; //166; //300;
							break;
						case 1:
							frameLength = 41; //166; //300;
							break;
						case 2:
							frameLength = 116;  //366; //634;
							break;
						case 3:
							frameLength = 140; //366; //634;
							break;
						case 4:
							frameLength = 379; //1066; //1803;
							break;
						case 5:
							frameLength = 445; //1066; //1803;
							break;
						case 6:
							frameLength = 791; //2166; //3630;
							break;
						case 7:
							frameLength = 923; //2166; //3640;
							break;
					}

				}

				art_txContFrameBegin(devNum, frameLength, configSetup.numSlots, configSetup.dataPattern, 
							DataRate[rateIndex], configSetup.antenna, 1, 0, NULL);
				break;

			case CONT_CARRIER:		// single carrier
				art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
			    forcePowerOrPcdac(devNum);
				setRegistersFromConfig(devNum);
				art_txContBegin(devNum, CONT_SINGLE_CARRIER, 511, 511, configSetup.antenna);

				break;
		}

		printContMenu(devNum);
#ifdef __ATH_DJGPPDOS__
		while (!_bios_keybrd(_KEYBRD_READY))
#else
		while (!kbhit())      
#endif
		{

			if (configSetup.contMode == CONT_TX99)
			{
				dBm_pwr = art_getPowerIndex(devNum, (A_INT32) configSetup.powerOutput) ;
				if((configSetup.mode == MODE_11G)&&((swDeviceID & 0xff) >= 0x0013)) {
					pcdac_pwr  = OFDM_11G_IDX;
					if ((configSetup.dataRateIndex <= 14) && (configSetup.dataRateIndex >= 8)) {
//						pcdac_pwr = CCK_11G_IDX;

						dBm_pwr -= ( OFDM_11G_IDX - CCK_11G_IDX);
						if (dBm_pwr < 0) dBm_pwr = 0;
					}
				}
				//uiPrintf("SNOOP: dbm_pwr = %d, pcdac_pwr = %d\n", dBm_pwr, pcdac_pwr);
				//		if (configSetup.powerOvr == 1)
				if (0)
				{
					pCurrGainLadder->currGain = configSetup.gainI;
				} else
				{
					readGainFInContTx(pCurrGainLadder, devNum, (configSetup.powerControlMethod == DB_PWR_CTL) ? dBm_pwr : pcdac_pwr);	
				}
				tweakGainF(pCurrGainLadder, devNum, 0);
				Sleep(200);				
				readGainFInContTx(pCurrGainLadder, devNum, (configSetup.powerControlMethod == DB_PWR_CTL) ? dBm_pwr : pcdac_pwr);	
				if (invalidGainReadback(pCurrGainLadder, devNum))
				{
					uiPrintf("invalid gainF - resetting.\n");
					break;
				}
				if (configSetup.powerOvr != 1)
				{
					configSetup.b_ob = art_getFieldForMode(devNum, "rf_b_ob", configSetup.mode, configSetup.turbo);
					configSetup.b_db = art_getFieldForMode(devNum, "rf_b_db", configSetup.mode, configSetup.turbo);
				}

				printContMenu(devNum);
				uiPrintf(" Gainf = %d [%s]  ", pCurrGainLadder->currGain, pCurrGainLadder->currStep->stepName);
				uiPrintf("  %s\n", (pCurrGainLadder->active ? "" : "inactive"));
				Sleep(100);
			} 

		}
		
		if (!invalidGainReadback(pCurrGainLadder, devNum))
		{
			inputKey = getch();
		} else
		{
			inputKey = '8';
		}

		if(!processCommonOptions(devNum, inputKey)) {
			switch(inputKey) {
			case '8' :
				break;
			case '9':  // toggle dynamic gain adj. on or off
//			  if((swDeviceID & 0xff) >= 0x14) {
				if (0) {
					uiPrintf("deviceID = %x does 

⌨️ 快捷键说明

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