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

📄 maui_cal.c

📁 Atheros AP Test with Agilent N4010A source code
💻 C
📖 第 1 页 / 共 5 页
字号:
		if (j > 0)			pEepromStruct = pRawGainDataset;		for (i = 0; i < myNumRawChannels; i++) {			channelValue = pMyRawChanList[i];			pEepromStruct->hadIdenticalPcdacs = TRUE;			pEepromStruct->pChannels[i] = channelValue;			pEepromStruct->pDataPerChannel[i].channelValue = channelValue;			pEepromStruct->pDataPerChannel[i].numPcdacValues = numPcdacs ;			memcpy(pEepromStruct->pDataPerChannel[i].pPcdacValues, RAW_PCDACS, numPcdacs*sizeof(A_UINT16));			pEepromStruct->pDataPerChannel[i].pcdacMin = pEepromStruct->pDataPerChannel[i].pPcdacValues[0];			pEepromStruct->pDataPerChannel[i].pcdacMax = pEepromStruct->pDataPerChannel[i].pPcdacValues[numPcdacs - 1];		}	}	return(1);}A_BOOL	d_allocateEepromStruct(dPCDACS_EEPROM  *pEepromStruct, A_UINT16	numChannels, A_UINT16 numPcdacs ){	A_UINT16	i, j;	///allocate room for the channels	pEepromStruct->pChannels = (A_UINT16 *)malloc(sizeof(A_UINT16) * numChannels);	if (NULL == pEepromStruct->pChannels) {		uiPrintf("unable to allocate eeprom struct\n");		return(0);	}	pEepromStruct->pDataPerChannel = (dDATA_PER_CHANNEL *)malloc(sizeof(dDATA_PER_CHANNEL) * numChannels);	if (NULL == pEepromStruct->pDataPerChannel) {		uiPrintf("unable to allocate eeprom struct\n");		free(pEepromStruct->pChannels);		return(0);	}	pEepromStruct->numChannels = numChannels;	for(i = 0; i < numChannels; i ++) {		pEepromStruct->pDataPerChannel[i].pPcdacValues = NULL;		pEepromStruct->pDataPerChannel[i].pPwrValues = NULL;		pEepromStruct->pDataPerChannel[i].numPcdacValues = numPcdacs;		pEepromStruct->pDataPerChannel[i].pPcdacValues = (A_UINT16 *)malloc(sizeof(A_UINT16) * numPcdacs);		if (NULL == pEepromStruct->pDataPerChannel[i].pPcdacValues) {			uiPrintf("unable to allocate eeprom struct\n");			break; //will cleanup outside loop		}		pEepromStruct->pDataPerChannel[i].pPwrValues = (double *)malloc(sizeof(double) * numPcdacs);		if (NULL == pEepromStruct->pDataPerChannel[i].pPwrValues) {			uiPrintf("unable to allocate eeprom struct\n");			break; //will cleanup outside loop		}	}	if (i != numChannels) {		//malloc must have failed, cleanup any allocs		for (j = 0; j < i; j++) {			if (pEepromStruct->pDataPerChannel[j].pPcdacValues != NULL) {				free(pEepromStruct->pDataPerChannel[j].pPcdacValues);			}			if (pEepromStruct->pDataPerChannel[j].pPwrValues != NULL) {				free(pEepromStruct->pDataPerChannel[j].pPwrValues);			}		}		uiPrintf("Failed to allocate eeprom struct, freeing anything already allocated\n");		free(pEepromStruct->pDataPerChannel);		free(pEepromStruct->pChannels);		pEepromStruct->numChannels = 0;		return(0);	}	return(1);}A_BOOL	d_freeEepromStruct(dPCDACS_EEPROM  *pEepromStruct){	A_UINT16	j;	A_UINT16	numChannels;	numChannels = pEepromStruct->numChannels;	for (j = 0; j < numChannels; j++) {		if (pEepromStruct->pDataPerChannel[j].pPcdacValues != NULL) {			free(pEepromStruct->pDataPerChannel[j].pPcdacValues);		}		if (pEepromStruct->pDataPerChannel[j].pPwrValues != NULL) {			free(pEepromStruct->pDataPerChannel[j].pPwrValues);		}	}	free(pEepromStruct->pDataPerChannel);	free(pEepromStruct->pChannels);//	free(pEepromStruct);	return(1);}void measure_all_channels(A_UINT32 devNum, A_UINT16 debug){	A_UINT16 fill_zero_pcdac = 40 ;	A_BOOL fillZeros ;	A_BOOL fillMaxPwr;	A_UINT16 numPcdacs ;	A_INT16 i;	A_UINT16 *reordered_pcdacs_index ;	A_UINT16 rr = 0; //reordered_pcdacs_index index	A_UINT16 channel;	A_UINT16  pcdac ;	A_UINT16 reset = 0;	double power;	dDATA_PER_CHANNEL	*pRawChannelData;	double				*pRawPwrValue;	dDATA_PER_CHANNEL	*pGainfChannelData;	double				*pGainfValue;//** the following added by ccshiang	double agiCableLost;//** the above added by ccshiang	uiPrintf("\nL%d, Collecting raw data for the adapter for mode 11a\n",_module_line());	numPcdacs = (A_UINT16) sizeOfRawPcdacs ;	reordered_pcdacs_index = (A_UINT16 *)malloc(sizeof(A_UINT16) * numPcdacs) ;	if (NULL == reordered_pcdacs_index)		uiPrintf("Could not allocate memory for the reordered_pcdacs_index array.\n");	for (i=numPcdacs-1; i>=0; i--)	{		if (RAW_PCDACS[i] <= fill_zero_pcdac)		{			reordered_pcdacs_index[rr] = i;			rr++;		}	}	for (i=0; i<numPcdacs; i++)	{		if (RAW_PCDACS[i] > fill_zero_pcdac)		{			reordered_pcdacs_index[rr] = i;			rr++;		}	}	if (rr != numPcdacs)	{		uiPrintf("Couldn't reorder pcdacs.\n");		exit(0);	}	//if(debug)	{		uiPrintf("Reordered pcdacs are: ");		for (i=0; i<numPcdacs; i++)		{			uiPrintf("%d, ", RAW_PCDACS[reordered_pcdacs_index[i]]);		}		uiPrintf("\n");	}	for (i=0; i<pRawDataset->numChannels; i++)	{		channel = pRawDataset->pDataPerChannel[i].channelValue;		pRawChannelData = &(pRawDataset->pDataPerChannel[i]) ;		pGainfChannelData = &(pRawGainDataset->pDataPerChannel[i]) ;//** the following added by ccshiang		agiCableLost = agiGetCableLost(channel);//** the above added by ccshiang		//setCornerFixBits(devNum, channel);		if (i == 0)		{			art_resetDevice(devNum, txStation, NullID, channel, 0);		} else		{//			art_resetDevice(devNum, txStation, NullID, channel, 0);			art_changeChannel(devNum, channel); //SNOOP: get this in eventually for efficiency		}		art_txContBegin(devNum, CONT_FRAMED_DATA, RANDOM_PATTERN,						rates[0], DESC_ANT_A | USE_DESC_ANT);		reset = 0; //1;		if(CalSetup.useInstruments)		{			power = pmMeasAvgPower(devPM, reset) ;			printf("THE POwer is %d\n",power);		} else		{			power = 0;		}		reset = 0;//		Sleep(20); // sleep 20 ms		Sleep(50); // sleep 150 ms - based on feedback b.		fillZeros = FALSE ;		fillMaxPwr = FALSE ;		for(rr=0; rr<numPcdacs; rr++)		{			pcdac = RAW_PCDACS[reordered_pcdacs_index[rr]] ;			pRawPwrValue = &(pRawChannelData->pPwrValues[reordered_pcdacs_index[rr]]) ;			pGainfValue  = &(pGainfChannelData->pPwrValues[reordered_pcdacs_index[rr]]) ;			if (CalSetup.xpd < 1)			{				printf("IN FOR IF \n");				art_txContEnd(devNum);				art_resetDevice(devNum, txStation, NullID, channel, 0);				art_ForceSinglePCDACTable(devNum, (A_UCHAR) pcdac);				art_txContBegin(devNum, CONT_FRAMED_DATA, RANDOM_PATTERN,								rates[0], DESC_ANT_A | USE_DESC_ANT);			} else			{				art_ForceSinglePCDACTable(devNum, pcdac);			}			if (pcdac > fill_zero_pcdac)				fillZeros = FALSE ;			if (pcdac < fill_zero_pcdac)				fillMaxPwr = FALSE ;			if (fillZeros)			{				*pRawPwrValue = 0;				*pGainfValue  = 0;				continue ;			}			if (fillMaxPwr)			{				*pRawPwrValue = CalSetup.maxPowerCap[MODE_11a];				*pGainfValue  = 110;				continue ;			}			Sleep(50) ;			if(CalSetup.useInstruments)			{				power = pmMeasAvgPower(devPM, reset) ;			} else			{				power = 0;			}			*pRawPwrValue = (power + CalSetup.attenDutPM) ;//** the following added by ccshiang			*pRawPwrValue += agiCableLost;//** the above added by ccshiang			if (CalSetup.customerDebug)			{				art_txContEnd(devNum);				//Sleep(100);				*pGainfValue  = (double) dump_a2_pc_out(devNum) ;				art_txContBegin(devNum, CONT_FRAMED_DATA, RANDOM_PATTERN,								rates[0], DESC_ANT_A | USE_DESC_ANT);			} else			{				*pGainfValue = (double) 0 ;			}			if ( *pRawPwrValue <= 0 )				fillZeros = TRUE ;			if ( *pRawPwrValue >= CalSetup.maxPowerCap[MODE_11a] )				fillMaxPwr = TRUE ;			if (debug)			{				uiPrintf("  power at pcdac=%d is %2.1f + %2.1f = %2.1f\n", pcdac, power, CalSetup.attenDutPM, *pRawPwrValue);			}		}		uiPrintf("ch: %d  --> max pwr is %2.1f dBm\n", channel, *pRawPwrValue) ;		art_txContEnd(devNum) ;	}	free(reordered_pcdacs_index);}void dump_rectangular_grid_to_file( dPCDACS_EEPROM  *pEepromData, char *filename ){	A_UINT16	i, j;	dDATA_PER_CHANNEL	*pChannelData;	FILE *fStream;	if (CalSetup.customerDebug)		uiPrintf("\nWriting to file %s\n", filename);	if( (fStream = fopen( filename, "w")) == NULL ) {		uiPrintf("Failed to open %s - using Defaults\n", filename);		return;	}	//print the frequency values	fprintf(fStream, "  \t");	for (i = 0; i < pEepromData->numChannels; i++) {		fprintf(fStream,"%d\t", pEepromData->pChannels[i]);	}	fprintf(fStream,"\n");	//print the pcdac values for each frequency	for(j = 0; j < pEepromData->pDataPerChannel[0].numPcdacValues ; j++) {		fprintf(fStream,"%d\t", pEepromData->pDataPerChannel[0].pPcdacValues[j]);		for(i = 0; i < pEepromData->numChannels; i++) {			pChannelData = &(pEepromData->pDataPerChannel[i]);			//fprintf(fStream,"%2.2f\t", pChannelData->pPwrValues[j]);			fprintf(fStream,"%f\t", pChannelData->pPwrValues[j]);		}		fprintf(fStream,"\n");	}	fclose(fStream);}void dump_nonrectangular_grid_to_file( dPCDACS_EEPROM  *pEepromData, char *filename ){	A_UINT16	i, j;	FILE *fStream;	if (CalSetup.customerDebug)		uiPrintf("\nWriting to file %s\n", filename);	if( (fStream = fopen( filename, "w")) == NULL ) {		uiPrintf("Failed to open %s - using Defaults\n", filename);		return;	}	//print the frequency values	fprintf(fStream, "  \t");	for (i = 0; i < pEepromData->numChannels; i++) {		fprintf(fStream,"%d: pcdacMin=%d, pcdacMax=%d\n", pEepromData->pChannels[i],														  pEepromData->pDataPerChannel[i].pcdacMin,														  pEepromData->pDataPerChannel[i].pcdacMax);		//print the pcdac values for each frequency		for(j = 0; j < pEepromData->pDataPerChannel[0].numPcdacValues ; j++) {			fprintf(fStream,"%d: %2.1f\n", pEepromData->pDataPerChannel[i].pPcdacValues[j],										   pEepromData->pDataPerChannel[i].pPwrValues[j]);		}		fprintf(fStream, "\n\n");	}	fclose(fStream);}void make_cal_dataset_from_raw_dataset(){	A_UINT16 numPiers ;	A_UINT16 i ;	A_UINT16 channelValue;	A_UINT16 numAllChannels, numAllPcdacs;	A_UINT16 stepAllChannels = 5;	A_UINT16 *AllPcdacs ;	A_UINT16 numPcdacs;	A_UINT16 *turning_points ;	A_UINT16 filter_size = 2;	A_UINT16 data_ceiling = 30 ; // max dB in raw measured data	A_UINT16 debug = CalSetup.customerDebug;	dPCDACS_EEPROM SnapshotDataset;	dPCDACS_EEPROM *pSnapshotDataset = &SnapshotDataset;	numPcdacs = sizeOfRawPcdacs;	if ( eepromType == EEPROM_SIZE_16K )	{		numPiers = NUM_PIERS ;	}	if(!d_allocateEepromStruct( pCalDataset, numPiers, goldenParams.numIntercepts  )) {		uiPrintf("unable to allocate eeprom struct pCalDataset. Exiting...\n");		exit(0);	}	pCalDataset->hadIdenticalPcdacs = FALSE ;	numAllChannels = (goldenParams.channelStop - goldenParams.channelStart)/stepAllChannels + 1;	numAllPcdacs = (goldenParams.pcdacStop - goldenParams.pcdacStart)/goldenParams.pcdacStep + 1;	if(!d_allocateEepromStruct( pFullDataset, numAllChannels, numAllPcdacs )) {		uiPrintf("unable to allocate eeprom struct pFullDataset. Exiting...\n");		exit(0);	}	pFullDataset->hadIdenticalPcdacs = TRUE ;	AllPcdacs = (A_UINT16 *) malloc(numAllPcdacs*sizeof(A_UINT16)) ;

⌨️ 快捷键说明

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