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

📄 test.c.bacup

📁 Atheros AP Test with Agilent N4010A source code
💻 BACUP
📖 第 1 页 / 共 5 页
字号:
                uiPrintf("closing environment\n");
                closeEnvironment();
                exit(0);            
            }
            if (configSetup.remote)
             {
                     uiPrintf("IP Address of the new AP: ");
                     scanf("%s",configSetup.machName);
             }


            findEepFile();

            
            if(configSetup.userInstanceOverride) {
              devNum = art_setupDevice(configSetup.instance);
              if(devNum < 0) {
                  uiPrintf("main: Error attaching to the device - ending test\n");
                  closeEnvironment();
                  exit(0);
              }
              art_configureLibParams(devNum);
              art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
              uiPrintf("Attached to the Device for instance = %d\n", configSetup.instance);

                //for now make the assumption that both a and g are supported
                devNum_5g = devNum;
                devNum_2g = devNum;
            }
            else {
                //enable the instances that are valid
                if(CalSetup.modeMaskForRadio[0] != 0) {
                    devNumInst[1] = art_setupDevice(1);
                    if(devNumInst[1] < 0) {
                        uiPrintf("main: Error attaching to the device - ending test\n");
                        closeEnvironment();
                        exit(0);
            }
                    art_configureLibParams(devNumInst[1]);
                    art_resetDevice(devNumInst[1], txStation, bssID, configSetup.channel, configSetup.turbo);
                    uiPrintf("Attached to the Device for instance = %d\n", 1);
            }

                if(CalSetup.modeMaskForRadio[1] != 0) {
                    devNumInst[2] = art_setupDevice(2);
                    if(devNumInst[2] < 0) {
                        uiPrintf("main: Error attaching to the device - ending test\n");
                        closeEnvironment();
                        exit(0);
                    }
                    art_configureLibParams(devNumInst[2]);
                    art_resetDevice(devNumInst[2], txStation, bssID, configSetup.channel, configSetup.turbo);
                    uiPrintf("Attached to the Device for instance = %d\n", 2);
                    }

                //Setup the 2g and 5g instances
                devNum_5g = devNumInst[CalSetup.instanceForMode[MODE_11a]];
                devNum_2g = devNumInst[CalSetup.instanceForMode[MODE_11g]];

                //check that we have legal devNums for both.  If not, point to a valid
                //devNum, manufacturing expects 2 devNums to be valid
                //if all board text files are setup correctly, should not use it.
                if((devNum_5g == INVALID_INSTANCE)&& (devNum_2g == INVALID_INSTANCE)) {
                    uiPrintf("Unable to allocate a valid devNum, exiting\n");
                        closeEnvironment();
                        exit(0);
                    }
                else if (devNum_5g == INVALID_INSTANCE) {
                        devNum_5g = devNum_2g;
                    }
                else if (devNum_2g == INVALID_INSTANCE) {
                    devNum_2g = devNum_5g;
                }
            }

            //setup devnum correctly
            if(configSetup.mode == MODE_11A) {
                if(devNum_5g != INVALID_INSTANCE) {
                    devNum = devNum_5g;
                }
                else {
                    //assume 11g
                    devNum = devNum_2g;
                }
            }
            else {
                if(devNum_2g != INVALID_INSTANCE) {
                    devNum = devNum_2g;
                }
                else {
                    //assume 11a
                    devNum = devNum_5g;
                }
                } 

            //extra safety check
            if(devNum == INVALID_INSTANCE) {
                uiPrintf("Unable to get allocate a valid devNum, exiting\n");
                closeEnvironment();
                exit(0);
            }
            
                    
            //get the deviceID from the library and use the swDevID
            art_getDeviceInfo(devNum, &devStruct);
                    swDeviceID = devStruct.swDevID;
                    hwDeviceID = devStruct.hwDevID;                    

            if (!configSetup.userInstanceOverride) {

                if (CalSetup.Amode) {
                    if (CalSetup.Gmode) {
                        if ((CalSetup.instanceForMode[MODE_11a] != 1) && (CalSetup.instanceForMode[MODE_11g] != 1)) {
                            configSetup.validInstance = 2;
                        }
                    } else {
                        if (CalSetup.instanceForMode[MODE_11a] != 1) {
                            configSetup.validInstance = 2;
                        }
                    }
                } else if (CalSetup.Gmode) {
                    if (CalSetup.instanceForMode[MODE_11g] != 1) {
                        configSetup.validInstance = 2;
                    }
                }
            }
                

            configSetup.powerControlMethod = NO_PWR_CTL;
            art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
            if (((swDeviceID & 0xff) == 0x14)||((swDeviceID & 0xff) >= 0x16)) {
                if ((swDeviceID & 0xFF) >= 0x16) {
                    pCurrGainLadder = &(gainLadder_derby2);
                } else {
                    pCurrGainLadder = &(gainLadder_derby1);
                }
            } else {
                pCurrGainLadder = &(gainLadder);
            }

            if (eeprom_verify_checksum(devNum))
            {
                configSetup.validCalData  =  TRUE;
                configSetup.eepromLoad    =  1;
                if (((swDeviceID & 0xff) >= 0x0014)&&((swDeviceID & 0xff) != 0x0015) ){
                    //xpdgain gets set by devlib, don't want to apply here unless there
                    //is an override.
                    configSetup.applyXpdGain = 0;
                }
            } else
            {
                configSetup.validCalData  =  FALSE;
                configSetup.eepromLoad    =  0;
                invalidEepromMessage(2000);
                configSetup.applyXpdGain = 1;
            }

            art_setResetParams(devNum, configSetup.pCfgFile, (A_BOOL)configSetup.eepromLoad,
                (A_BOOL)configSetup.eepromHeaderLoad, (A_UCHAR)configSetup.mode, configSetup.use_init);        
       #ifndef __ATH_DJGPPDOS__
            if(!setEepFile(devNum)) {
                art_teardownDevice(devNum);
                closeEnvironment();
                exit(0);
            }

            if(((swDeviceID == 0xa014)||(swDeviceID == 0xa016)||(swDeviceID == 0xa017))&&(!configSetup.userInstanceOverride)) {
                if(!setEepFile((devNum == devNum_5g) ? devNum_2g : devNum_5g)) {
                    art_teardownDevice((devNum == devNum_5g) ? devNum_2g : devNum_5g);
                    closeEnvironment();
                    exit(0);
                }
            }
        #endif
            //test card/installation
            if(!initTest(devNum)) {
                uiPrintf("main: Error testing device - exiting\n");
                art_teardownDevice(devNum);
                closeEnvironment();
                exit(0);
            }

            //Read register values read in from resetDevice
            updateConfigFromRegValues(devNum);
			}
            break;
        case 'W':
            if(configSetup.logging) {
                printf("Enter comment below.  Put a period (.) on a seperate line to complete\n");
                while(commentBuffer[0] != '.') {   
                    if( fgets( commentBuffer, MAX_SIZE_COMMENT_BUFFER, stdin ) == NULL) {
                        printf( "fgets error\n" );
                        break;
                    }
                    if(commentBuffer[0] != '.') {    
                        uiWriteToLog(commentBuffer);
                    }
                }
                //remote the . from comment buffer otherwise will fall through next time
                commentBuffer[0] = 'a';
            }
            else {
                uiPrintf("Unknown command\n");
            }
            break;
        case 'M':
            if((swDeviceID == 0xa014)||(swDeviceID == 0xa016)||(swDeviceID == 0xa017)){
                if (configSetup.userInstanceOverride) {
                    if (configSetup.instance == 1) {
                        tempDevNum = art_setupDevice(2);
                        if(tempDevNum < 0) {
                            uiPrintf("main: Error attaching to the second device - ending test\n");
                            closeEnvironment();
                            exit(0);
                        }
                        art_configureLibParams(tempDevNum);
                        
                        if (CalSetup.instanceForMode[MODE_11g] == 2) {
                            devNum_2g = tempDevNum;
                        } else {
                            devNum_2g = devNum;
                        }
                        
                        if (CalSetup.instanceForMode[MODE_11a] == 2) {
                            devNum_5g = tempDevNum;
                        } else {
                            devNum_5g = devNum;
                        }
                        
                    } else {
                        tempDevNum = art_setupDevice(1);
                        if(tempDevNum < 0) {
                            uiPrintf("main: Error attaching to the second device - ending test\n");
                            closeEnvironment();
                            exit(0);
                        }                        
                        art_configureLibParams(tempDevNum);
    
                        if (CalSetup.instanceForMode[MODE_11g] == 1) {
                            devNum_2g = tempDevNum;
                        } else {
                            devNum_2g = devNum;
                        }
                        
                        if (CalSetup.instanceForMode[MODE_11a] == 1) {
                            devNum_5g = tempDevNum;
                        } else {
                            devNum_5g = devNum;
                        }
                    }
//                art_teardownDevice(devNum_2g);
//                devNum = devNum_5g;
                } 
            } else {
                devNum_2g = devNum;
                devNum_5g = devNum;
            }
            
            art_resetDevice(devNum, txStation, bssID, configSetup.channel, configSetup.turbo);
            topCalibrationEntry(&devNum_5g, &devNum_2g);

            break;
#endif  // __ATH_DJGPPDOS__
//Take out for now        case 'X':
//            testMenu(devNum);
//            break;
        case 'f':
        case 'F':
            printf("Press a key to write 0\n");
            getch();
//            art_ap_reg_write(devNum, 0x0b10008, 0);
            art_ap_reg_write(devNum, 0x0b10000, 0);
//            art_ap_reg_write(devNum, 0x0b10000, 0);
            //art_ap_reg_write(devNum, 0x0b10008, 0);
            printf("Press a key to write 1\n");
            getch();
//            art_ap_reg_write(devNum, 0x0b10000, 3);
            art_ap_reg_write(devNum, 0x0b10000, 3);

            printf("Press a key to write 0\n");
            getch();
//            art_ap_reg_write(devNum, 0x0b10000, 3);
            art_ap_reg_write(devNum, 0x0b10000, 0);
            break;

        case 'd':
        case 'D':
				sleep_enable = !sleep_enable;
				art_sleepCmd(devNum, sleep_enable);
            break;
            
        case 0x1b:
        case 'Q':
            exitLoop = TRUE;
            uiPrintf("exiting\n");
            break;

        default:
            uiPrintf("Unknown command\n");
            break;
        }
    }
    if(configSetup.logging) {
        uilogClose();
    }
    uiPrintf("closing device\n");
    art_teardownDevice(devNum); 
    if((devNum_2g != devNum_5g) && ((swDeviceID == 0xa014)||(swDeviceID == 0xa016)||(swDeviceID == 0xa017))&&(!configSetup.userInstanceOverride)) {
        if(devNum == devNum_2g) {
            art_teardownDevice(devNum_5g);
        } else {
            art_teardownDevice(devNum_2g); 
        }
    }
    uiPrintf("closing environment\n");
    closeEnvironment();
    uiPrintf("exiting\n");
    exit(0);
}

void getSupportedModes (A_UINT32 devNum, SUPPORTED_MODES *pModes)
{
    A_UINT16 tempValue;
	printf(" GETSupported Modes\n");

    if(configSetup.eepromLoad) {
		printf("get the mode flags from reading eeprom\n");
        //get the mode flags from reading eeprom
        tempValue = (A_UINT16)art_eepromRead(devNum, 0xc2);
        pModes->aMode = (A_BOOL)(tempValue & 0x01);
        pModes->bMode = (A_BOOL)((tempValue >> 1) & 0x01);
        pModes->gMode = (A_BOOL)((tempValue >> 2) & 0x01);
    }
    else {
#ifndef __ATH_DJGPPDOS__
        //get the values from the eep file
//		printf("LOAD FROM EEPROM TABLE %d\n");
        load_cal_section();
        pModes->aMode = (A_BOOL)CalSetup.Amode;
        pModes->bMode = (A_BOOL)CalSetup.Bmode;
        pModes->gMode = (A_BOOL)CalSetup.Gmode;
//		printf("LOAD FROM EEPROM TA

⌨️ 快捷键说明

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