|
做的一个保护器,用的430单片机和SIM300模块,利用手机短信控制现场设备,现在的问题是加回复函数后即执行一条指令返回一条确认消息,奇怪的是烧写完程序第一条指令可以执行,但后面的不执行,但如果人工复位后后面收到的指令也可以执行,注:未加回复前每条指令都可以执行,请问这是怎么回事?下面是部分代码
void Action_judge(void)
{
ulong ultemp1=0,ultemp2; //号码认证
char i,temp1;//,temp2;
delay1S();
for(i=0;i<13;i++)
{
receivnum=RX_action[i+2]-48;
}
for(i=0;i<11;i=i+2)
{
temp1=receivnum;
receivnum=receivnum[i+1];
receivnum[i+1]=temp1;
}
for(i=0;(i<2*tablesize-1)&&pass==0;i=i+2)
{
if(receivnum1==Teletable&&receivnum2==Teletable[i+1])
{
pass=1;
}
else
pass=0;
}
RX_bit=RX_temp;
flag_receiving=0;
counter_action=0;
if(pass)//如果通过认证
{
switch(RX_action[53])
{
case 65:
//设备自检
if(RX_action[45]==69)
{
flag_ensend=1;
flag_allsend=1;
}
flag_measuring=1;//恢复测量状态
flag_display=0;//显示Iresrms
break;
case 56:
//总闸合
if(RX_action[45]==66)
{
P5OUT&=~BIT4;
delay1S();
send_ATorder(TX_ATD);//删除消息
send_ATorder(TX_ATEsc);//从发送消息中跳出来
diskeyint(); //禁止按键中断
flag_ensend=0;//flag clearence
flag_measuring=0;
flag_Tfault=0;
Tstep2send=0;
flag_Irmsfault=0;
rmstep2send=0;
flag_Iresfault=0;
restep2send=0;
flag_reclose=0;
flag_Iresfault=0;
send_commandall(); //回复函数
enkeyint(); //发送完毕,打开按键中断
delay1S();
flag_measuring=1;
flag_display=0; flag_messfault=0;/*invalidate the message caused cut off flag*/
//清除过流标志
P4OUT&=~BIT0;
//清除过热标志
P4OUT&=~BIT1;
//清除剩余电流过大标志
P4OUT&=~BIT2;
}
break;
case 54:
//总闸分
if(RX_action[45]==66)
{
P5OUT|=BIT4;
delay1S();
send_ATorder(TX_ATD);
send_ATorder(TX_ATEsc);
diskeyint(); //禁止按键中断
flag_ensend=0;//flag clearence
flag_measuring=0;
// send_ATorder(TX_ATD);
flag_messfault=1;/*validate the flag to cutt off the break*/
//send_ATorder(TX_ATEsc);
send_commandall();
}
enkeyint(); //发送完毕,打开按键中断
delay1S();
delay1S();
//send_ATorder(TX_ATD);
flag_measuring=1; //恢复测量状态
flag_display=0;
break;
}
send_ATorder(TX_ATD);
send_ATorder(TX_ATD);
send_ATorder(TX_ATEsc);
enkeyint();
flag_measuring=1;//恢复测量状态
flag_display=0;
pass=0;
// ATTReset();
// delay1S();
// ATT_Cali();
}
else
{
send_ATorder(TX_ATD);
enkeyint();
flag_measuring=1;
flag_display=0;
}
}
|
|