目的:通过AT指令发送短消息给手机 我往串口发送AT指令后 手机没有收到短消息 我的write函数可能有问题 大家帮忙看看
//将接收到的信息,写到串口,将短信发出去
void SerialComm::WriteSerialComm(string phone,string phone_note)
{
cout<<"phone:: "<<phone<<endl;
cout<<"phone_note:: "<<phone_note<<endl;
/**发送AT指令*/
/*设置短信中心号码*/
string addr;
addr="0891683108100005F0";
/*手机号码处理:用字符串 phone*/
phone="685100010498F5";//写死了
/*短消息部分处理:用字符串msg*/
string msg=phone_note;
msg="024E2D"; //
/*组合*/
phone="11000D91" + phone;
phone=phone + "000800" + msg;
phone="11000D91685100010498F5000800024E2D"; //34/2=17
string send="";
send= addr + phone;
send= "0891683108100005F011000D91685100010498F5000800024E2D";
if(("0891683108100005F011000D91685100010498F5000800024E2D") != (addr+phone))
{
cout<<"no equal"<<endl;
exit(1);
}
/*开始发送*/
write(fd,"at+cmgf=0\r",10);
sleep(1);
write(fd,"at+cmgs=17\r",11);
sleep(1);
write(fd,"send\x01A",8);
sleep(1);
/*char bu[40];
read(fd,bu,40);
cout<<bu<<endl; */
cout<<endl<<"*****"<<endl;
sleep(2);
close(fd);
}