谢谢你。 代码运行的时候,标记位(TEST_GEAR)发生变化,但接受的数据一定要发送两次才会有变化,是不是main函数的数组不能这样写呢。谢谢解答
void Go_PutCmd(unsigned short *adr){
putCmd(WriteCmd,*adr++,ADC_VOL,sizeof(ADC_VOL)); //电压
putCmd(WriteCmd,*adr++,ADC_CUR,sizeof(ADC_CUR)); //电流
putCmd(WriteCmd,*adr++,ADC_WAT,sizeof(ADC_WAT)); //功率
putCmd(WriteCmd,*adr++,TST_MAR,sizeof(TST_MAR)); //测试标识
putCmd(WriteCmd,*adr++,TST_STA,sizeof(TST_STA)); //测试结果PASS/FAIL
putCmd(WriteCmd,*adr++,FNT_COR,sizeof(FNT_COR)); //结果字体颜色
putCmd(WriteCmd,*adr++,TST_MAX,sizeof(TST_MAX)); //最大值
putCmd(WriteCmd,*adr++,TST_AGE,sizeof(TST_AGE)); //平均值
putCmd(WriteCmd,*adr,TST_MIN,sizeof(TST_MIN)); //最小值
}
void Get_Back_Data(){ //获得测试档位的参数 0x34,0x35,0x57,表示45W
if(REC_COMPLETED){
REC_COMPLETED=0;
if(USART_RX_BUF[1]==0x31){
switch(USART_RX_BUF[2]){
case 0x00: TEST_GEAR=0;putchar(0);break;
case 0x10: TEST_GEAR=1;putchar(1);break;
case 0x20: TEST_GEAR=2;break;
case 0x30: TEST_GEAR=3;break;
case 0x40: TEST_GEAR=4;break;
case 0x50: TEST_GEAR=5;break;
case 0x60: TEST_GEAR=6;break;
case 0x70: TEST_GEAR=7;break;
default: break;
}
Go_PutCmd(write_add);
}
DATA_LENGTH=0;
ES=1;
}
}
void main(){
while(1){
if(TEST_GEAR==0){
ADC_VOL[0]=0x06;ADC_VOL[1]=0x1B; //电压
ADC_CUR[0]=0x01;ADC_CUR[1]=0x45; //电流
// unsigned char ADC_WAT[2]={0x01,0xFB}; //功率
// unsigned char TST_MAR[3]={0x34,0x35,0x57}; //测试标识
// unsigned char TST_STA[4]={0x50,0x41,0x53,0x53}; //测试结果
// unsigned char FNT_COR[2]={0x04,0x00}; //字体颜色0400绿色,F800红色
// unsigned char TST_MAX[2]={0x14,0x55}; //最大值
// unsigned char TST_MIN[2]={0x13,0x89}; //最小值
// unsigned char TST_AGE[2]={0x13,0xF1}; //平均值
}
if(TEST_GEAR==1){
ADC_VOL[0]=0x04;ADC_VOL[1]=0xCF; //电压 1231
ADC_CUR[0]=0x01;ADC_CUR[1]=0x3B; //电流 315
//ADC_WAT[2]={0x0F,0x25}; //功率 3877
//TST_MAR[4]={0x36,0x37,0x57}; //测试标识 67W
//TST_STA[4]={0x46,0x41,0x49,0x4C}; //测试结果 FAIL
//FNT_COR[2]={0xF8,0x00}; //字体颜色0400绿色,F800红色
//TST_MAX[2]={0x01,0x4F}; //电流最大值 335
//TST_MIN[2]={0x01,0x2C}; //电流最小值 300
//TST_AGE[2]={0x01,0x3D}; //电流平均值 317
}
Get_Back_Data();
}
}
|