有关AT命令的结束符?
send_GSM_cmd(fd,"AT\r");
send_GSM_cmd(fd,"AT+CNMI=2,2,0,1,1\r");
send_GSM_cmd(fd,"AT+CMGF=1\r");
send_GSM_cmd(fd,"AT+CMGS=138XXXXXXXX\r");
send_GSM_cmd(fd,"hello1A“);
以上是我发送AT的过程,但是对于结束到底该怎么表示才能发送成功一直不明白,有人说是1a,有人说是26,但是我无论以什么作为结束符,都感觉我的结束符被当做发的信息内容的一部分了,导致每次发送都不成功。希望大家帮我解决下这个问题,小弟刚接触AT命令,不是很明白。
[解决办法]
send_GSM_cmd(fd,"AT\r");
send_GSM_cmd(fd,"AT+CNMI=2,2,0,1,1\r");
send_GSM_cmd(fd,"AT+CMGF=1\r");
send_GSM_cmd(fd,"AT+CMGS=138XXXXXXXX\r");
楼主这样的发送方式是不对的!
应该这样:
send_GSM_cmd(fd,"AT\r");
if(strstr(buf,"OK"))
send_GSM_cmd(fd,"AT+CNMI=2,2,0,1,1\r");
.......
.......
send_GSM_cmd(fd,"AT+CMGS=138XXXXXXXX\r");
if(strstr(buf,">"))
send_GSM_cmd(fd,"hello\x1a");
大概是这样一个过程,即每发送一次AT命令后,收到OK后,才发送下一个AT命令!
至于发过号码后,需等待收到>后在发送内容,最后以0x1a结束
[解决办法]
send_GSM_cmd(fd,"AT\r");//添加自己的收串口数据接口,这里只是个例子while(1){ if(read(fd,buf,sizeof(buf))) break;}if(strstr(buf,"OK")) { ...}