我用的是wavecom的gsm,我想关闭猫,发送AT+CPOF
,通过pc机没问题
而改用单片机就不行了,那里错了呢,猫已经登陆网络了
#include<reg52.h> #include<stdio.h> #include<string.h>
#define uchar unsigned char
uchar idata RsPoint=0;
uchar RsBuf[256];
sbit buz = P1^0;
char code AT_wmoi3[]="AT"; //连机
char code AT_Code[]="OK"; //确认
char code AT_M[]="AT+CPOF
/"; //关机
void InitSerial(void)
{ SCON = 0x52; // setup serial port control TMOD = 0x20; // hardware (9600 BAUD @11.0592MHZ) TH1 = 0xFD; // TH1 TR1 = 1; // Timer 1 on }
////////////////////////////////////////////////////
void DelayMs(unsigned int count) // mSec Delay 11.0592 Mhz
{ unsigned int i; // Keil v7.5a while(count) { i = 115; while(i>0) i--; count--; } }
////////////////////////////////////////////////////
void SendASC(unsigned char ASC)
{ bit es; es=ES; ES=0; //关闭中断 TI=0; SBUF=ASC; while(!TI); TI=0; ES=es; }
//////////////////////////////////////////////////////
void Send_To_wmoi3(unsigned char* p,unsigned char Long)
{ while(Long--) { SendASC(*p++); } }
////////////////////////////////////////////////////////
void wmoi3_To_cpu(void) interrupt 4 using 1
{ unsigned char *p;
*RsBuf=0x0000;
if(RI==1) { RI=0;
RsBuf[RsPoint++]=SBUF;
p=strstr(RsBuf,AT_Code);
if(p!=NULL) {buz=~buz ;}
if (RsPoint>=sizeof(RsBuf))
{ RsPoint=0; } } }
/*uchar idata count_232=0; // 串行接收计数器 uchar xdata *read_232; // 串行接收数据缓冲区指针 uchar xdata *pr; */
//////////////////////////////////////////////////// /* void Send_AT(void)
{ unsigned char *p;
while(1)
{
ClrRsBuf(RsBuf,sizeof(RsBuf));
SendTowmoi3(AT_wmoi3,2); //"AT"
SendASC(OVER);
//************等待应答“ok" ES=1; //必须中断
Delay(50);
P=strstr(RsBuf,AT_Code);
if(p!=NULL) break;
} } */
main()
{ InitSerial() ; DelayMs(900000);//5s ES=1; Send_To_wmoi3(AT_M,8); while(1); }
|