public int send(string phonenum,string msg){
commPort.WriteLine("AT+CMGF=1\r\n");
commPort.WriteLine("AT+CSCS=\"UCS2\"\r\n");
commPort.WriteLine("AT+CMGS="+ToUnicode(phonenum)+"\r\n");
Thread.Sleep(1000);
string data = commPort.ReadExisting();
if(data.Length > 0 && data.EndsWith("> ")){
commPort.Write(ToUnicode(String.Format("{0}\x01a",msg)));
return 0;
}else{
return -1;
}
}
这个函数在发送完消息的时候,返回的数据是一堆乱码,应该是“>”,为什么吗?然后我在发送消息。另外有示例的话,最好。谢谢!
commPort.WriteLine("AT+CMGF=1\r\n");
commPort.WriteLine("AT+CSCS=\"UCS2\"\r\n");
commPort.WriteLine("AT+CMGS="+ToUnicode(phonenum)+"\r\n");
Thread.Sleep(1000);
string data = commPort.ReadExisting();
if(data.Length > 0 && data.EndsWith("> ")){
commPort.Write(ToUnicode(String.Format("{0}\x01a",msg)));
return 0;
}else{
return -1;
}
}
这个函数在发送完消息的时候,返回的数据是一堆乱码,应该是“>”,为什么吗?然后我在发送消息。另外有示例的话,最好。谢谢!
